Sep 14 - Update the check-ins pages to force employee to select the type of work
This commit is contained in:
@@ -69,6 +69,12 @@
|
||||
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;
|
||||
@@ -1218,11 +1224,16 @@
|
||||
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. -->
|
||||
<option value="" selected>Regular / Trabajo Regular</option>
|
||||
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>
|
||||
<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>
|
||||
@@ -1435,7 +1446,8 @@
|
||||
// Bilingual labels - mirror WORK_TYPE_LABELS in routes/qr_codes.py.
|
||||
const WORK_TYPE_LABELS = {
|
||||
"": { en: "Regular", es: "Trabajo Regular" },
|
||||
PW: { en: "Periodic Work", es: "Trabajo Periódico" },
|
||||
R: { en: "Regular", es: "Trabajo Regular" },
|
||||
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" },
|
||||
@@ -1502,8 +1514,14 @@
|
||||
return;
|
||||
}
|
||||
const field = document.getElementById("work_type");
|
||||
if (field && field.value !== suggestedWorkTypeCode) {
|
||||
field.value = suggestedWorkTypeCode;
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1627,6 +1645,9 @@
|
||||
});
|
||||
|
||||
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.
|
||||
@@ -1914,6 +1935,19 @@
|
||||
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);
|
||||
@@ -1944,7 +1978,7 @@
|
||||
// Prepare form data with location information
|
||||
const formData = new FormData();
|
||||
formData.append("employee_id", employeeId);
|
||||
// Empty string = Regular; PW / SP / C are appended to the ID server-side
|
||||
// R = Regular (ID stored unchanged); 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
|
||||
|
||||
Reference in New Issue
Block a user