Merge pull request 'Added logic in quality validation for sfg line enter prevent logic' (#1412) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 26s

Reviewed-on: #1412
This commit was merged in pull request #1412.
This commit is contained in:
2026-11-13 10:49:23 +00:00

View File

@@ -223,7 +223,7 @@ class QualityValidationResource extends Resource
->required() ->required()
->autofocus() ->autofocus()
->live() ->live()
->afterStateUpdated(function (callable $set, callable $get, ?string $state) { ->afterStateUpdated(function (callable $set, callable $get, ?string $state, $livewire) {
$pId = $get('line_id'); $pId = $get('line_id');
$set('part_validation_type', null); $set('part_validation_type', null);
@@ -533,6 +533,8 @@ class QualityValidationResource extends Resource
$serialAssigned = false; $serialAssigned = false;
$visibleSerialColumns = [];
foreach ($serialFields as $column) { foreach ($serialFields as $column) {
$colFld = $column; $colFld = $column;
@@ -548,6 +550,10 @@ class QualityValidationResource extends Resource
$set($column . '_visible', $count > 0); $set($column . '_visible', $count > 0);
if ($count > 0) {
$visibleSerialColumns[] = $column; // NEW
}
// assign serial only once // assign serial only once
if (!$serialAssigned && $count > 0) { if (!$serialAssigned && $count > 0) {
@@ -608,11 +614,38 @@ class QualityValidationResource extends Resource
// Save options in hidden field // Save options in hidden field
$set('part_validation_type_options', $options); $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) => [ ->extraAttributes(fn ($get) => [
'class' => $get('validationError') ? 'border-red-500' : '', 'class' => $get('validationError') ? 'border-red-500' : '',
'id' => 'item_id', 'id' => 'item_id',
'onkeydown' => "if (event.key === 'Enter') { event.preventDefault(); event.stopPropagation(); return false; }", '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) => [ // ->extraAttributes(fn ($get) => [
// 'class' => $get('validationError') ? 'border-red-500' : '', // 'class' => $get('validationError') ? 'border-red-500' : '',