From 0b6ef45a4090c66a8fedef6afd082669aea12f2f Mon Sep 17 00:00:00 2001 From: Mekan1206 Date: Sun, 2 Aug 2026 21:38:50 +0500 Subject: [PATCH] Refactor VacationForm and VacationInfolist to enhance date picker functionality and improve localization. Introduce new sections in VacationInfolist for better organization of information, and add missing labels in multiple languages for improved user experience. --- .../Vacations/Schemas/VacationForm.php | 9 +- .../Vacations/Schemas/VacationInfolist.php | 121 +++++++++++------- lang/en/hr.php | 4 + lang/ru/hr.php | 4 + lang/tk/hr.php | 4 + 5 files changed, 91 insertions(+), 51 deletions(-) diff --git a/app/Filament/Resources/Vacations/Schemas/VacationForm.php b/app/Filament/Resources/Vacations/Schemas/VacationForm.php index 1e485c5..00602c0 100644 --- a/app/Filament/Resources/Vacations/Schemas/VacationForm.php +++ b/app/Filament/Resources/Vacations/Schemas/VacationForm.php @@ -21,10 +21,13 @@ class VacationForm ->options(VacationType::class) ->required() ->native(false), - HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')), - HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')), + HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')) + ->native(false), + HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')) + ->native(false), DatePicker::make('return_date') - ->label(__('hr.fields.return_date')), + ->label(__('hr.fields.return_date')) + ->native(false), HrForm::leaveDaysDisplay(), Textarea::make('reason') ->label(__('hr.fields.reason')) diff --git a/app/Filament/Resources/Vacations/Schemas/VacationInfolist.php b/app/Filament/Resources/Vacations/Schemas/VacationInfolist.php index a3d7826..3929df4 100644 --- a/app/Filament/Resources/Vacations/Schemas/VacationInfolist.php +++ b/app/Filament/Resources/Vacations/Schemas/VacationInfolist.php @@ -1,9 +1,15 @@ components([ - TextEntry::make('employee.id') - ->label(__('hr.fields.employee')), - TextEntry::make('type') - ->label(__('hr.fields.type')) - ->badge(), - TextEntry::make('start_date') - ->label(__('hr.fields.start_date')) - ->date(), - TextEntry::make('end_date') - ->label(__('hr.fields.end_date')) - ->date(), - TextEntry::make('return_date') - ->label(__('hr.fields.return_date')) - ->date() - ->placeholder('-'), - TextEntry::make('days') - ->label(__('hr.fields.days')) - ->numeric(), - TextEntry::make('status') - ->label(__('hr.fields.status')) - ->badge(), - TextEntry::make('reason') - ->label(__('hr.fields.reason')) - ->placeholder('-') - ->columnSpanFull(), - TextEntry::make('attachment_path') - ->label(__('hr.fields.attachment')) - ->placeholder('-'), - TextEntry::make('approved_by') - ->label(__('hr.fields.approved_by')) - ->numeric() - ->placeholder('-'), - TextEntry::make('approved_at') - ->label(__('hr.fields.approved_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('created_at') - ->label(__('hr.fields.created_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('updated_at') - ->label(__('hr.fields.updated_at')) - ->dateTime() - ->placeholder('-'), - TextEntry::make('deleted_at') - ->label(__('hr.fields.deleted_at')) - ->dateTime() - ->visible(fn (Vacation $record): bool => $record->trashed()), + Section::make(__('hr.sections.basic_info')) + ->schema([ + TextEntry::make('employee.full_name') + ->label(__('hr.fields.employee')), + TextEntry::make('type') + ->label(__('hr.fields.type')) + ->badge() + ->color(fn (VacationType $state): string => $state->color()) + ->formatStateUsing(fn (VacationType $state): string => $state->label()), + TextEntry::make('status') + ->label(__('hr.fields.status')) + ->badge() + ->color(fn (ApprovalStatus $state): string => $state->color()) + ->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()), + ]) + ->columns(3), + Section::make(__('hr.sections.dates')) + ->schema([ + TextEntry::make('start_date') + ->label(__('hr.fields.start_date')) + ->date('d.m.Y'), + TextEntry::make('end_date') + ->label(__('hr.fields.end_date')) + ->date('d.m.Y'), + TextEntry::make('return_date') + ->label(__('hr.fields.return_date')) + ->date('d.m.Y') + ->placeholder('—'), + TextEntry::make('days') + ->label(__('hr.fields.days')) + ->suffix(' '.__('hr.messages.days_suffix')), + ]) + ->columns(2), + Section::make(__('hr.sections.approval')) + ->schema([ + TextEntry::make('reason') + ->label(__('hr.fields.reason')) + ->placeholder('—') + ->columnSpanFull(), + TextEntry::make('attachment_path') + ->label(__('hr.fields.attachment')) + ->formatStateUsing(fn (?string $state): string => filled($state) ? basename($state) : '—'), + TextEntry::make('approved_by') + ->label(__('hr.fields.approved_by')) + ->formatStateUsing(fn ($state, Vacation $record): string => $record->approver?->name ?? '—'), + ]) + ->columns(2), + Section::make(__('hr.sections.metadata')) + ->schema([ + TextEntry::make('approved_at') + ->label(__('hr.fields.approved_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('created_at') + ->label(__('hr.fields.created_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('updated_at') + ->label(__('hr.fields.updated_at')) + ->dateTime('d.m.Y H:i') + ->placeholder('—'), + TextEntry::make('deleted_at') + ->label(__('hr.fields.deleted_at')) + ->dateTime('d.m.Y H:i') + ->visible(fn (Vacation $record): bool => $record->trashed()), + ]) + ->columns(2), ]); } } diff --git a/lang/en/hr.php b/lang/en/hr.php index 96d4cc6..6a9922b 100644 --- a/lang/en/hr.php +++ b/lang/en/hr.php @@ -156,6 +156,10 @@ return [ 'upcoming_approved_leave' => 'Upcoming Approved Leave', 'other_leave_types' => 'Other Leave Types', 'activity_details' => 'Activity Details', + 'basic_info' => 'Basic Information', + 'dates' => 'Dates', + 'approval' => 'Approval', + 'metadata' => 'Metadata', ], 'messages' => [ diff --git a/lang/ru/hr.php b/lang/ru/hr.php index d5e642e..85365b8 100644 --- a/lang/ru/hr.php +++ b/lang/ru/hr.php @@ -156,6 +156,10 @@ return [ 'upcoming_approved_leave' => 'Предстоящий одобренный отпуск', 'other_leave_types' => 'Другие типы отпусков', 'activity_details' => 'Детали активности', + 'basic_info' => 'Основная информация', + 'dates' => 'Даты', + 'approval' => 'Утверждение', + 'metadata' => 'Метаданные', ], 'messages' => [ diff --git a/lang/tk/hr.php b/lang/tk/hr.php index f2d6030..6ad21a0 100644 --- a/lang/tk/hr.php +++ b/lang/tk/hr.php @@ -156,6 +156,10 @@ return [ 'upcoming_approved_leave' => 'Ýakynlaşýan tassyklanan dynç alyş', 'other_leave_types' => 'Beýleki rugsat görnüşleri', 'activity_details' => 'Işjeňlik jikme-jiklikleri', + 'basic_info' => 'Esasy maglumat', + 'dates' => 'Seneler', + 'approval' => 'Tassyklama', + 'metadata' => 'Maglumat', ], 'messages' => [