From 110b8b2e927985eb3d47ab97a7bd9f4cb965b415 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 8 Oct 2026 09:59:45 +0530 Subject: [PATCH] Refactored form design, validation and Added items - description, category, uom in resource files --- .../RequestCharacteristicResource.php | 21 +++++++++ .../TempClassCharacteristicResource.php | 21 +++++++++ .../TempStopCharacteristicResource.php | 44 ++++++++++++++----- .../WindedSerialValidationErrorResource.php | 24 ++++++---- 4 files changed, 91 insertions(+), 19 deletions(-) diff --git a/app/Filament/Resources/RequestCharacteristicResource.php b/app/Filament/Resources/RequestCharacteristicResource.php index 8eb837e3..9533443b 100644 --- a/app/Filament/Resources/RequestCharacteristicResource.php +++ b/app/Filament/Resources/RequestCharacteristicResource.php @@ -1049,6 +1049,27 @@ class RequestCharacteristicResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('item.description') + ->label('Description') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.category') + ->label('Category') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.uom') + ->label('Unit of Measure') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('aufnr') ->label('Job Number') ->alignCenter() diff --git a/app/Filament/Resources/TempClassCharacteristicResource.php b/app/Filament/Resources/TempClassCharacteristicResource.php index f57b9df9..a79b3677 100644 --- a/app/Filament/Resources/TempClassCharacteristicResource.php +++ b/app/Filament/Resources/TempClassCharacteristicResource.php @@ -1183,6 +1183,27 @@ class TempClassCharacteristicResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('item.description') + ->label('DESCRIPTION') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.category') + ->label('CATEGORY') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.uom') + ->label('UNIT OF MEASURE') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('model_type') ->label('MODEL TYPE') ->alignCenter() diff --git a/app/Filament/Resources/TempStopCharacteristicResource.php b/app/Filament/Resources/TempStopCharacteristicResource.php index 896da557..b2bc7070 100644 --- a/app/Filament/Resources/TempStopCharacteristicResource.php +++ b/app/Filament/Resources/TempStopCharacteristicResource.php @@ -128,7 +128,7 @@ class TempStopCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }) ->required() - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('aufnr') ->label('Job Number') ->reactive() @@ -152,18 +152,16 @@ class TempStopCharacteristicResource extends Resource return ($userHas && strlen($userHas) > 0) ? null : optional(TempStopCharacteristic::latest()->first())->aufnr ?? null; }) - ->readOnly(fn ($get) => ($get('item_id') == null)) - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id')) || ! $get('item_id')), Forms\Components\TextInput::make('gernr') ->label('Serial Number') ->reactive() ->minLength(13) - ->readOnly(fn (callable $get) => ! $get('aufnr')) ->afterStateUpdated(function ($state, callable $set, callable $get) { $set('updated_by', Filament::auth()->user()?->name); }) ->required() - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id')) || ! $get('aufnr')), Forms\Components\TextInput::make('zmm_heading') ->label('Zmm Heading') ->reactive() @@ -172,7 +170,7 @@ class TempStopCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }) ->required() - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\Select::make('model_type') ->label('Model Type') ->reactive() @@ -200,7 +198,7 @@ class TempStopCharacteristicResource extends Resource $set('updated_by', Filament::auth()->user()?->name); }) ->required() - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('samlight_logged_name') ->label('SAMLight Logged Name') ->reactive() @@ -208,7 +206,7 @@ class TempStopCharacteristicResource extends Resource ->afterStateUpdated(function ($state, callable $set, callable $get) { $set('updated_by', Filament::auth()->user()?->name); }) - ->disabled(fn (Get $get) => ! empty($get('id'))), + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\DateTimePicker::make('stopped_at') ->label('Stopped At') ->default(now()) @@ -216,7 +214,8 @@ class TempStopCharacteristicResource extends Resource ->afterStateUpdated(function ($state, callable $set, callable $get) { $set('updated_by', Filament::auth()->user()?->name); }) - ->required(), + ->required() + ->disabled(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('stopped_by') ->label('Stopped By') ->reactive() @@ -224,7 +223,8 @@ class TempStopCharacteristicResource extends Resource ->afterStateUpdated(function ($state, callable $set, callable $get) { $set('updated_by', Filament::auth()->user()?->name); }) - ->required(), + ->required() + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\TextInput::make('has_stop_flow_id') ->label('Has Stop Flow ID') ->reactive() @@ -236,7 +236,8 @@ class TempStopCharacteristicResource extends Resource } $set('updated_by', Filament::auth()->user()?->name); }) - ->required(), + ->required() + ->readonly(fn (Get $get) => ! empty($get('id'))), Forms\Components\Hidden::make('created_by') ->label('Created By') ->default(Filament::auth()->user()?->name), @@ -284,6 +285,27 @@ class TempStopCharacteristicResource extends Resource ->alignCenter() ->searchable() ->sortable(), + Tables\Columns\TextColumn::make('item.description') + ->label('Description') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.category') + ->label('Category') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), + Tables\Columns\TextColumn::make('item.uom') + ->label('Unit of Measure') + ->default('-') + ->searchable() + ->alignCenter() + ->sortable() + ->toggleable(isToggledHiddenByDefault: true), Tables\Columns\TextColumn::make('aufnr') ->label('Job Number') ->alignCenter() diff --git a/app/Filament/Resources/WindedSerialValidationErrorResource.php b/app/Filament/Resources/WindedSerialValidationErrorResource.php index cc8ab431..7ab06165 100644 --- a/app/Filament/Resources/WindedSerialValidationErrorResource.php +++ b/app/Filament/Resources/WindedSerialValidationErrorResource.php @@ -141,7 +141,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('aufnr') ->label('AUFNR') ->placeholder('Scan the AUFNR') @@ -150,7 +151,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('gernr') ->label('GERNR') ->placeholder('Scan the GERNR') @@ -159,7 +161,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('model_type') ->label('Model Type') ->placeholder('Scan the Model Type') @@ -168,7 +171,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('winded_qr') ->label('Winded QR') ->placeholder('Scan the Winded QR') @@ -176,7 +180,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('winded_code') ->label('Winded Code') ->placeholder('Scan the Winded Code') @@ -184,7 +189,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('winded_serial_number') ->label('Winded Serial Number') ->placeholder('Scan the Winded Serial Number') @@ -192,7 +198,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('winded_status') ->label('Winded Status') ->placeholder('Scan the Winded Status') @@ -201,7 +208,8 @@ class WindedSerialValidationErrorResource extends Resource ->reactive() ->afterStateUpdated(function ($state, callable $set) { $set('updated_by', Filament::auth()->user()?->name); - }), + }) + ->readOnly(fn (Get $get) => $get('id')), Forms\Components\TextInput::make('created_by') ->default(fn () => Filament::auth()->user()?->name) ->readOnly()