Skip to content
Snippets Groups Projects
Commit c4bb87bd authored by Ruben Backx's avatar Ruben Backx :coffee:
Browse files

Merge branch...

Merge branch '609-store-last-location-enqueued-and-suggest-as-room-when-enqueuing-again' into 'development'

Resolve "Store last location enqueued and suggest as room when enqueuing again"

Closes #609

See merge request !660
parents b3b04bc7 e033d73f
Branches
Tags
2 merge requests!664Version 2.1.4,!660Resolve "Store last location enqueued and suggest as room when enqueuing again"
......@@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- Students are now provided with a suggestion of their most recent location within a lab when they requeue. [@hpage](https://gitlab.ewi.tudelft.nl/hpage)
### Changed
### Fixed
......
......@@ -31,6 +31,7 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.transaction.Transactional;
import nl.tudelft.labracore.api.dto.*;
......@@ -119,6 +120,9 @@ public class LabController {
@Autowired
private RoleDTOService roleService;
@Autowired
private HttpSession session;
/**
* Gets the page with information on the lab with the given id. This page is different for TAs than for
* students. For students, this page shows their history of requests and their current requests. For TAs,
......@@ -209,6 +213,10 @@ public class LabController {
model.addAttribute("request", new LabRequestCreateDTO());
model.addAttribute("rType", "lab");
if (session.getAttribute("lastKnownLocation") != null) {
model.addAttribute("lastKnownLocation", session.getAttribute("lastKnownLocation"));
}
return "lab/enqueue/lab";
} else {
model.addAttribute("request", new SelectionRequestCreateDTO());
......@@ -284,6 +292,11 @@ public class LabController {
dto.setSession(lab);
rs.createRequest(dto, student.getId(), true);
if (dto.getComment() != null) {
session.setAttribute("lastKnownLocation", dto.getComment());
}
return "redirect:/lab/" + lab.getId();
}
......
......@@ -169,7 +169,9 @@
<div class="col-sm-8">
<textarea maxlength="250" th:classappend="${#fields.hasErrors('comment')} ? 'is-invalid'"
class="form-control" id="input-comment" th:field="*{comment}"
placeholder="You can use this field to specify a location within the room, e.g. your cubicle number."></textarea>
th:placeholder="'You can use this field to specify a location within the room, e.g. your cubicle number.'"></textarea>
<input type="hidden" id="lastKnownLocation" th:value="${lastKnownLocation}" />
<div class="invalid-feedback" th:if="${#fields.hasErrors('comment')}" th:errors="*{comment}">
Comment error
......@@ -181,6 +183,7 @@
<script src="/js/map_loader.js"></script>
<script type="text/javascript" th:inline="javascript">
function checkEnrolled(val) {
$(".enrollment-status").css('display', 'none')
$("#enqueue").prop('disabled', false)
......@@ -191,6 +194,14 @@
}
}
$(document).ready(() => {
const lastKnownLocation = $("#lastKnownLocation").val();
const inputCommentField = $("#input-comment");
if (lastKnownLocation) {
inputCommentField.val(lastKnownLocation);
}
});
//<![CDATA[
const spDefaults = $.fn.selectpicker.Constructor.DEFAULTS;
spDefaults.mobile = true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment