diff --git a/app/Filament/Resources/MotorTestingMasterResource.php b/app/Filament/Resources/MotorTestingMasterResource.php index 5088cf7..93274d8 100644 --- a/app/Filament/Resources/MotorTestingMasterResource.php +++ b/app/Filament/Resources/MotorTestingMasterResource.php @@ -28,9 +28,9 @@ class MotorTestingMasterResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack'; - protected static ?string $navigationGroup = 'Master Entries'; + protected static ?string $navigationGroup = 'Testing Panel'; - protected static ?int $navigationSort = 12; + protected static ?int $navigationSort = 1; public static function form(Form $form): Form { @@ -61,6 +61,11 @@ class MotorTestingMasterResource extends Resource ]) ->hint(fn ($get) => $get('mTmError') ? $get('mTmError') : null) ->hintColor('danger'), + Forms\Components\TimePicker::make('routine_test_time') + ->label('Routine Test Time') + ->default('00:40:00') + ->required() + ->reactive(), Forms\Components\Select::make('item_id') ->label('Item Code') //->relationship('item', 'name') @@ -82,11 +87,40 @@ class MotorTestingMasterResource extends Resource ->where('plant_id', $get('plant_id')) ->ignore($get('id')); // Ignore current record during updates }), - Forms\Components\TimePicker::make('routine_test_time') - ->label('Routine Test Time') - ->default('00:40:00') + Forms\Components\TextInput::make('subassembly_code') + ->label('Subassembly Code') ->required() - ->reactive(), + ->placeholder('Scan the valid code') + ->reactive() + ->alphaNum() + ->minLength(6) + ->afterStateUpdated(function ($state, callable $set, callable $get) { + $code = $get('subassembly_code'); + // Ensure `linestop_id` is not cleared + if (!$code) { + $set('iCodeError', 'Scan the valid Subassembly Code.'); + return; + } + else + { + if (strlen($code) < 6) { + $set('iCodeError', 'Subassembly code must be at least 6 digits.'); + return; + } + else if (!preg_match('/^[a-zA-Z0-9]{6,}$/', $code)) { + $set('code',null); + $set('iCodeError', 'Subassembly code must contain only alpha-numeric characters.'); + return; + } + $set('iCodeError', null); + } + }) + ->extraAttributes(fn ($get) => [ + 'class' => $get('iCodeError') ? 'border-red-500' : '', + ]) + ->hint(fn ($get) => $get('iCodeError') ? $get('iCodeError') : null) + ->hintColor('danger'), + Forms\Components\Select::make('isi_model') ->label('ISI Model') ->options([ @@ -296,6 +330,11 @@ class MotorTestingMasterResource extends Resource ->searchable() ->alignCenter() ->sortable(), + Tables\Columns\TextColumn::make('subassembly_code') + ->label('SubAssembly Code') + ->searchable() + ->alignCenter() + ->sortable(), Tables\Columns\TextColumn::make('item.description') ->label('Model') ->alignCenter()