Skip to content

Commit

Permalink
Fixed displaying of blocked slot without replacementText
Browse files Browse the repository at this point in the history
Removed delete button of reserve slots
Added blocking in wizard and event edit
  • Loading branch information
Alf-Melmac committed Jun 8, 2021
1 parent 73e1692 commit 9d7a50c
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import de.webalf.slotbot.model.dtos.website.EventEditDto;
import de.webalf.slotbot.service.external.DiscordApiService;
import de.webalf.slotbot.util.LongUtils;
import de.webalf.slotbot.util.StringUtils;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -133,6 +134,9 @@ private EventDetailsSlotDto toEventDetailsSlotDto(@NonNull Slot slot) {
if (slot.getUser() != null) {
if (slot.getUser().isDefaultUser()) {
text = slot.getReplacementText();
if (StringUtils.isEmpty(text)) {
text = "Gesperrt";
}
blocked = true;
} else {
text = discordApiService.getName(LongUtils.toString(slot.getUser().getId()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/webalf/slotbot/model/Squad.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Squad(long id, String name, List<Slot> slotList, Event event) {
this.event = event;
}

static final String RESERVE_NAME = "Reserve";
public static final String RESERVE_NAME = "Reserve";

// Getter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import javax.validation.constraints.Size;
import java.util.List;

import static de.webalf.slotbot.model.Squad.RESERVE_NAME;

/**
* @author Alf
* @since 30.10.2020
Expand All @@ -24,4 +26,8 @@ public class EventDetailsSquadDto extends AbstractIdEntityDto {
List<EventDetailsSlotDto> slotList;

boolean notEmpty;

public boolean isReserve() {
return getName().equals(RESERVE_NAME);
}
}
14 changes: 13 additions & 1 deletion src/main/resources/static/assets/css/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,16 @@

.btn-denied:hover {
color: gray;
}
}

.btn-lock .fa-lock-open {
color: mediumseagreen;
}

.btn-lock .fa-lock {
color: lightcoral;
}

.btn-lock:not(.js-blocked):hover {
opacity: 50%;
}
6 changes: 6 additions & 0 deletions src/main/resources/static/assets/js/eventSave.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ function getSquads(update = false) {
name: $slot.find('.js-slot-name').val().trim(),
number: $slot.find('.js-slot-number').val()
};
if ($slot.find('.fa-lock').length !== 0) {
slot.user = {
id: defaultUserId
}
slot.replacementText = 'Gesperrt'
}
if (update) {
slot.id = $slot.data('slotid');
}
Expand Down
15 changes: 13 additions & 2 deletions src/main/resources/static/assets/js/slotList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ $(function () {
<div class="col-md-10">
<input class="form-control js-slot-name" type="text" placeholder="Slot Name" required>
</div>
<div class="col-md-1 d-flex btn btn-xl btn-wht js-trash" type="button"><em class="far fa-trash-alt"></em></div>
<div class="col-md-1 d-flex">
<div class="btn btn-xl btn-lock p-0 pr-1 js-lock" type="button" title="Blockierung">
<em class="fas fa-lock-open"></em>
</div>
<div class="btn btn-xl btn-wht p-0 js-trash" type="button">
<em class="far fa-trash-alt"></em>
</div>
</div>
</div>`;

const newSquad =
Expand Down Expand Up @@ -59,8 +66,12 @@ $(function () {
$this.appendTo($slots);
});

$squads.on('click', '.js-lock:not(.js-blocked, .btn-denied)', function () {
$(this).find('.fas').toggleClass('fa-lock-open fa-lock');
});

$squads.on('click', '.js-trash', function () {
const $row = $(this).parent('.form-row');
const $row = $(this).parents('.form-row');
if ($row.hasClass('js-squad')) {
$row.parent('.js-complete-squad').remove();
} else {
Expand Down
40 changes: 27 additions & 13 deletions src/main/resources/templates/eventEdit.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ <h3>Teilnahmeplatzaufzählung</h3>
<div class="col-md-11">
<!--suppress HtmlFormInputWithoutLabel -->
<input class="form-control js-squad-name" type="text" placeholder="Squad Name"
required th:value="${squad.name}">
required th:value="${squad.name}" th:disabled="${squad.isReserve()}">
</div>
<div th:unless="${squad.isNotEmpty()}" class="d-flex btn btn-xl btn-wht js-trash" type="button">
<div th:unless="${squad.isNotEmpty() || squad.isReserve()}" class="d-flex btn btn-xl btn-wht js-trash" type="button">
<em class="far fa-trash-alt"></em>
</div>
<div th:if="${squad.isNotEmpty()}" class="d-flex btn btn-xl btn-denied"
Expand All @@ -191,23 +191,35 @@ <h3>Teilnahmeplatzaufzählung</h3>
<div class="col-md-1">
<!--suppress HtmlFormInputWithoutLabel -->
<input class="form-control js-slot-number" type="number" min="1" value="1"
required th:value="${slot.number}">
required th:value="${slot.number}" th:disabled="${squad.isReserve()}">
</div>
<div class="col-md-10">
<!--suppress HtmlFormInputWithoutLabel -->
<input class="form-control js-slot-name" type="text" placeholder="Slot Name"
required th:value="${slot.name}">
required th:value="${slot.name}" th:disabled="${squad.isReserve()}">
</div>
<div th:unless="${slot.isOccupied()}" class="col-md-1 d-flex btn btn-xl btn-wht js-trash"
type="button">
<em class="far fa-trash-alt"></em>
</div>
<div th:if="${slot.isOccupied()}" class="col-md-1 d-flex btn btn-xl btn-denied"
title="Dieser Slot ist belegt">
<em class="far fa-trash-alt"></em>
<div th:unless="${squad.isReserve()}" class="col-md-1 d-flex">
<div th:unless="${slot.isBlocked()}" class="btn btn-xl p-0 pr-1 js-lock"
th:classappend="${slot.isOccupied()} ? 'btn-denied' : 'btn-lock'"
type="button" title="Blockierung">
<em class="fas fa-lock-open"></em>
</div>
<div th:if="${slot.isBlocked()}" class="btn btn-xl p-0 pr-1 js-lock js-blocked"
th:classappend="${slot.isOccupied()} ? 'btn-denied' : 'btn-lock'"
type="button" title="Blockierung">
<em class="fas fa-lock"></em>
</div>
<div th:unless="${slot.isOccupied()}" class="btn btn-xl btn-wht p-0 js-trash"
type="button">
<em class="far fa-trash-alt"></em>
</div>
<div th:if="${slot.isOccupied()}" class="btn btn-xl btn-denied p-0"
title="Dieser Slot ist belegt">
<em class="far fa-trash-alt"></em>
</div>
</div>
</div>
<div type="button" class="btn btn-success rounded-circle js-add-slot"
<div th:unless="${squad.isReserve()}" type="button" class="btn btn-success rounded-circle js-add-slot"
title="Slot hinzufügen">
<em class="fas fa-plus"></em>
</div>
Expand Down Expand Up @@ -236,7 +248,7 @@ <h3>Teilnahmeplatzaufzählung</h3>
</div>
<div class="col-md-6">
<div id="btnSaveSlotlist" class="btn btn-primary float-right" tabindex="0" data-toggle="popover"
data-trigger="focus" data-content="Alle Pflichtfelder ausfüllen!">
data-trigger="focus" data-content="Alle Pflichtfelder ausfüllen!">
Slotliste speichern
</div>
</div>
Expand Down Expand Up @@ -285,6 +297,8 @@ <h3>Teilnahmeplatzaufzählung</h3>
const putEventEditableUrl = /*[[${putEventEditableUrl}]]*/ '';
const eventDetailsUrl = /*[[${eventDetailsUrl}]]*/ '';
const savedEvent = /*[[${event}]]*/ '';

const defaultUserId = /*[[${T(de.webalf.slotbot.model.User).DEFAULT_USER_ID}]]*/ '';
/*]]>*/
</script>
<script th:src="@{/assets/js/eventSave.js}"></script>
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/eventWizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ <h3>Teilnahmeplatzaufzählung</h3>
const uploadSqmFileUrl = /*[[${uploadSqmFileUrl}]]*/ '';
const postEventUrl = /*[[${postEventUrl}]]*/ '';
const eventDetailsUrl = /*[[${eventDetailsUrl}]]*/ '';

const defaultUserId = /*[[${T(de.webalf.slotbot.model.User).DEFAULT_USER_ID}]]*/ '';
/*]]>*/
</script>
<script th:src="@{/assets/js/eventSave.js}"></script>
Expand Down

0 comments on commit 9d7a50c

Please sign in to comment.