diff --git a/src/main/java/nl/tudelft/ewi/queue/controller/RequestController.java b/src/main/java/nl/tudelft/ewi/queue/controller/RequestController.java index d8f1434bffeecea1724636910dd79d9df3e06779..add43d88fb41af3026a2913532f5343f89a03d6d 100644 --- a/src/main/java/nl/tudelft/ewi/queue/controller/RequestController.java +++ b/src/main/java/nl/tudelft/ewi/queue/controller/RequestController.java @@ -326,6 +326,17 @@ public class RequestController { return "redirect:/requests"; } + @RequestMapping(value = "/request/{id}/room", method = RequestMethod.POST) + @PreAuthorize("@permissionService.canNextRequest(principal, #id)") + public String updateRoom(@PathVariable("id") Long id, + @RequestParam("room") Room room) { + Request request = requestRepository.findById(id); + request.setRoom(room); + requestRepository.save(request); + + return "redirect:/request/" + id; + } + @RequestMapping(value = "/course/{id}/requests/export", method = RequestMethod.GET, produces = "application/json") @PreAuthorize("@permissionService.canEditCourse(principal, #id)") @JsonView(View.Summary.class) diff --git a/src/main/java/nl/tudelft/ewi/queue/model/Request.java b/src/main/java/nl/tudelft/ewi/queue/model/Request.java index 13e65df38dd500695848de07967b8909dfc88ea7..f3581aeff2807822ffa4f22324df45e493b7f07f 100644 --- a/src/main/java/nl/tudelft/ewi/queue/model/Request.java +++ b/src/main/java/nl/tudelft/ewi/queue/model/Request.java @@ -597,9 +597,8 @@ public class Request implements RecordsEvents<Request>, Serializable, Comparable requests.put("labId", this.getLab().getId().toString()); requests.put("lab",this.getLab().getTitle()); requests.put("assignment", this.getAssignment().getName()); - requests.put("room", this.getRoom().getName()); + requests.put("room", (this.getRoom() == null) ? "TBA" : this.getRoom().getName()); requests.put("course", this.getLab().getCourse().toString()); - requests.put("room", this.getRoom().toString()); if (this.getAssistant() != null) requests.put("assigned", this.getAssistant().toString()); if (this.getHandledAt() != null) diff --git a/src/main/java/nl/tudelft/ewi/queue/repository/RequestRepository.java b/src/main/java/nl/tudelft/ewi/queue/repository/RequestRepository.java index e1563b2d4e6d4e7f6446d1afc31edd55128ff1ae..ff02263dbc880a36ac3caca5baee57590b966b22 100644 --- a/src/main/java/nl/tudelft/ewi/queue/repository/RequestRepository.java +++ b/src/main/java/nl/tudelft/ewi/queue/repository/RequestRepository.java @@ -21,4 +21,5 @@ public interface RequestRepository extends CrudRepository<Request, Long>, JpaSpe List<Request> findByAssistant(User assistant); + Request findById(Long id); } diff --git a/src/main/resources/templates/request/list/requesttable.html b/src/main/resources/templates/request/list/requesttable.html index 81b3eb16bec50e8304ecd089c016230ccae6092c..739f6f5dbef30f9d70ec534250d995428798c374 100644 --- a/src/main/resources/templates/request/list/requesttable.html +++ b/src/main/resources/templates/request/list/requesttable.html @@ -40,7 +40,7 @@ <small th:text="${#temporals.format(request.handledAt, 'dd-MM HH:mm')}">22 May 2016</small> </th:block> </td> - <td th:text="${request.getRoom().toString()}">Room</td> + <td th:text="${(request.getRoom() == null)? 'TBA' : request.getRoom().toString()}">Room</td> </tr> </th:block> </tbody> diff --git a/src/main/resources/templates/request/view.html b/src/main/resources/templates/request/view.html index 0246b1fc9f9be99057e7cabd881a152458d71151..3273d6d11e2e0ab1ea182fc357945189302f1567 100644 --- a/src/main/resources/templates/request/view.html +++ b/src/main/resources/templates/request/view.html @@ -1,7 +1,8 @@ <!DOCTYPE html> -<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="course/view"> +<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" + layout:decorate="course/view"> <head> - <title >Request #[[${request.id}]] · [[${request.lab.course}]]</title> + <title>Request #[[${request.id}]] · [[${request.lab.course}]]</title> </head> @@ -12,8 +13,9 @@ <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="/">Home</a></li> <li class="breadcrumb-item"><a href="/courses">Courses</a></li> - <li class="breadcrumb-item"><a href="#" th:href="@{/course/{id}(id=${course.id})}" th:text="${course.code}">TI1234</a></li> - <li class="breadcrumb-item active" >Request #[[${request.id}]]</li> + <li class="breadcrumb-item"><a href="#" th:href="@{/course/{id}(id=${course.id})}" th:text="${course.code}">TI1234</a> + </li> + <li class="breadcrumb-item active">Request #[[${request.id}]]</li> </ol> </nav> @@ -27,31 +29,35 @@ <a th:href="${submissionUrl}" target="_blank" class="btn btn-secondary">View submission</a> </div> </div> - <h3 th:unless="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]]</h3> - <h3 th:if="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]] at [[${request.getSlot()}]]</h3> + <h3 th:unless="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]]</h3> + <h3 th:if="${request.getLab().getSignOffIntervals()}">Request #[[${request.id}]] at + [[${request.getSlot()}]]</h3> </div> <div class="row"> - <div class="col-sm-12" th:if="${request.isHandled() and !request.getLeftFeedback() and request.getRequestEntity().getId().equals(#authenticated.getId())}"> + <div class="col-sm-12" + th:if="${request.isHandled() and !request.getLeftFeedback() and request.getRequestEntity().getId().equals(#authenticated.getId())}"> <div class="page-header"> <h4>Feedback</h4> </div> - <form action="#" th:action="@{/request/{id}/feedback(id=${request.id})}" method="post" class="form-horizontal"> - <div class="form-group"> - <label for="inputFeedback" class="col-sm-2 control-label">Feedback</label> - - <div class="col-sm-8"> - <textarea maxlength="250" class="form-control" id="inputFeedback" name="feedback" placeholder="Leave feedback about the TA (only teachers can see this feedback)."></textarea> - </div> + <form action="#" th:action="@{/request/{id}/feedback(id=${request.id})}" method="post" + class="form-horizontal"> + <div class="form-group"> + <label for="inputFeedback" class="col-sm-2 control-label">Feedback</label> + + <div class="col-sm-8"> + <textarea maxlength="250" class="form-control" id="inputFeedback" name="feedback" + placeholder="Leave feedback about the TA (only teachers can see this feedback)."></textarea> </div> + </div> - <div class="form-group"> - <div class="col-sm-offset-2 col-sm-10"> - <button type="submit" class="btn btn-primary">Leave feedback</button> - </div> + <div class="form-group"> + <div class="col-sm-offset-2 col-sm-10"> + <button type="submit" class="btn btn-primary">Leave feedback</button> </div> - </form> + </div> + </form> </div> <div class="col-sm-4"> @@ -79,63 +85,87 @@ <h4 class="card-header">Info</h4> <div class="card-body"> - <dl class="dl-horizontal request"> - <th:block > - <dt>Request by</dt> - <dd th:text="${request.requestEntity}"></dd> - </th:block> - - <th:block th:if="${request.requestEntity.isGroup()}"> - <dt>Members</dt> - <dd th:text="${request.requestEntity.membersToString()}"></dd> - </th:block> - - <dt>Course</dt> - <dd th:text="${request.lab.course}"></dd> - - <dt>Lab</dt> - <dd th:text="${request.lab}"></dd> - - <dt>Assignment</dt> - <dd th:text="${request.assignment}"></dd> - - <dt>Room</dt> - <dd th:text="${request.room}"></dd> + <dl class="dl-horizontal request"> + <th:block> + <dt>Request by</dt> + <dd th:text="${request.requestEntity}"></dd> + </th:block> - <dt>Type</dt> - <dd th:text="${request.requestType.name}"></dd> + <th:block th:if="${request.requestEntity.isGroup()}"> + <dt>Members</dt> + <dd th:text="${request.requestEntity.membersToString()}"></dd> + </th:block> - <th:block th:unless="${#strings.isEmpty(request.comment)}"> - <dt>Comment</dt> - <dd th:text="${request.comment}"></dd> - </th:block> + <dt>Course</dt> + <dd th:text="${request.lab.course}"></dd> + + <dt>Lab</dt> + <dd th:text="${request.lab}"></dd> + + <dt>Assignment</dt> + <dd th:text="${request.assignment}"></dd> + + <dt>Room</dt> + <dd th:text="${request.room}" th:if="${request.getLab().studentCanChooseRoom()}"></dd> + <dd th:if="${not request.getLab().studentCanChooseRoom()}"> + <form action="#" th:action="@{/request/{id}/room(id=${request.id})}" method="post" class="form-horizontal"> + <label for="inputRoom" class="col-sm-4 control-label">What room are you in?</label> + + <div class="col-sm-8 form-group" > + <select class="form-control" id="inputRoom" th:field="${request.room}"> + <div> + <option value="" th:selected="selected">Choose a room</option> + <option th:each="room : ${request.getLab().rooms}" th:value="${room.id}" + th:text="${room}" th:selected="${room.equals(request.getRoom())? 'selected' : ''}">DW 1.01 + </option> + </div> + </select> + </div> + <div class="form-group"> + <button type="submit" class="btn btn-primary">Update room</button> + </div> + </form> + </dd> + + <dt>Type</dt> + <dd th:text="${request.requestType.name}"></dd> + + <th:block th:unless="${#strings.isEmpty(request.comment)}"> + <dt>Comment</dt> + <dd th:text="${request.comment}"></dd> + </th:block> - <th:block th:if="${request.assistant != null}"> - <dt>Assistant</dt> - <dd th:text="${request.assistant}"></dd> - </th:block> + <th:block th:if="${request.assistant != null}"> + <dt>Assistant</dt> + <dd th:text="${request.assistant}"></dd> + </th:block> - <dt>Status</dt> - <dd th:include="request/status :: status(${request.status})"></dd> + <dt>Status</dt> + <dd th:include="request/status :: status(${request.status})"></dd> - <th:block th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)}"> - <th:block th:unless="${#strings.isEmpty(request.reason)}"> - <dt>Reason (TA only)</dt> - <dd th:text="${request.reason}"></dd> + <th:block + th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)}"> + <th:block th:unless="${#strings.isEmpty(request.reason)}"> + <dt>Reason (TA only)</dt> + <dd th:text="${request.reason}"></dd> + </th:block> </th:block> - </th:block> - <th:block th:unless="${#strings.isEmpty(request.reasonForStudent)}"> - <dt>Reason</dt> - <dd th:text="${request.reasonForStudent}"></dd> - </th:block> - </dl> + <th:block th:unless="${#strings.isEmpty(request.reasonForStudent)}"> + <dt>Reason</dt> + <dd th:text="${request.reasonForStudent}"></dd> + </th:block> + </dl> </div> - <div class="card-footer" th:if="${@permissionService.canFinishRequest(#authentication.principal, request.id)}"> + <div class="card-footer" + th:if="${@permissionService.canFinishRequest(#authentication.principal, request.id)}"> <div class="btn-group d-flex" role="group"> - <a href="#" th:href="@{/request/{id}/approve(id=${request.id})}" class="w-100 btn btn-success btn-sm">Approve</a> - <a href="#" th:href="@{/request/{id}/reject(id=${request.id})}" class="w-100 btn btn-danger btn-sm">Reject</a> - <a href="#" th:href="@{/request/{id}/forward(id=${request.id})}" class="w-100 btn btn-warning btn-sm">Forward</a> + <a href="#" th:href="@{/request/{id}/approve(id=${request.id})}" + class="w-100 btn btn-success btn-sm">Approve</a> + <a href="#" th:href="@{/request/{id}/reject(id=${request.id})}" + class="w-100 btn btn-danger btn-sm">Reject</a> + <a href="#" th:href="@{/request/{id}/forward(id=${request.id})}" + class="w-100 btn btn-warning btn-sm">Forward</a> </div> </div> </div> @@ -145,25 +175,32 @@ </div> <p th:if="${#lists.isEmpty(request.previous)}"> - There are no previous requests by <strong th:text="${request.requestEntity}">student</strong> for <strong th:text="${request.assignment}">Assembly programming</strong>. + There are no previous requests by <strong th:text="${request.requestEntity}">student</strong> for + <strong th:text="${request.assignment}">Assembly programming</strong>. </p> <div class="list-group mb-3" th:unless="${#lists.isEmpty(request.previous)}"> - <a href="#" class="list-group-item list-group-item-action" th:each="request : ${request.previous}" th:href="@{/request/{id}(id=${request.id})}"> + <a href="#" class="list-group-item list-group-item-action" th:each="request : ${request.previous}" + th:href="@{/request/{id}(id=${request.id})}"> <th:block th:if="${request.revoked}"> Request <strong>#[[${request.id}]]</strong> was <strong>revoked</strong>. </th:block> <th:block th:unless="${request.revoked}"> - <th:block th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> - Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by <strong>[[${request.assistant}]]</strong> because “[[${request.reason}]]” + <th:block + th:if="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> + Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by + <strong>[[${request.assistant}]]</strong> because “[[${request.reason}]]” + </th:block> + <th:block + th:unless="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> + Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by + <strong>[[${request.assistant}]]</strong>. </th:block> - <th:block th:unless="${@permissionService.canViewRequestReason(#authentication.principal, request.id)} and ${!request.reason.equals('')}"> - Request <strong>#[[${request.id}]]</strong> was <strong>[[${request.status}]]</strong> by <strong>[[${request.assistant}]]</strong>. - </th:block> </th:block> - <p class="time" th:text="${#prettyTime.diffForHumans(request.handledAt)}" th:if="request.handledAt">5 minutes ago</p> + <p class="time" th:text="${#prettyTime.diffForHumans(request.handledAt)}" th:if="request.handledAt"> + 5 minutes ago</p> </a> </div> </div>