Skip to content

Commit

Permalink
Added guild emoji for reserved slot
Browse files Browse the repository at this point in the history
  • Loading branch information
Alf-Melmac committed Jan 28, 2022
1 parent 65de3ac commit 913242f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private EventDetailsSlotDto toEventDetailsSlotDto(@NonNull Slot slot) {
.id(slot.getId())
.name(slot.getName())
.number(slot.getNumber())
.reservedFor(GuildAssembler.toDto(slot.getReservedFor()))
.reservedFor(GuildAssembler.toDto(slot.getEffectiveReservedForDisplay()))
.text(text)
.occupied(!(slot.getUser() == null || slot.getUser().isDefaultUser()))
.blocked(blocked)
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/de/webalf/slotbot/model/Slot.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ public Guild getEffectiveReservedFor() {
return reservedFor != null ? reservedFor : getSquad().getReservedFor();
}

/**
* Same as {@link #getEffectiveReservedFor()} but doesn't return {@link #reservedFor} if the whole squad is reserved
* for this {@link Guild}
*
* @see #getEffectiveReservedFor()
*/
public Guild getEffectiveReservedForDisplay() {
final Guild effectiveReservedFor = getEffectiveReservedFor();
if (effectiveReservedFor != null &&
getSquad().getSlotList().stream().allMatch(slot -> effectiveReservedFor.equals(slot.getReservedFor()))) {
return null;
}
return effectiveReservedFor;
}

// Setter

/**
Expand Down
13 changes: 12 additions & 1 deletion src/main/resources/templates/eventDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,18 @@ <h5 class="modal-title" id="addChannelLabel">Kanal hinzufügen</h5>
<p class="mb-1" th:text="${slot.number}"></p>
</div>
<div class="col-md-5">
<p class="mb-1" th:text="${slot.name}"></p>
<p class="mb-1">
<span th:text="${slot.name}"></span>
<th:block th:if="${slot.reservedFor != null}"
th:with="reservedFor=${slot.reservedFor}">
<img th:unless="${#strings.isEmpty(reservedFor.emojiUrl)}"
class="square-em-1" th:src="${reservedFor.emojiUrl}"
th:title="${reservedFor.groupIdentifier}"
th:alt="${reservedFor.groupIdentifier}">
<span th:if="${#strings.isEmpty(reservedFor.emojiUrl)}"
th:text="${'[' + reservedFor.groupIdentifier + ']'}"></span>
</th:block>
</p>
</div>
<div th:if="${#strings.isEmpty(slot.text)}">
<p class="mb-1 font-weight-bold">Freier Slot</p>
Expand Down

0 comments on commit 913242f

Please sign in to comment.