Sep 15 - Reverse the check-in pages, set type of work Regular as default

This commit is contained in:
2026-09-15 11:44:05 -04:00
parent 4fc500707b
commit 23bd3a897b
4 changed files with 13 additions and 87 deletions
+6 -40
View File
@@ -69,12 +69,6 @@
margin-right: 6px;
}
/* Type of Work has no default - flagged when submit is tried without one */
select.work-type-missing {
border: 2px solid #ef4444 !important;
box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}
.bilingual-container {
background: rgba(255, 255, 255, 0.98);
border-radius: 8px;
@@ -1224,16 +1218,11 @@
name="work_type"
class="form-control"
autocomplete="off"
required
>
<!-- <option> cannot hold the coloured english-text/spanish-text
spans used elsewhere, so both languages share one plain label,
separated by "/" like the Employee ID placeholder above.
No default: the employee must pick a type before submitting.
Regular is "R" so it is distinguishable from "nothing picked";
the server stores it as the plain numeric ID. -->
<option value="" selected disabled>-- Select type of work / Seleccione tipo de trabajo --</option>
<option value="R">Regular / Trabajo Regular</option>
separated by "/" like the Employee ID placeholder above. -->
<option value="" selected>Regular / Trabajo Regular</option>
<option value="PW">Periodic Work / Trabajo Periódico (PW)</option>
<option value="SP">Special Project / Proyecto Especial (SP)</option>
<option value="C">Covering / Cobertura (C)</option>
@@ -1446,8 +1435,7 @@
// Bilingual labels - mirror WORK_TYPE_LABELS in routes/qr_codes.py.
const WORK_TYPE_LABELS = {
"": { en: "Regular", es: "Trabajo Regular" },
R: { en: "Regular", es: "Trabajo Regular" },
PW: { en: "Periodic Work", es: "Trabajo Periódico" },
PW: { en: "Periodic Work", es: "Trabajo Periódico" },
SP: { en: "Special Project", es: "Proyecto Especial" },
PT: { en: "Project Team", es: "Equipo de Proyecto" },
C: { en: "Covering", es: "Cobertura" },
@@ -1514,14 +1502,8 @@
return;
}
const field = document.getElementById("work_type");
// The server reports an open Regular check-in as ""; the dropdown's
// Regular option is "R" ("" is the "nothing selected" placeholder).
const optionValue = suggestedWorkTypeCode === "" ? "R" : suggestedWorkTypeCode;
if (field && field.value !== optionValue) {
field.value = optionValue;
}
if (field && field.value) {
field.classList.remove("work-type-missing");
if (field && field.value !== suggestedWorkTypeCode) {
field.value = suggestedWorkTypeCode;
}
}
@@ -1645,9 +1627,6 @@
});
field.addEventListener("change", function () {
if (field.value) {
field.classList.remove("work-type-missing");
}
if (!workTypeTouchedByEmployee) {
// No interaction preceded this change: it is Safari restoring the
// control, not the employee choosing. Re-assert the suggestion.
@@ -1935,19 +1914,6 @@
return;
}
// Type of Work has no default - the employee must choose one
if (!workType) {
if (workTypeField) {
workTypeField.classList.add("work-type-missing");
workTypeField.focus();
}
showStatusMessage(
"Please select the Type of Work / Por favor seleccione el Tipo de Trabajo",
"error"
);
return;
}
// Save Employee ID to localStorage for next time
try {
localStorage.setItem("qr_last_employee_id", employeeId);
@@ -1978,7 +1944,7 @@
// Prepare form data with location information
const formData = new FormData();
formData.append("employee_id", employeeId);
// R = Regular (ID stored unchanged); PW / SP / C are appended to the ID server-side
// Empty string = Regular; PW / SP / C are appended to the ID server-side
formData.append("work_type", workType);
// Read selected location — window globals (most reliable), then hidden field, then dropdown