feat: enhance candidate details display with logout functionality and conditional action visibility

This commit is contained in:
Ross
2026-01-19 11:40:47 +00:00
parent db04550e1a
commit a50af67315
2 changed files with 45 additions and 18 deletions
+6 -1
View File
@@ -118,19 +118,24 @@
<div id="options-panel" class="fullscreen-overlay"> <div id="options-panel" class="fullscreen-overlay">
<h1>RTS</h1> <h1>RTS</h1>
<span id="user-details"> <span id="user-details">
<span id="candidate-info">
<input <input
type="button" type="button"
id="btn-candidate-login" id="btn-candidate-login"
class="login-button" class="login-button"
value="Enter candidate details" value="Enter candidate details"
onclick="void(0)" onclick="void(0)"
/><span id="candidate-details"></span> />
<span id="candidate-details"></span>
</span>
<span id="user-actions">
<input <input
type="button" type="button"
id="btn-user-login" id="btn-user-login"
class="login-button" class="login-button"
value="User log in" value="User log in"
/> />
</span>
<!-- <a href="#" id="overlay-close" class="close"></a> --> <!-- <a href="#" id="overlay-close" class="close"></a> -->
<div id="user" class="user-text"></div> <div id="user" class="user-text"></div>
</span> </span>
+26 -4
View File
@@ -126,6 +126,9 @@ function showCandidateDetails() {
global_passcode = passToShow; global_passcode = passToShow;
$("#candidate-details").empty(); $("#candidate-details").empty();
$("#candidate-details").text(`Current: CID ${global_cid} / Passcode ${global_passcode}`);
// Create logout action and place it in the actions area so we can hide actions when users disabled
let logout = $("<span>[x]</span>"); let logout = $("<span>[x]</span>");
logout.css({ cursor: "pointer", "margin-left": "8px" }); logout.css({ cursor: "pointer", "margin-left": "8px" });
logout.click(() => { logout.click(() => {
@@ -139,7 +142,16 @@ function showCandidateDetails() {
} }
}); });
$("#candidate-details").append(`Current: CID ${global_cid} / Passcode ${global_passcode} `).append(logout); // Ensure the actions container exists and append the logout button there
if ($("#user-actions").length) {
$("#user-actions").empty().append(logout);
// Hide actions entirely if `allow_users` is false
if (!allow_users) {
$("#user-actions").hide();
} else {
$("#user-actions").show();
}
}
// If an exam results URL is configured, update the options link to point to the candidate's results // If an exam results URL is configured, update the options link to point to the candidate's results
if (URLS.exam_results_url != "" && URLS.exam_results_url != undefined) { if (URLS.exam_results_url != "" && URLS.exam_results_url != undefined) {
@@ -203,9 +215,10 @@ question_db.version(1).stores({
retrievePacketList(); retrievePacketList();
if (!allow_users) { if (!allow_users) {
// Keep the user/candidate details visible, but disable action buttons // Keep the user/candidate details visible, but hide the action buttons entirely
$("#btn-user-login").prop("disabled", true).attr("title", "User login disabled"); $("#user-actions").hide();
$("#btn-candidate-login").prop("disabled", true).attr("title", "Candidate entry disabled"); } else {
$("#user-actions").show();
} }
try { try {
@@ -384,13 +397,22 @@ async function loadExamList(data) {
$("#btn-user-login").hide(); $("#btn-user-login").hide();
let logout = $("<span>[x]</span>") let logout = $("<span>[x]</span>")
logout.css({ cursor: "pointer", "margin-left": "8px" });
logout.click(() => { logout.click(() => {
localStorage.removeItem("cid.cid"); localStorage.removeItem("cid.cid");
localStorage.removeItem("cid.passcode"); localStorage.removeItem("cid.passcode");
window.location = URLS.logout_url; window.location = URLS.logout_url;
}) })
// append logout to actions area so actions can be hidden when `allow_users` is false
if ($("#user-actions").length) {
$("#user-actions").append(logout);
if (!allow_users) {
$("#user-actions").hide();
}
} else {
$("#user").append(logout); $("#user").append(logout);
} }
}
let exams_started = []; let exams_started = [];