Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Portals committed Sep 4, 2024
1 parent ed7bffa commit c1afbd5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ModelAndView getGroups(
return mv;
}

public record Member(String name, String post, UUID userId) {}
public record Member(String name, String post, UUID postId, UUID userId) {}

public static class MyMembershipsForm {

Expand Down Expand Up @@ -118,13 +118,17 @@ public ModelAndView getGroup(
group.get().groupMembers().stream()
.map(
groupMember -> {
String post = " - " + groupMember.post().enName();
String post = groupMember.post().enName();

if (groupMember.unofficialPostName() != null) {
post += " - " + groupMember.unofficialPostName();
}

return new Member(groupMember.user().nick(), post, groupMember.user().id());
return new Member(
groupMember.user().nick(),
post,
groupMember.post().id(),
groupMember.user().id());
})
.toList());
mv.addObject("random", Math.random());
Expand Down Expand Up @@ -199,6 +203,7 @@ public ModelAndView getCancelEditGroup(
+ groupMember.post().enName()
+ " - "
+ Objects.requireNonNullElse(groupMember.unofficialPostName(), ""),
groupMember.post().id(),
groupMember.user().id()))
.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
import it.chalmers.gamma.app.group.domain.EmailPrefix;
import it.chalmers.gamma.app.post.PostFacade;
import it.chalmers.gamma.app.post.domain.PostRepository;
import java.util.*;

import it.chalmers.gamma.app.validation.ValidationResult;
import it.chalmers.gamma.app.validation.Validator;
import jakarta.servlet.http.HttpServletResponse;
import java.util.*;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
Expand Down Expand Up @@ -128,7 +127,12 @@ private ModelAndView createGetEditPost(
ModelAndView mv = new ModelAndView();

if (form == null) {
form = new UpdatePost(post.get().svName(), post.get().enName(), post.get().emailPrefix(), post.get().version());
form =
new UpdatePost(
post.get().svName(),
post.get().enName(),
post.get().emailPrefix(),
post.get().version());
}

if (bindingResult != null) {
Expand Down Expand Up @@ -210,7 +214,6 @@ public static final class NameValidator implements Validator<String> {
@Override
public ValidationResult validate(String value) {
return withValidators(IS_NOT_EMPTY, SANITIZED_HTML, MAX_LENGTH.apply(2048)).validate(value);

}
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/resources/templates/client-details/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@
No users have approved this client yet
</p>
<ul th:if="${userApprovals.size() > 0}">
<li th:each="userApproval : ${userApprovals}" th:text="${userApproval.nick()}"></li>
<li th:each="userApproval : ${userApprovals}">
<a th:href="|/users/${userApproval.id()}|" th:text="${userApproval.fullName()}"></a>
</li>
</ul>
</article>

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/resources/templates/group-details/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
<ul>
<li th:each="member : ${members}">
<a th:href="|/users/${member.userId()}|" th:text="${member.name()}"></a>
<span th:text="${member.post()}"></span>
</li>
<span> - </span>
<a th:href="|/posts/${member.postId()}|" th:text="${member.post()}"></a>
</li>
</ul>

<footer th:if="${isAdmin}">
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/resources/templates/pages/super-groups.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<tbody>
<tr th:each="superGroup : ${superGroups}">
<td th:text="${superGroup.prettyName()}"></td>
<td th:text="${superGroup.type()}"></td>
<td>
<a th:href="|/types/${superGroup.type()}|" th:text="${superGroup.type()}"></a>
</td>
<td>
<a th:href="${'/super-groups/' + superGroup.id()}">Details</a>
</td>
Expand Down

0 comments on commit c1afbd5

Please sign in to comment.