Updated plant load / choose logic and part_validation allow logic #321

Merged
jothi merged 1 commits from ranjith-dev into master 2026-02-06 13:05:32 +00:00

View File

@@ -61,34 +61,36 @@ class StickerMasterResource extends Resource
return optional(StickerMaster::latest()->first())->plant_id; return optional(StickerMaster::latest()->first())->plant_id;
}) })
->disabled(fn (Get $get) => ! empty($get('id'))) // disable in edit if user try to change ->disabled(fn (Get $get) => ! empty($get('id'))) // disable in edit if user try to change
->afterStateUpdated(fn (callable $set) => $set('item_id', null) & // when plant changed remove all the data which is in text input box ->afterStateUpdated(function ($state, callable $set) {
$set('item_description', null) & $set('item_id', null);
$set('item_error', null) & $set('item_description', null);
$set('panel_box_code', null) & $set('item_error', null);
$set('load_rate', null) & $set('panel_box_code', null);
$set('bundle_quantity', null) & $set('load_rate', null);
$set('material_type', null) & $set('bundle_quantity', null);
$set('part_validation1', null) & $set('material_type', null);
$set('part_validation2', null) & $set('part_validation1', null);
$set('part_validation3', null) & $set('part_validation2', null);
$set('part_validation4', null) & $set('part_validation3', null);
$set('part_validation5', null) & $set('part_validation4', null);
$set('laser_part_validation1', null) & $set('part_validation5', null);
$set('laser_part_validation2', null) & $set('laser_part_validation1', null);
$set('serial_number_motor', false) & $set('laser_part_validation2', null);
$set('serial_number_pump', false) & $set('serial_number_motor', false);
$set('serial_number_pumpset', false) & $set('serial_number_pump', false);
$set('pack_slip_motor', false) & $set('serial_number_pumpset', false);
$set('pack_slip_pump', false) & $set('pack_slip_motor', false);
$set('pack_slip_pumpset', false) & $set('pack_slip_pump', false);
$set('name_plate_motor', false) & $set('pack_slip_pumpset', false);
$set('name_plate_pump', false) & $set('name_plate_motor', false);
$set('name_plate_pumpset', false) & $set('name_plate_pump', false);
$set('tube_sticker_motor', false) & $set('name_plate_pumpset', false);
$set('tube_sticker_pump', false) & $set('tube_sticker_motor', false);
$set('tube_sticker_pumpset', false) & $set('tube_sticker_pump', false);
$set('warranty_card', false) // & $set('updated_by', Filament::auth()->user()?->name) $set('tube_sticker_pumpset', false);
) $set('warranty_card', false);
$set('updated_by', Filament::auth()->user()?->name);
})
->required(), ->required(),
Forms\Components\Select::make('item_id') Forms\Components\Select::make('item_id')
@@ -209,6 +211,7 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation1') Forms\Components\TextInput::make('part_validation1')
->label('Part Validation 1') ->label('Part Validation 1')
->nullable() ->nullable()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -216,6 +219,8 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation2') Forms\Components\TextInput::make('part_validation2')
->label('Part Validation 2') ->label('Part Validation 2')
->nullable() ->nullable()
->reactive()
->disabled(fn (Get $get) => empty($get('part_validation1')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -223,6 +228,8 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation3') Forms\Components\TextInput::make('part_validation3')
->label('Part Validation 3') ->label('Part Validation 3')
->nullable() ->nullable()
->reactive()
->disabled(fn (Get $get) => empty($get('part_validation2')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -230,6 +237,8 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation4') Forms\Components\TextInput::make('part_validation4')
->label('Part Validation 4') ->label('Part Validation 4')
->nullable() ->nullable()
->reactive()
->disabled(fn (Get $get) => empty($get('part_validation3')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -237,6 +246,8 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('part_validation5') Forms\Components\TextInput::make('part_validation5')
->label('Part Validation 5 (Capacitor QR)') ->label('Part Validation 5 (Capacitor QR)')
->nullable() ->nullable()
->reactive()
->disabled(fn (Get $get) => empty($get('part_validation4')) && empty($get('panel_box_code')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -244,6 +255,7 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('laser_part_validation1') Forms\Components\TextInput::make('laser_part_validation1')
->label('Laser Part Validation 1') ->label('Laser Part Validation 1')
->nullable() ->nullable()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -251,6 +263,8 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('laser_part_validation2') Forms\Components\TextInput::make('laser_part_validation2')
->label('Laser Part Validation 2') ->label('Laser Part Validation 2')
->nullable() ->nullable()
->reactive()
->disabled(fn (Get $get) => empty($get('laser_part_validation1')))
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -259,6 +273,7 @@ class StickerMasterResource extends Resource
->label('Panel Box Code') ->label('Panel Box Code')
->readOnly(fn (callable $get) => $get('material_type')) ->readOnly(fn (callable $get) => $get('material_type'))
->nullable() ->nullable()
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) { ->afterStateUpdated(function ($state, callable $set, callable $get) {
$set('updated_by', Filament::auth()->user()?->name); $set('updated_by', Filament::auth()->user()?->name);
}), }),
@@ -266,6 +281,7 @@ class StickerMasterResource extends Resource
Forms\Components\TextInput::make('load_rate') Forms\Components\TextInput::make('load_rate')
->label('Load Rate') ->label('Load Rate')
->default(0) ->default(0)
->reactive()
->required() ->required()
->disabled(function ($get) { ->disabled(function ($get) {
return $get('material_type'); return $get('material_type');