Merge pull request #137 from hhu-propra2/group-list-ordering
Group list ordering
This commit is contained in:
@ -86,14 +86,21 @@ public class GroupService {
|
|||||||
|
|
||||||
List<Group> visibleGroups = projectEventList(groupEvents);
|
List<Group> visibleGroups = projectEventList(groupEvents);
|
||||||
|
|
||||||
return visibleGroups.parallelStream()
|
sortByGroupType(visibleGroups);
|
||||||
|
|
||||||
|
return visibleGroups.stream()
|
||||||
.filter(group -> group.getType() != null)
|
.filter(group -> group.getType() != null)
|
||||||
.filter(group -> !eventService.userInGroup(group.getId(), userId))
|
.filter(group -> !eventService.userInGroup(group.getId(), userId))
|
||||||
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wird verwendet beim Gruppe erstellen bei der Parent-Auswahl: nur Titel benötigt.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws EventException
|
||||||
|
*/
|
||||||
public List<Group> getAllLecturesWithVisibilityPublic() throws EventException {
|
public List<Group> getAllLecturesWithVisibilityPublic() throws EventException {
|
||||||
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
List<Event> createEvents = eventService.translateEventDTOs(eventRepository.findAllEventsByType("CreateGroupEvent"));
|
||||||
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("DeleteGroupEvent")));
|
createEvents.addAll(eventService.translateEventDTOs(eventRepository.findAllEventsByType("DeleteGroupEvent")));
|
||||||
@ -102,7 +109,7 @@ public class GroupService {
|
|||||||
|
|
||||||
List<Group> visibleGroups = projectEventList(createEvents);
|
List<Group> visibleGroups = projectEventList(createEvents);
|
||||||
|
|
||||||
return visibleGroups.parallelStream()
|
return visibleGroups.stream()
|
||||||
.filter(group -> group.getType() == GroupType.LECTURE)
|
.filter(group -> group.getType() == GroupType.LECTURE)
|
||||||
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
.filter(group -> group.getVisibility() == Visibility.PUBLIC)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -129,4 +136,17 @@ public class GroupService {
|
|||||||
|| group.getDescription().toLowerCase().contains(search.toLowerCase()))
|
|| group.getDescription().toLowerCase().contains(search.toLowerCase()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sortByGroupType(List<Group> groups) {
|
||||||
|
groups.sort((g1, g2) -> {
|
||||||
|
if (g1.getType() == GroupType.LECTURE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (g2.getType() == GroupType.LECTURE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,9 @@ public class UserService {
|
|||||||
newGroups.add(group);
|
newGroups.add(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
groupService.sortByGroupType(newGroups);
|
||||||
|
|
||||||
return newGroups;
|
return newGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation" th:switch="${account.getRoles().contains('orga')}">
|
<nav class="navigation navigation-secondary" is="mops-navigation" th:fragment="navigation"
|
||||||
|
th:switch="${account.getRoles().contains('orga')}">
|
||||||
<ul>
|
<ul>
|
||||||
<li class="active">
|
<li class="active">
|
||||||
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
<a href="/" th:href="@{/gruppen2}">Gruppen</a>
|
||||||
@ -44,8 +45,12 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<br>
|
<br>
|
||||||
<div th:each="gruppe: ${gruppen}">
|
<div th:each="gruppe: ${gruppen}">
|
||||||
<div class="shadow-sm p-4" style="border: none; border-radius: 5px; background: aliceblue">
|
<div class="shadow-sm p-4"
|
||||||
|
style="border: none; border-radius: 5px; background: aliceblue">
|
||||||
<h3 style="color: dodgerblue; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word">
|
<h3 style="color: dodgerblue; font-weight: bold; font-optical-sizing: auto; overflow-wrap: break-word">
|
||||||
|
<span class="badge badge-pill badge-success"
|
||||||
|
style="background: lightseagreen; margin-right: 25px;"
|
||||||
|
th:if='${gruppe.getType() == gruppe.getType().LECTURE}'>Veranstaltung</span>
|
||||||
<a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}"
|
<a th:href="@{/gruppen2/details/{id}(id=${gruppe.getId()})}"
|
||||||
th:text="${gruppe.getTitle()}"></a>
|
th:text="${gruppe.getTitle()}"></a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@ -59,8 +59,11 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr th:each="gruppe : ${gruppen}" th:switch="${gruppe.getUserMaximum() != 100000}">
|
<tr th:each="gruppe : ${gruppen}" th:switch="${gruppe.getUserMaximum() != 100000}">
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
|
<span class="badge badge-pill badge-success"
|
||||||
|
style="background: lightseagreen; margin-right: 25px;"
|
||||||
|
th:if='${gruppe.getType() == gruppe.getType().LECTURE}'>Veranstaltung</span>
|
||||||
<a th:href="@{/gruppen2/detailsSearch(id=${gruppe.getId()})}"
|
<a th:href="@{/gruppen2/detailsSearch(id=${gruppe.getId()})}"
|
||||||
th:text="${gruppe.getTitle()}">Gruppenname</a>
|
th:text="${#strings.abbreviate(gruppe.getTitle(), 50)}">Gruppenname</a>
|
||||||
</th>
|
</th>
|
||||||
<td style="" th:text="${#strings.abbreviate(gruppe.getDescription(), 50)}">
|
<td style="" th:text="${#strings.abbreviate(gruppe.getDescription(), 50)}">
|
||||||
Beschreibung
|
Beschreibung
|
||||||
|
|||||||
Reference in New Issue
Block a user