1

finish template refactoring

This commit is contained in:
Christoph
2020-04-12 15:41:21 +02:00
parent edb0aa9d96
commit fba166ad54
14 changed files with 144 additions and 163 deletions

View File

@ -5,6 +5,6 @@ import org.springframework.http.HttpStatus;
public class GroupNotFoundException extends EventException {
public GroupNotFoundException(String info) {
super(HttpStatus.NOT_FOUND, "Gruppe wurde nicht gefunden.", info);
super(HttpStatus.NOT_FOUND, "Die Gruppe existiert nicht oder wurde gelöscht.", info);
}
}

View File

@ -79,6 +79,10 @@ public class GroupDetailsController {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
if (ValidationService.checkIfMember(group, user)) {
return "redirect:/gruppen2/details/" + groupId;
}
groupService.addUser(user, group);
return "redirect:/gruppen2/details/" + groupId;
@ -93,6 +97,8 @@ public class GroupDetailsController {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
ValidationService.throwIfNoMember(group, user);
groupService.deleteUser(user, group);
return "redirect:/gruppen2";
@ -100,10 +106,10 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@GetMapping("/details/{id}/edit")
public String getDetailsMembers(KeycloakAuthenticationToken token,
Model model,
HttpServletRequest request,
@PathVariable("id") String groupId) {
public String getDetailsEdit(KeycloakAuthenticationToken token,
Model model,
HttpServletRequest request,
@PathVariable("id") String groupId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -124,9 +130,9 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/{id}/edit/meta")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMetaUpdate(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@Valid MetaForm form) {
public String postDetailsEditMeta(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@Valid MetaForm form) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -140,9 +146,9 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/{id}/edit/userlimit")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateUserLimit(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@Valid UserLimitForm form) {
public String postDetailsEditUserLimit(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@Valid UserLimitForm form) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -154,9 +160,9 @@ public class GroupDetailsController {
@RolesAllowed("ROLE_orga")
@PostMapping("/details/{id}/edit/csv")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateCsv(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@RequestParam(value = "file", required = false) MultipartFile file) {
public String postDetailsEditCsv(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@RequestParam(value = "file", required = false) MultipartFile file) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(IdService.stringToUUID(groupId));
@ -169,9 +175,9 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/{id}/edit/role/{userid}")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersUpdateRole(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
public String postDetailsEditRole(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -191,9 +197,9 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/{id}/edit/delete/{userid}")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsMembersDelete(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
public String postDetailsEditDelete(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId,
@PathVariable("userid") String userId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));
@ -211,8 +217,8 @@ public class GroupDetailsController {
@RolesAllowed({"ROLE_orga", "ROLE_studentin"})
@PostMapping("/details/{id}/edit/destroy")
@CacheEvict(value = "groups", allEntries = true)
public String postDetailsDestroy(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId) {
public String postDetailsEditDestroy(KeycloakAuthenticationToken token,
@PathVariable("id") String groupId) {
User user = new User(token);
Group group = projectionService.projectSingleGroup(UUID.fromString(groupId));

View File

@ -83,6 +83,6 @@ public class SearchAndInviteController {
return "redirect:/gruppen2/details/" + group.getId();
}
return "join";
return "link";
}
}

View File

@ -13,10 +13,9 @@
<h1 class="def-cursor">Neue Gruppe</h1>
<div class="content">
<h3 class="def-cursor">Eigenschaften:</h3>
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/create}">
<form enctype="multipart/form-data" method="post" th:action="@{/gruppen2/create}">
<div class="content">
<h3 class="def-cursor">Eigenschaften:</h3>
<!--Titel + Beschreibung-->
<div class="content-text" th:insert="~{fragments/forms :: meta}"></div>
@ -32,13 +31,14 @@
</div>
<!--CSV Import-->
<div class="content-text" th:insert="~{fragments/forms :: csvimport}"></div>
<div class="content-text mb-0" th:insert="~{fragments/forms :: csvimport}"></div>
</div>
<div class="content">
<!--Submit-->
<button class="btn btn-primary btn-block" type="submit">Gruppe Erstellen</button>
</form>
</div>
</div>
</form>
</div>
</main>

View File

@ -16,28 +16,13 @@
<div class="row">
<!--Gruppendetails-->
<div class="col-9 px-0">
<div class="content" th:insert="~{fragments/groups :: groupcontent}"></div>
<div class="content">
<div class="content-heading row">
<!--Badges-->
<span th:replace="~{fragments/gruppen :: badges}"></span>
<!--Spacer-->
<span class="col"></span>
<!--Edit-Pen-Button-->
<a class="fas fa-edit edit"
th:href="@{/gruppen2/details/{id}/meta(id=${group.getId()})}"
th:if="${group.getRoles().get(user.getId()) == admin}"></a>
</div>
<!--Description-->
<div class="content-text-in">
<span th:text="${group.getDescription()}"></span>
</div>
<!--Button-Bar-->
<div class="row">
<a class="btn btn-primary" href="/gruppen2">Fertig</a>
<!--Spacer-->
<span class="col"></span>
@ -72,7 +57,7 @@
<li class="list-group-item d-flex justify-content-between"
th:each="member : ${group.getMembers()}">
<span th:text="${member.getGivenname() + ' ' + member.getFamilyname().charAt(0) + '.'}"></span>
<span th:replace="~{fragments/gruppen :: userbadges}"></span>
<span th:replace="~{fragments/groups :: userbadges}"></span>
</li>
</ul>
</div>

View File

@ -99,7 +99,7 @@
<li class="list-group-item d-flex justify-content-between" th:each="member : ${group.getMembers()}">
<div>
<span th:text="${member.getGivenname() + ' ' + member.getFamilyname().charAt(0) + '.'}"></span>
<span th:replace="~{fragments/gruppen :: userbadges}"></span>
<span th:replace="~{fragments/groups :: userbadges}"></span>
</div>
<div class="d-flex">

View File

@ -10,7 +10,7 @@
<span class="input-group-text text-monospace">Gruppentitel:</span>
</div>
<input type="text" class="form-control" th:name="title" th:value="${group?.getTitle()}"
required>
required minlength="4" maxlength="128">
</div>
<!--Gruppenbeschreibung-->
@ -19,7 +19,7 @@
<span class="input-group-text text-monospace">Beschreibung:</span>
</div>
<textarea class="form-control" th:name="description" th:text="${group?.getDescription()}"
required></textarea>
required minlength="4" maxlength="512"></textarea>
</div>
</th:block>

View File

@ -0,0 +1,68 @@
<!DOCTYPE HTML>
<!--suppress ALL -->
<html lang="de" xmlns:th="http://www.thymeleaf.org">
<!--Grouptype Badges-->
<th:block th:fragment="badges">
<span class="badge badge-pill private"
th:if='${group.getType() == private}'>Privat</span>
<span class="badge badge-pill public"
th:if="${group.getType() == public}">Öffentlich</span>
<span class="badge badge-pill lecture"
th:if='${group.getType() == lecture}'>Veranstaltung</span>
<span class="badge badge-pill parent"
th:unless="${parent == null || parent.getTitle() == null|| parent.getTitle() == ''}"
th:text="${parent.getTitle()}">Parent</span>
<!--Needs completly projected (cached) groups-->
<!--<span class="badge badge-success float-right"
th:if='${group.getRoles().get(user.getId()) == admin}'>Admin</span>-->
</th:block>
<!--User Badges-->
<th:block th:fragment="userbadges">
<span class="badge badge-success align-self-start ml-2"
th:if="${group.getRoles().get(member.getId()) == admin}">Admin</span>
</th:block>
<th:block th:fragment="groupcontent">
<!--Badges-->
<div class="content-heading">
<span th:replace="~{fragments/groups :: badges}"></span>
</div>
<!--Description-->
<div class="content-text-in">
<span th:text="${group.getDescription()}"></span>
</div>
<!--<div class="content-text-in" th:if="${group.getMembers().contains(user.getId())}"></div>-->
</th:block>
<th:block th:fragment="joingroup">
<div class="content-heading" th:if="${group.getMembers().size() < group.getUserLimit()}">
<span>Möchtest du dieser Gruppe beitreten?</span>
</div>
<div class="row" th:if="${group.getMembers().size() < group.getUserLimit()}">
<form method="post" th:action="@{/gruppen2/details/{id}/join(id = ${group.getId()})}">
<button class="btn btn-success" type="submit">Gruppe beitreten.</button>
</form>
<div class="col"></div>
<a class="btn btn-warning" href="/gruppen2"
type="submit">Nicht beitreten.</a>
</div>
<div class="content-heading" th:unless="${group.getMembers().size() < group.getUserLimit()}">
<span>Diese Gruppe hat ihre maximale Teilnehmeranzahl erreicht.</span>
</div>
<div class="row" th:unless="${group.getMembers().size() < group.getUserLimit()}">
<div class="col"></div>
<a class="btn btn-primary" href="/gruppen2"
type="submit">Startseite.</a>
</div>
</th:block>

View File

@ -1,28 +0,0 @@
<!DOCTYPE HTML>
<!--suppress ALL -->
<html lang="de" xmlns:th="http://www.thymeleaf.org">
<!--Grouptype Badges-->
<th:block th:fragment="badges">
<span class="badge badge-pill private"
th:if='${group.getType() == private}'>Privat</span>
<span class="badge badge-pill public"
th:if="${group.getType() == public}">Öffentlich</span>
<span class="badge badge-pill lecture"
th:if='${group.getType() == lecture}'>Veranstaltung</span>
<span class="badge badge-pill parent"
th:unless="${parent == null || parent.getTitle() == null|| parent.getTitle() == ''}"
th:text="${parent.getTitle()}">Parent</span>
<!--Needs completly projected (cached) groups-->
<!--<span class="badge badge-success float-right"
th:if='${group.getRoles().get(user.getId()) == admin}'>Admin</span>-->
</th:block>
<!--User Badges-->
<th:block th:fragment="userbadges">
<span class="badge badge-success align-self-start ml-2"
th:if="${group.getRoles().get(member.getId()) == admin}">Admin</span>
</th:block>

View File

@ -19,7 +19,7 @@
<a class="link col" th:href="@{/gruppen2/details/{id}(id=${group.getId()})}"
th:text="${group.getTitle()}"></a>
<span th:replace="~{fragments/gruppen :: badges}"></span>
<span th:replace="~{fragments/groups :: badges}"></span>
</div>
<div class="content-text-in">
<span th:text="${group.getDescription()}"></span>

View File

@ -1,66 +0,0 @@
<!DOCTYPE html>
<html lang="de"
th:replace="~{mopslayout :: html(name='Gruppenbildung', headcontent=~{:: headcontent}, navigation=~{:: navigation}, bodycontent=~{:: bodycontent})}"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Gruppe Beitreten</title>
<th:block th:fragment="headcontent">
<!-- Links, Skripts, Styles hier einfügen! -->
</th:block>
</head>
<body>
<header>
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation">
<ul>
<li>
<a th:href="@{/gruppen2}">Gruppen</a>
</li>
<li>
<a th:href="@{/gruppen2/create}">Erstellen</a>
</li>
<li>
<a th:href="@{/gruppen2/search}">Suche</a>
</li>
</ul>
</nav>
</header>
<main th:fragment="bodycontent">
<div class="container-fluid">
<div class="shadow-sm p-4"
style="border: 1px solid aliceblue; border-radius: 5px; background: aliceblue;">
<h1 style="color: black; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word;"
th:text="${group.getTitle()}"></h1>
<div class="shadow-sm p-4" style="background: white;">
<p style="overflow-wrap: break-word; font-optical-sizing: auto;"
th:text="${group.getDescription()}"></p>
</div>
<div class="form-group mt-2" th:if="${group.getMembers().size() < group.getUserLimit()}">
<h3>Möchtest du dieser privaten Gruppe beitreten?</h3>
<div class="text-right">
<form method="post" th:action="@{/gruppen2/details/{id}/join(id = ${group.getId()})}">
<input name="id" th:value="${group.getId()}" type="hidden"/>
<button class="btn btn-primary"
style="background: #52a1eb; border-style: none;"
type="submit">Ja, Gruppe beitreten
</button>
<a class="btn btn-primary"
href="/gruppen2"
style="background: #52a1eb; border-style: none;"
type="submit">Ich will das nicht.
</a>
</form>
</div>
</div>
<h3 class="mt-2" th:if="${group.getMembers().size() >= group.getUserLimit()}">Gruppe ist
voll und
kann nicht
beigetreten
werden.</h3>
</div>
</div>
</main>
</body>
</html>

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="de" xmlns:th="http://www.thymeleaf.org" th:replace="~{mopslayout :: html(
name='Gruppenbildung',
title='Beitreten',
headcontent=~{fragments/general :: headcontent('details')},
navigation=~{fragments/general :: nav('none')},
bodycontent=~{:: bodycontent})}">
<body>
<main th:fragment="bodycontent">
<div class="container-fluid">
<h1 class="def-cursor" th:text="${group.getTitle()}"></h1>
<div class="content" th:insert="~{fragments/groups :: groupcontent}"></div>
<div class="content" th:insert="~{fragments/groups :: joingroup}"></div>
</div>
</main>
</body>
</html>

View File

@ -10,24 +10,18 @@
<main th:fragment="bodycontent">
<div class="container-fluid">
<h1 class="def-cursor" th:text="${group.getTitle()}"></h1>
<div class="content">
<div class="content-heading">
<div th:replace="~{fragments/gruppen :: badges}"></div>
</div>
<div class="content" th:insert="~{fragments/groups :: groupcontent}"></div>
<div class="content-text-in">
<span th:text="${group.getDescription()}"></span>
</div>
<div class="content" th:unless="${group.getType() == private}"
th:insert="~{fragments/groups :: joingroup}"></div>
<form th:if="${group.getType() == public}" method="post"
th:action="@{/gruppen2/details/{id}/join(id=${group.getId()})}">
<button class="btn btn-primary" type="submit">Beitreten!</button>
</form>
<div class="content row" th:if="${group.getType() == private}">
<span class="col"></span>
<a class="btn btn-primary" href="/gruppen2">Startseite.</a>
</div>
</div>
</main>
</body>

View File

@ -29,7 +29,7 @@
<!--Ergebnisliste-->
<div class="content" th:each="group: ${groups}">
<div class="content-heading row">
<span th:replace="~{fragments/gruppen :: badges}"></span>
<span th:replace="~{fragments/groups :: badges}"></span>
<a class="link col" th:href="@{/gruppen2/details/{id}(id=${group.getId()})}"
th:text="${group.getTitle()}"></a>