Merge pull request 'ranjith-dev' (#263) 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: #263
This commit was merged in pull request #263.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\CharacteristicApproverMasterExporter;
|
||||
use App\Filament\Resources\CharacteristicApproverMasterResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Machine;
|
||||
@@ -11,6 +12,8 @@ use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
@@ -34,10 +37,13 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->columnSpan(2)
|
||||
->reactive()
|
||||
->relationship('plant', 'name')
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->plant_id;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\Select::make('machine_id')
|
||||
->label('Work Center')
|
||||
->columnSpan(2)
|
||||
@@ -52,19 +58,28 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
|
||||
return Machine::where('plant_id', $plantId)->pluck('work_center', 'id');
|
||||
})
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->machine_id ?? [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required(),
|
||||
}),
|
||||
Forms\Components\TextInput::make('characteristic_field')
|
||||
->label('Characteristic Field')
|
||||
->label('Master Characteristic Field')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->default('NIL')
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
Forms\Components\TextInput::make('machine_name')
|
||||
->label('Machine')
|
||||
->columnSpan(2)
|
||||
->required()
|
||||
->default(function () {
|
||||
return optional(CharacteristicApproverMaster::latest()->first())->machine_name ?? '';
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
}),
|
||||
@@ -173,7 +188,7 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristic_field')
|
||||
->label('Characteristic Field')
|
||||
->label('Master Characteristic Field')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state): string => strtoupper(__($state)))
|
||||
@@ -271,6 +286,22 @@ class CharacteristicApproverMasterResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->color('warning')
|
||||
// ->importer(CharacteristicApproverMasterImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import characteristic approver master');
|
||||
// }),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->color('warning')
|
||||
->exporter(CharacteristicApproverMasterExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export characteristic approver master');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Exports\RequestCharacteristicExporter;
|
||||
use App\Filament\Resources\RequestCharacteristicResource\Pages;
|
||||
use App\Models\CharacteristicApproverMaster;
|
||||
use App\Models\Item;
|
||||
@@ -15,6 +16,8 @@ use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
@@ -140,6 +143,9 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('aufnr', null);
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->item_id ?? [];
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('aufnr')
|
||||
->label('Aufnr')
|
||||
@@ -148,6 +154,9 @@ class RequestCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->aufnr ?? '';
|
||||
})
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\Select::make('machine_name')
|
||||
->label('Machines')
|
||||
@@ -162,14 +171,29 @@ class RequestCharacteristicResource extends Resource
|
||||
return [];
|
||||
}
|
||||
|
||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'id')->unique();
|
||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->pluck('machine_name', 'machine_name')->unique();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('characteristic_approver_master_id', null);
|
||||
// dd($get('characteristic_approver_master_id'));
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
||||
$machineName = '';
|
||||
$reqId = RequestCharacteristic::latest()->first()?->characteristic_approver_master_id;
|
||||
if ($reqId) {
|
||||
$reqMac = CharacteristicApproverMaster::where('id', $reqId)->first()?->machine_name;
|
||||
if ($reqMac) {
|
||||
$machineName = $reqMac;
|
||||
} else {
|
||||
$machineName = null;
|
||||
}
|
||||
} else {
|
||||
$machineName = null;
|
||||
}
|
||||
|
||||
// return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
||||
return $machineName ?? [];
|
||||
})
|
||||
->afterStateHydrated(function ($component, $state, Get $get, Set $set) {
|
||||
if ($get('id')) {
|
||||
@@ -188,8 +212,8 @@ class RequestCharacteristicResource extends Resource
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('characteristic_approver_master_id')
|
||||
->label('Master Characteristic')
|
||||
->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||
->label('Master Characteristic Field')
|
||||
// ->relationship('characteristicApproverMaster', 'characteristic_field')
|
||||
->reactive()
|
||||
->nullable()
|
||||
->searchable()
|
||||
@@ -204,6 +228,9 @@ class RequestCharacteristicResource extends Resource
|
||||
|
||||
return CharacteristicApproverMaster::where('plant_id', $plantId)->where('machine_id', $machineId)->where('machine_name', $machineName)->pluck('characteristic_field', 'id');
|
||||
})
|
||||
->default(function () {
|
||||
return optional(RequestCharacteristic::latest()->first())->characteristic_approver_master_id ?? [];
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -219,6 +246,7 @@ class RequestCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->required()
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('current_value')
|
||||
->label('Current Value')
|
||||
@@ -250,6 +278,7 @@ class RequestCharacteristicResource extends Resource
|
||||
Forms\Components\Select::make('approver_status1')
|
||||
->label('Approver Status')
|
||||
->reactive()
|
||||
->live()
|
||||
->options([
|
||||
'Approved' => 'Approved',
|
||||
'Hold' => 'Hold',
|
||||
@@ -313,6 +342,7 @@ class RequestCharacteristicResource extends Resource
|
||||
default => 'Updated At',
|
||||
})
|
||||
->reactive()
|
||||
->live()
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -814,6 +844,22 @@ class RequestCharacteristicResource extends Resource
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
])
|
||||
->headerActions([
|
||||
// ImportAction::make()
|
||||
// ->label('Import Request Characteristics')
|
||||
// ->color('warning')
|
||||
// ->importer(RequestCharacteristicImporter::class)
|
||||
// ->visible(function () {
|
||||
// return Filament::auth()->user()->can('view import request characteristic');
|
||||
// }),
|
||||
ExportAction::make()
|
||||
->label('Export Request Characteristics')
|
||||
->color('warning')
|
||||
->exporter(RequestCharacteristicExporter::class)
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export request characteristic');
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user