Added logic in quality validation for sfg line enter prevent logic #1412

Merged
jothi merged 1 commits from ranjith-dev into master 2026-11-13 10:49:24 +00:00
Showing only changes of commit f000821240 - Show all commits

View File

@@ -223,7 +223,7 @@ class QualityValidationResource extends Resource
->required()
->autofocus()
->live()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) {
$pId = $get('line_id');
$set('part_validation_type', null);
@@ -533,6 +533,8 @@ class QualityValidationResource extends Resource
$serialAssigned = false;
$visibleSerialColumns = [];
foreach ($serialFields as $column) {
$colFld = $column;
@@ -548,6 +550,10 @@ class QualityValidationResource extends Resource
$set($column . '_visible', $count > 0);
if ($count > 0) {
$visibleSerialColumns[] = $column; // NEW
}
// assign serial only once
if (!$serialAssigned && $count > 0) {
@@ -608,11 +614,38 @@ class QualityValidationResource extends Resource
// Save options in hidden field
$set('part_validation_type_options', $options);
$visiblePartValidations = array_filter(
$partValidationColumns,
fn ($col) => ! empty($stickerMaster->$col)
);
if (
$visibleSerialColumns === ['serial_number_motor_qr']
&& (int) $stickerMaster->serial_number_motor === 1
&& empty($visiblePartValidations)
) {
$livewire->create();
$livewire->js("document.getElementById('item_id')?.focus()");
}
})
->extraAttributes(fn ($get) => [
'class' => $get('validationError') ? 'border-red-500' : '',
'id' => 'item_id',
'onkeydown' => "if (event.key === 'Enter') { event.preventDefault(); event.stopPropagation(); return false; }",
// 'onkeydown' => "
// if (event.key === 'Enter') {
// if (
// document.querySelector('[name=\"data[serial_number_motor_qr]\"]')?.value === '1'
// ) {
// this.closest('form').querySelector('button[wire\\\\:click*=\"create\"]')?.click();
// } else {
// event.preventDefault();
// event.stopPropagation();
// return false;
// }
// }
// ",
])
// ->extraAttributes(fn ($get) => [
// 'class' => $get('validationError') ? 'border-red-500' : '',