Merge pull request 'Updated default plant load logic and auto focus enabled for invoice number' (#311) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #311
This commit was merged in pull request #311.
This commit is contained in:
@@ -70,7 +70,10 @@ class InvoiceValidationResource extends Resource
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->default(function () {
|
||||
return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? $userHas : optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
// return optional(InvoiceValidation::latest()->first())->plant_id;
|
||||
})
|
||||
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||
// ->afterStateUpdated(fn ($set) => $set('block_id', null) & $set('name', null) & $set('start_time', null) & $set('duration', null) & $set('end_time', null))
|
||||
@@ -118,8 +121,19 @@ class InvoiceValidationResource extends Resource
|
||||
// ->afterStateHydrated(function (TextInput $component, string $state) {
|
||||
// $component->state(ucwords($state));
|
||||
// })
|
||||
->autofocus(function ($state, callable $set, callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
$sNo = $get('serial_number');
|
||||
if (! $plantId || $sNo) {
|
||||
return false;
|
||||
} elseif ($plantId && ! $sNo) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$invNo = $get('invoice_number');
|
||||
// $invNo = $get('invoice_number');
|
||||
$set('serial_number', null);
|
||||
$set('update_invoice', null);
|
||||
// Session::put('invoice_number', $state);
|
||||
|
||||
Reference in New Issue
Block a user