Added focus to production order and qr input in production quantity page #438

Merged
jothi merged 1 commits from ranjith-dev into master 2026-03-05 09:32:59 +00:00
2 changed files with 14 additions and 6 deletions

View File

@@ -352,7 +352,8 @@ class ProductionQuantityPage extends Page implements HasForms
} }
}) })
->extraAttributes(fn ($get) => [ ->extraAttributes(fn ($get) => [
'id' => 'scan_locator_no', 'id' => 'production_order',
'wire:keydown.enter' => '$dispatch("focus-qr-input")',
'class' => $get('productionError') ? 'border-red-500' : '', 'class' => $get('productionError') ? 'border-red-500' : '',
]) ])
->hint(fn ($get) => $get('productionError') ? $get('productionError') : null) ->hint(fn ($get) => $get('productionError') ? $get('productionError') : null)
@@ -508,12 +509,11 @@ class ProductionQuantityPage extends Page implements HasForms
// 'operator_id'=> $operatorName, // 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr, 'recent_qr' => $this->recQr,
]); ]);
$this->dispatch('focus-production-order');
$this->triggerChartUpdate(); $this->triggerChartUpdate();
} }
} }
// Method to process the value when Enter is pressed
#[On('handleQrScan')] #[On('handleQrScan')]
public function handleQrScan($value) public function handleQrScan($value)
{ {
@@ -571,7 +571,6 @@ class ProductionQuantityPage extends Page implements HasForms
->body('Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )') ->body('Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )')
->danger() ->danger()
->send(); ->send();
return; return;
} else { } else {
if (! $this->pId) { if (! $this->pId) {

View File

@@ -87,6 +87,15 @@
} }
}); });
window.addEventListener('focus-qr-input', () => {
const input = document.getElementById('qr-scan-input');
if (input) {
input.focus();
input.select();
}
});
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const scanInput = document.getElementById('qr-scan-input'); const scanInput = document.getElementById('qr-scan-input');
if (!scanInput) return; if (!scanInput) return;
@@ -97,10 +106,10 @@
const value = scanInput.value.trim(); const value = scanInput.value.trim();
if (value !== '') { // if (value != '') {
Livewire.dispatch('handleQrScan', { value: value }); Livewire.dispatch('handleQrScan', { value: value });
scanInput.value = ''; scanInput.value = '';
} // }
} }
}); });