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

Active shop now shows, clicking the shop takes you to that shop's settings page

parent f25d885f
No related branches found
No related tags found
2 merge requests!114LoggingService service class, new method to add a log to the "Logs" table when...,!93Thirty five
...@@ -117,43 +117,36 @@ public class AdminController { ...@@ -117,43 +117,36 @@ public class AdminController {
} }
//Get the shops paired with admin, sorted by category //Get the shops paired with admin, sorted by category
Map<String,ArrayList<Map<Shops,Users>>> categorySortedShops = new HashMap<>(); Map<String,ArrayList<Shops>> categorySortedShops = new HashMap<>();
//For each shop //For each shop
for (Shops sh : shopsRepo.findAll()){ for (Shops sh : shopsRepo.findAll()){
Map<Shops, Users> shopsUsersMap = new HashMap<>();
//Get the perms for that shop //Get the perms for that shop
List<UserPermissions> permList = userPermissionsRepo.findByShopID(sh.getShopId()); List<UserPermissions> permList = userPermissionsRepo.findByShopID(sh.getShopId());
//For each perm //For each perm
for(UserPermissions p : permList){ for(UserPermissions p : permList){
//If it is the shop creator then pair them with the shop //If it is the shop creator then pair them with the shop
if(p.getAdminType().getAdminTypeId() == 2){ if(p.getAdminType().getAdminTypeId() == 2 && user.get().getUserId() == p.getUser().getUserId()){
shopsUsersMap.put(sh, p.getUser()); //Set an empty list for the category if it doesn't exist
if(!categorySortedShops.containsKey(sh.getCategory().getCategoryName())){
categorySortedShops.put(sh.getCategory().getCategoryName(),new ArrayList<>());
}
//Add the pair to the correct category list
ArrayList<Shops> cat = categorySortedShops.get(sh.getCategory().getCategoryName());
cat.add(sh);
categorySortedShops.put(sh.getCategory().getCategoryName(), cat);
} }
} }
//Set an empty list for the category if it doesn't exist
if(!categorySortedShops.containsKey(sh.getCategory())){
categorySortedShops.put(sh.getCategory().getCategoryName(),new ArrayList<>());
}
//Add the pair to the correct category list
ArrayList<Map<Shops,Users>> cat = categorySortedShops.get(sh.getCategory().getCategoryName());
if(shopsUsersMap.size() != 0){
cat.add(shopsUsersMap);
categorySortedShops.put(sh.getCategory().getCategoryName(), cat);
}
} }
Map<String,ArrayList<Map<Shops,Users>>> filteredCategorySortedShops = new HashMap<>(); Map<String,ArrayList<Shops>> filteredCategorySortedShops = new HashMap<>();
for(Map.Entry e : categorySortedShops.entrySet()){ for(Map.Entry e : categorySortedShops.entrySet()){
ArrayList<Map<Shops,Users>> val = (ArrayList<Map<Shops, Users>>) e.getValue(); ArrayList<Shops> val = (ArrayList<Shops>) e.getValue();
if(val.size() != 0){ if(val.size() != 0){
filteredCategorySortedShops.put(e.getKey().toString(), val); filteredCategorySortedShops.put(e.getKey().toString(), val);
} }
} }
System.out.println(filteredCategorySortedShops);
model.addAttribute("adminOfByCategory",filteredCategorySortedShops); model.addAttribute("adminOfByCategory",filteredCategorySortedShops);
model.addAttribute("linkedShop", userShopLinked.hasShop(user.get().getUserId())); model.addAttribute("linkedShop", userShopLinked.hasShop(user.get().getUserId()));
......
...@@ -167,8 +167,12 @@ html{ ...@@ -167,8 +167,12 @@ html{
} }
.sidebar .shop-tab.shop-name{ .sidebar .shop-tab.shop-name{
color: red;
height: 50px; height: 50px;
color: #4a4a4a;
}
.sidebar .shop-tab.shop-name:hover{
opacity: 0.8;
} }
.shop-tab-container{ .shop-tab-container{
......
...@@ -46,16 +46,19 @@ ...@@ -46,16 +46,19 @@
</div> </div>
<div class="sidebar closed" id="side_shop_select"> <div class="sidebar closed" id="side_shop_select">
<th:block th:each="category: ${adminOfByCategory.entrySet()}"> <th:block th:each="category: ${adminOfByCategory.entrySet()}">
<div class="shop-tab-container" onclick="this.classList.toggle('open')"> <div class="shop-tab-container">
<div class="shop-tab shop-category"> <div class="shop-tab shop-category" onclick="this.parentElement.classList.toggle('open')">
<p th:text="${category.getKey()}"></p> <p th:text="${category.getKey()}"></p>
<div class="baseIcon"> <div class="baseIcon">
<i class="fas fa-caret-down fa-lg"></i> <i class="fas fa-caret-down fa-lg"></i>
</div> </div>
</div> </div>
<div class="shop-tab shop-name" th:each="shop: ${category.getValue()}"> <th:block th:each="sh: ${category.getValue()}">
<p th:text="${shop.entrySet.iterator.next().getKey()}"></p> <div th:class="'shop-tab shop-name' + ${shop.getShopId() == sh.getShopId()?' active':''}"
</div> th:onclick="'window.location.href=\'/settings?shopId='+${sh.getShopId()} + '&tab=shop-setup\''">
<p th:text="'- ' + ${sh.getShopName()}"></p>
</div>
</th:block>
</div> </div>
</th:block> </th:block>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment