fix(measure): supervisor modal — backspace works and fields reset
Two issues with the "Autorizzazione capoturno" modal: 1. Backspace and digits did not work in the username/password fields. The numpad component installs a window-level keydown handler (for the USB caliper / keyboard wedge) that preventDefault()s digits, Backspace, Enter etc. It swallowed those keys inside the modal inputs. Guard handleKeydown to ignore events whose target is an editable field (INPUT/TEXTAREA/SELECT/ contentEditable); the numpad has no text inputs of its own. 2. The modal kept the previous username/password: opening only set the flag, and closing via backdrop click did not clear the fields. Add openSupervisorModal()/closeSupervisorModal() that always reset username, password and error, and use them for every open (fermo_linea, fine_produzione, out_of_tolerance) and close (backdrop, Annulla). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,17 @@ function numpad() {
|
|||||||
* @param {KeyboardEvent} e - The keyboard event
|
* @param {KeyboardEvent} e - The keyboard event
|
||||||
*/
|
*/
|
||||||
handleKeydown(e) {
|
handleKeydown(e) {
|
||||||
|
// Ignore keystrokes aimed at an editable field (e.g. the supervisor
|
||||||
|
// login modal). The numpad has no text inputs of its own, so this
|
||||||
|
// window-level capture is only meant for the USB caliper / keyboard
|
||||||
|
// wedge when no field is focused. Without this guard the numpad would
|
||||||
|
// swallow digits and Backspace inside those inputs.
|
||||||
|
const t = e.target;
|
||||||
|
if (t && (t.tagName === 'INPUT' || t.tagName === 'TEXTAREA' ||
|
||||||
|
t.tagName === 'SELECT' || t.isContentEditable)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Number keys
|
// Number keys
|
||||||
if (e.key >= '0' && e.key <= '9') {
|
if (e.key >= '0' && e.key <= '9') {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -116,14 +116,14 @@
|
|||||||
{# Fermo linea + Fine produzione (measurement tasks only) #}
|
{# Fermo linea + Fine produzione (measurement tasks only) #}
|
||||||
<template x-if="subtasks.length > 0">
|
<template x-if="subtasks.length > 0">
|
||||||
<div class="shrink-0 flex items-center gap-1.5">
|
<div class="shrink-0 flex items-center gap-1.5">
|
||||||
<button @click="showSupervisorModal = true; supervisorAction = 'fermo_linea'"
|
<button @click="openSupervisorModal('fermo_linea')"
|
||||||
class="btn text-xs py-1 px-2.5 gap-1 border-2 border-amber-500 text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/20 hover:bg-amber-100 dark:hover:bg-amber-900/40">
|
class="btn text-xs py-1 px-2.5 gap-1 border-2 border-amber-500 text-amber-700 dark:text-amber-300 bg-amber-50 dark:bg-amber-900/20 hover:bg-amber-100 dark:hover:bg-amber-900/40">
|
||||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
<path stroke-linecap="round" stroke-linejoin="round" d="M10 9v6m4-6v6m7-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||||
</svg>
|
</svg>
|
||||||
{{ _('Fermo linea') }}
|
{{ _('Fermo linea') }}
|
||||||
</button>
|
</button>
|
||||||
<button @click="showSupervisorModal = true; supervisorAction = 'fine_produzione'"
|
<button @click="openSupervisorModal('fine_produzione')"
|
||||||
class="btn text-xs py-1 px-2.5 gap-1 border-2 border-red-500 text-red-700 dark:text-red-300 bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/40">
|
class="btn text-xs py-1 px-2.5 gap-1 border-2 border-red-500 text-red-700 dark:text-red-300 bg-red-50 dark:bg-red-900/20 hover:bg-red-100 dark:hover:bg-red-900/40">
|
||||||
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24">
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
<path stroke-linecap="round" stroke-linejoin="round" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||||
@@ -607,7 +607,7 @@
|
|||||||
x-transition:leave-end="opacity-0"
|
x-transition:leave-end="opacity-0"
|
||||||
x-cloak
|
x-cloak
|
||||||
class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 backdrop-blur-sm"
|
class="fixed inset-0 z-[60] flex items-center justify-center bg-black/50 backdrop-blur-sm"
|
||||||
@click.self="showSupervisorModal = false">
|
@click.self="closeSupervisorModal()">
|
||||||
<div class="bg-[var(--bg-card)] rounded-2xl shadow-2xl p-6 max-w-sm mx-4 w-full border border-[var(--border-color)]">
|
<div class="bg-[var(--bg-card)] rounded-2xl shadow-2xl p-6 max-w-sm mx-4 w-full border border-[var(--border-color)]">
|
||||||
<div class="flex items-center gap-3 mb-4">
|
<div class="flex items-center gap-3 mb-4">
|
||||||
<div class="w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center">
|
<div class="w-10 h-10 rounded-full bg-amber-100 dark:bg-amber-900/30 flex items-center justify-center">
|
||||||
@@ -636,7 +636,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<button @click="showSupervisorModal = false; supervisorUsername = ''; supervisorPassword = ''; supervisorError = ''"
|
<button @click="closeSupervisorModal()"
|
||||||
class="btn btn-secondary flex-1 text-sm">
|
class="btn btn-secondary flex-1 text-sm">
|
||||||
{{ _('Annulla') }}
|
{{ _('Annulla') }}
|
||||||
</button>
|
</button>
|
||||||
@@ -858,8 +858,7 @@ function taskExecute() {
|
|||||||
// Out-of-tolerance: block advancement, require supervisor
|
// Out-of-tolerance: block advancement, require supervisor
|
||||||
if (pf === 'fail') {
|
if (pf === 'fail') {
|
||||||
this.pendingAdvance = true;
|
this.pendingAdvance = true;
|
||||||
this.supervisorAction = 'out_of_tolerance';
|
this.openSupervisorModal('out_of_tolerance');
|
||||||
this.showSupervisorModal = true;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -998,6 +997,22 @@ function taskExecute() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ---- Open/close supervisor modal (always reset fields) ----
|
||||||
|
openSupervisorModal(action) {
|
||||||
|
this.supervisorAction = action;
|
||||||
|
this.supervisorUsername = '';
|
||||||
|
this.supervisorPassword = '';
|
||||||
|
this.supervisorError = '';
|
||||||
|
this.showSupervisorModal = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
closeSupervisorModal() {
|
||||||
|
this.showSupervisorModal = false;
|
||||||
|
this.supervisorUsername = '';
|
||||||
|
this.supervisorPassword = '';
|
||||||
|
this.supervisorError = '';
|
||||||
|
},
|
||||||
|
|
||||||
// ---- Supervisor reason text ----
|
// ---- Supervisor reason text ----
|
||||||
get supervisorReason() {
|
get supervisorReason() {
|
||||||
if (this.supervisorAction === 'out_of_tolerance') return '{{ _("Misurazione fuori tolleranza") }}';
|
if (this.supervisorAction === 'out_of_tolerance') return '{{ _("Misurazione fuori tolleranza") }}';
|
||||||
|
|||||||
Reference in New Issue
Block a user