Skip to content

Commit

Permalink
Sort all the things!
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Jun 14, 2024
1 parent 066e670 commit dd71d12
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.chalmers.gamma.app.user.allowlist.AllowListFacade;
import it.chalmers.gamma.app.user.allowlist.AllowListRepository;
import java.util.Comparator;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
Expand All @@ -28,7 +29,8 @@ public ModelAndView getAllowList(
}

List<String> allowList = this.allowListFacade.getAllowList();
mv.addObject("allowList", allowList);
mv.addObject(
"allowList", allowList.stream().sorted(Comparator.comparing(String::toLowerCase)).toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import it.chalmers.gamma.app.apikey.ApiKeySettingsFacade;
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import jakarta.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
Expand Down Expand Up @@ -227,7 +224,11 @@ public ModelAndView getNewSuperGroupType(
ModelAndView mv = new ModelAndView();

mv.setViewName("partial/new-super-group-type-to-api-settings");
mv.addObject("superGroupTypes", this.superGroupFacade.getAllTypes());
mv.addObject(
"superGroupTypes",
this.superGroupFacade.getAllTypes().stream()
.sorted(Comparator.comparing(String::toLowerCase))
.toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import it.chalmers.gamma.security.authentication.AuthenticationExtractor;
import it.chalmers.gamma.security.authentication.UserAuthentication;
import jakarta.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -243,6 +240,12 @@ public ModelAndView newRestrictionRow(
Collectors.toMap(
SuperGroupFacade.SuperGroupDTO::id,
SuperGroupFacade.SuperGroupDTO::prettyName)));
mv.addObject(
"superGroupKeys",
this.superGroupFacade.getAll().stream()
.sorted(Comparator.comparing(superGroup -> superGroup.prettyName().toLowerCase()))
.map(SuperGroupFacade.SuperGroupDTO::id)
.toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public ModelAndView getGroups(
mv.addObject("page", "groups/page");
}

mv.addObject("groups", groups);
mv.addObject(
"groups",
groups.stream()
.sorted(Comparator.comparing(group -> group.prettyName().toLowerCase()))
.toList());

return mv;
}
Expand Down Expand Up @@ -310,12 +314,14 @@ public ModelAndView getGroupEdit(
ModelAndView mv = new ModelAndView();
mv.setViewName("group-details/edit-group");

List<SuperGroupFacade.SuperGroupDTO> superGroups = this.superGroupFacade.getAll();
List<SuperGroupFacade.SuperGroupDTO> superGroups =
this.superGroupFacade.getAll().stream()
.sorted(Comparator.comparing(superGroup -> superGroup.prettyName().toLowerCase()))
.toList();
List<UserFacade.UserDTO> users = this.userFacade.getAll();
List<PostFacade.PostDTO> posts = this.postFacade.getAll();

if (form != null) {

form =
new GroupForm(
group.get().version(),
Expand All @@ -339,10 +345,22 @@ public ModelAndView getGroupEdit(
"posts",
posts.stream()
.collect(Collectors.toMap(PostFacade.PostDTO::id, PostFacade.PostDTO::enName)));
mv.addObject(
"postKeys",
posts.stream()
.sorted(Comparator.comparing(post -> post.enName().toLowerCase()))
.map(PostFacade.PostDTO::id)
.toList());

mv.addObject(
"users",
users.stream().collect(Collectors.toMap(UserFacade.UserDTO::id, UserFacade.UserDTO::nick)));
mv.addObject(
"userKeys",
users.stream()
.sorted(Comparator.comparing(user -> user.nick().toLowerCase()))
.map(UserFacade.UserDTO::id)
.toList());

if (bindingResult.hasErrors()) {
mv.addObject(BindingResult.MODEL_KEY_PREFIX + "form", bindingResult);
Expand Down Expand Up @@ -397,10 +415,22 @@ public ModelAndView getNewMember(
"posts",
posts.stream()
.collect(Collectors.toMap(PostFacade.PostDTO::id, PostFacade.PostDTO::enName)));
mv.addObject(
"postKeys",
posts.stream()
.sorted(Comparator.comparing(post -> post.enName().toLowerCase()))
.map(PostFacade.PostDTO::id)
.toList());

mv.addObject(
"users",
users.stream().collect(Collectors.toMap(UserFacade.UserDTO::id, UserFacade.UserDTO::nick)));
mv.addObject(
"userKeys",
users.stream()
.sorted(Comparator.comparing(user -> user.nick().toLowerCase()))
.map(UserFacade.UserDTO::id)
.toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import it.chalmers.gamma.app.post.PostFacade;
import it.chalmers.gamma.app.post.domain.PostRepository;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -32,7 +33,9 @@ public ModelAndView getPosts(
mv.addObject("page", "pages/posts");
}

mv.addObject("posts", posts);
mv.addObject(
"posts",
posts.stream().sorted(Comparator.comparing(post -> post.enName().toLowerCase())).toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import it.chalmers.gamma.app.supergroup.domain.SuperGroupTypeRepository;
import jakarta.servlet.http.HttpServletResponse;
import java.util.Comparator;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -36,7 +37,8 @@ public ModelAndView getSuperGroupTypes(
var v = new CreateType("");

mv.addObject("form", v);
mv.addObject("types", types);
mv.addObject(
"types", types.stream().sorted(Comparator.comparing(String::toLowerCase)).toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import it.chalmers.gamma.app.group.GroupFacade;
import it.chalmers.gamma.app.supergroup.SuperGroupFacade;
import it.chalmers.gamma.app.supergroup.domain.SuperGroupRepository;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -37,7 +38,11 @@ public ModelAndView getSuperGroups(
mv.addObject("page", "pages/super-groups");
}

mv.addObject("superGroups", superGroups);
mv.addObject(
"superGroups",
superGroups.stream()
.sorted(Comparator.comparing(superGroup -> superGroup.prettyName().toLowerCase()))
.toList());

return mv;
}
Expand Down Expand Up @@ -118,7 +123,11 @@ public ModelAndView getSuperGroupEdit(
sg.type(),
sg.svDescription(),
sg.enDescription()));
mv.addObject("types", this.superGroupFacade.getAllTypes());
mv.addObject(
"types",
this.superGroupFacade.getAllTypes().stream()
.sorted(Comparator.comparing(String::toLowerCase))
.toList());

return mv;
}
Expand Down Expand Up @@ -212,7 +221,11 @@ public ModelAndView getCreateSuperGroup(
}

mv.addObject("form", new CreateSuperGroupForm("", "", "", "", ""));
mv.addObject("types", this.superGroupFacade.getAllTypes());
mv.addObject(
"types",
this.superGroupFacade.getAllTypes().stream()
.sorted(Comparator.comparing(String::toLowerCase))
.toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import it.chalmers.gamma.security.authentication.AuthenticationExtractor;
import it.chalmers.gamma.security.authentication.UserAuthentication;
import java.time.Year;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
Expand Down Expand Up @@ -40,7 +41,9 @@ public ModelAndView getUsers(
mv.addObject("page", "users/page");
}

mv.addObject("users", users);
mv.addObject(
"users",
users.stream().sorted(Comparator.comparing(user -> user.nick().toLowerCase())).toList());

return mv;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<label>
User
<select class="userId">
<option th:each="user : ${users}" th:value="${user.key}" th:text="${user.value}"></option>
<option th:each="userKey : ${userKeys}" th:value="${userKey}" th:text="${users.get(userKey)}"></option>
</select>
</label>
<label>
Post
<select class="postId">
<option th:each="post : ${posts}" th:value="${post.key}" th:text="${post.value}"></option>
<option th:each="postKey : ${postKeys}" th:value="${postKey}" th:text="${posts.get(postKey)}"></option>
</select>
</label>
<label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<label>
Post
<select class="postId" th:field="*{members[__${memberStat.index}__].postId}">
<option th:each="post : ${posts}" th:value="${post.key}" th:text="${post.value}"></option>
<option th:each="postKey : ${postKeys}" th:value="${postKey}" th:text="${posts.get(postKey)}"></option>
</select>
</label>
<label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="restriction-row">
<select class="restriction">
<option th:each="superGroup : ${superGroups}" th:value="${superGroup.key}" th:text="${superGroup.value}"></option>
<option th:each="superGroupKey : ${superGroupKeys}" th:value="${superGroupKey}" th:text="${superGroups.get(superGroupKey)}"></option>
</select>
<button class="outline contrast" _="on click remove closest .restriction-row then call updateNames('restrictions', '.restriction')" type="button">Delete</button>
</div>

0 comments on commit dd71d12

Please sign in to comment.