Skip to content
Snippets Groups Projects
Commit a8e83611 authored by John Watkins's avatar John Watkins
Browse files

Merge branch 'develop' into 'issueThirtyThree'

will now successfully hide shops

See merge request !90
parents a478d521 816dbfcc
Branches
No related tags found
3 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!91Issue thirty three,!90will now successfully hide shops
......@@ -85,4 +85,5 @@ public class Shops {
return this.getShopName();
}
}
......@@ -27,13 +27,15 @@ public class DashboardStampLoader {
Set<UserStampBoards> userStamps = userRepo.findById((long) userId).get().getUserStampBoards();
for(UserStampBoards u:userStamps){
combinedInfo.add(
new HashMap<>() {{
put("UserStampBoard", u);
put("Shop", shopsRepo.
findByStampboardId(u.getStampBoard().getStampBoardId()));
}}
);
if(shopsRepo.findByStampboardId(u.getStampBoard().getStampBoardId()).isShopActive()) {
combinedInfo.add(
new HashMap<>() {{
put("UserStampBoard", u);
put("Shop", shopsRepo.
findByStampboardId(u.getStampBoard().getStampBoardId()));
}}
);
}
}
List<Shops> favouriteShops = new ArrayList<>();
......@@ -41,19 +43,22 @@ public class DashboardStampLoader {
boolean alreadyInPuchased = false;
for(Shops s:shopsRepo.findAll()){
UserFavouriteDTO ufDTO = new UserFavouriteDTO(new UserFavouriteForm(s.getShopId()), userId);
if(toggleFavourite.alreadyInDb(ufDTO)){
for(Map<String, Object> m:combinedInfo){
Shops shop = (Shops) m.get("Shop");
if(shop.getShopId() == s.getShopId()){
alreadyInPuchased = true;
if(s.isShopActive()) {
UserFavouriteDTO ufDTO = new UserFavouriteDTO(new UserFavouriteForm(s.getShopId()), userId);
if (toggleFavourite.alreadyInDb(ufDTO)) {
for (Map<String, Object> m : combinedInfo) {
Shops shop = (Shops) m.get("Shop");
if (shop.getShopId() == s.getShopId()) {
alreadyInPuchased = true;
}
}
}
if(!alreadyInPuchased) {
favouriteShops.add(s);
}
alreadyInPuchased = false;
if (!alreadyInPuchased) {
favouriteShops.add(s);
System.out.println(s.isShopActive());
}
alreadyInPuchased = false;
}
}
}
......
......@@ -69,7 +69,7 @@ public class HomeController {
int userId = jwtUtils.getLoggedInUserId(session).get();
//System.out.println(shopsRepo.findAll());
List<Shops> allShops = shopsRepo.findAll();
List<Shops> allShops = shopsRepo.findActiveShops();
List<Shops> favouriteShops = new ArrayList();
List<Shops> normalShops = new ArrayList();
......
......@@ -7,6 +7,10 @@
margin-right: 20px;
}
.hidden{
display:none;
}
.reward_card.hidden{
display: none;
}
......
......@@ -55,9 +55,9 @@ function filterRewards(input){
for(let reward of rewards){
let title = reward.getElementsByClassName("title")[0].innerText
if(title.toLowerCase().replace(" ","").includes(input.value.toString().toLowerCase().replace(" ", ""))){
reward.classList.remove("hidden")
reward.parentElement.classList.remove("hidden")
}else{
reward.classList.add("hidden")
reward.parentElement.classList.add("hidden")
added++;
}
}
......
let shopId;
function toggleShop(shopId){
params = 'shopId=' + shopId;
//Sends list to server
......
......@@ -5,6 +5,7 @@
<link th:replace="fragments/libs.html :: fa"/>
<link th:replace="fragments/nav.html :: nav-css"/>
<script th:replace="fragments/business_card.html :: card_js"/>
<script src="/js/selectCategories.js"></script>
<link rel="stylesheet" href="/css/reward_card.css">
<link rel="stylesheet" href="/css/business_container.css">
<meta charset="UTF-8">
......@@ -17,7 +18,7 @@
<div class="is-full-width is-flex is-justify-content-space-between is-align-content-center" style="margin: 20px;">
<a href="/"> < Back to dashboard</a>
<div class="control has-icons-left">
<input class="input" type="text" placeholder="Search">
<input class="input" type="text" placeholder="Search" oninput="filterRewards(this)">
<span class="icon is-small is-left">
<i class="fas fa-search"></i>
</span>
......@@ -26,8 +27,9 @@
<div class="is-flex is-flex-direction-row is-justify-content-space-around is-flex-wrap-wrap">
<!--Reward Card Here-->
<div th:each="shopMap: ${activeShops}" style="margin:20px!important" th:include="fragments/reward_card.html :: reward_card"
th:with="title=${shopMap.get('Shop').shopName},
<div th:each="shopMap: ${activeShops}" th:include="fragments/reward_card.html :: reward_card"
th:with="margin=true,
title=${shopMap.get('Shop').shopName},
stamps=${shopMap.get('UserStampBoard').userStampPosition},
next_reward=${@claimableRewards.nextReward(shopMap.get('UserStampBoard'))},
reward_amount_obtained=${@claimableRewards.totalClaimableRewards(shopMap.get('UserStampBoard'))},
......@@ -38,7 +40,8 @@
<!--Reward Card Here-->
<div th:each="shop: ${favouriteShops}" th:include="fragments/reward_card.html :: reward_card"
th:with="title=${shop.shopName},
th:with="margin=true,
title=${shop.shopName},
stamps=0,
next_reward=${shop.getStampBoard.getRewards.get(0).rewardStampLocation},
reward_amount_obtained=0,
......
......@@ -5,7 +5,7 @@
<title>Title</title>
</head>
<body th:fragment="reward_card">
<div class="reward_card" style="position:relative;">
<div class="reward_card" th:style="${margin?'margin:20px!important':''}+ ';position:relative'">
<div class="favouriteStar starContainer" th:classappend="${isFavourite ? 'active' : ''}" th:onclick="'favouriteBusiness(this,' + ${shopId} + ');'">
<span class="icon favouriteStar">
<i class="far fa-star"></i>
......
......@@ -31,7 +31,8 @@
<div class="horiz_scroll is-full-width mb-1">
<!--Reward Card Here-->
<div th:each="shopMap: ${activeShops}" th:include="fragments/reward_card.html :: reward_card"
th:with="title=${shopMap.get('Shop').shopName},
th:with="margin=false,
title=${shopMap.get('Shop').shopName},
stamps=${shopMap.get('UserStampBoard').userStampPosition},
next_reward=${@claimableRewards.nextReward(shopMap.get('UserStampBoard'))},
reward_amount_obtained=${@claimableRewards.totalClaimableRewards(shopMap.get('UserStampBoard'))},
......@@ -42,7 +43,8 @@
<!--Reward Card Here-->
<div th:each="shop: ${favouriteShops}" th:include="fragments/reward_card.html :: reward_card"
th:with="title=${shop.shopName},
th:with="margin=false,
title=${shop.shopName},
stamps=0,
next_reward=${shop.getStampBoard.getRewards.get(0).rewardStampLocation},
reward_amount_obtained=0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment