Refactor UnpaidLeaveForm and UnpaidLeaveInfolist to improve layout and organization. Introduce sections in UnpaidLeaveInfolist for better categorization of information, enhance date picker functionality, and improve localization for various fields.
This commit is contained in:
@@ -13,8 +13,10 @@ class UnpaidLeaveForm
|
|||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
HrForm::employeeSelect(),
|
HrForm::employeeSelect(),
|
||||||
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date')),
|
HrForm::leaveDatePicker('start_date', __('hr.fields.start_date'))
|
||||||
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date')),
|
->native(false),
|
||||||
|
HrForm::leaveDatePicker('end_date', __('hr.fields.end_date'))
|
||||||
|
->native(false),
|
||||||
HrForm::leaveDaysDisplay(),
|
HrForm::leaveDaysDisplay(),
|
||||||
Textarea::make('reason')
|
Textarea::make('reason')
|
||||||
->label(__('hr.fields.reason'))
|
->label(__('hr.fields.reason'))
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Filament\Resources\UnpaidLeaves\Schemas;
|
namespace App\Filament\Resources\UnpaidLeaves\Schemas;
|
||||||
|
|
||||||
|
use App\Enums\ApprovalStatus;
|
||||||
use App\Models\UnpaidLeave;
|
use App\Models\UnpaidLeave;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
use Filament\Infolists\Components\TextEntry;
|
||||||
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
|
||||||
class UnpaidLeaveInfolist
|
class UnpaidLeaveInfolist
|
||||||
@@ -12,44 +16,61 @@ class UnpaidLeaveInfolist
|
|||||||
{
|
{
|
||||||
return $schema
|
return $schema
|
||||||
->components([
|
->components([
|
||||||
TextEntry::make('employee.id')
|
Section::make(__('hr.sections.basic_info'))
|
||||||
|
->schema([
|
||||||
|
TextEntry::make('employee.full_name')
|
||||||
->label(__('hr.fields.employee')),
|
->label(__('hr.fields.employee')),
|
||||||
TextEntry::make('start_date')
|
|
||||||
->label(__('hr.fields.start_date'))
|
|
||||||
->date(),
|
|
||||||
TextEntry::make('end_date')
|
|
||||||
->label(__('hr.fields.end_date'))
|
|
||||||
->date(),
|
|
||||||
TextEntry::make('days')
|
|
||||||
->label(__('hr.fields.days'))
|
|
||||||
->numeric(),
|
|
||||||
TextEntry::make('reason')
|
|
||||||
->label(__('hr.fields.reason'))
|
|
||||||
->placeholder('-')
|
|
||||||
->columnSpanFull(),
|
|
||||||
TextEntry::make('status')
|
TextEntry::make('status')
|
||||||
->label(__('hr.fields.status'))
|
->label(__('hr.fields.status'))
|
||||||
->badge(),
|
->badge()
|
||||||
|
->color(fn (ApprovalStatus $state): string => $state->color())
|
||||||
|
->formatStateUsing(fn (ApprovalStatus $state): string => $state->label()),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
|
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('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('approved_by')
|
TextEntry::make('approved_by')
|
||||||
->label(__('hr.fields.approved_by'))
|
->label(__('hr.fields.approved_by'))
|
||||||
->numeric()
|
->formatStateUsing(fn ($state, UnpaidLeave $record): string => $record->approver?->name ?? '—'),
|
||||||
->placeholder('-'),
|
])
|
||||||
|
->columns(2),
|
||||||
|
Section::make(__('hr.sections.metadata'))
|
||||||
|
->schema([
|
||||||
TextEntry::make('approved_at')
|
TextEntry::make('approved_at')
|
||||||
->label(__('hr.fields.approved_at'))
|
->label(__('hr.fields.approved_at'))
|
||||||
->dateTime()
|
->dateTime('d.m.Y H:i')
|
||||||
->placeholder('-'),
|
->placeholder('—'),
|
||||||
TextEntry::make('created_at')
|
TextEntry::make('created_at')
|
||||||
->label(__('hr.fields.created_at'))
|
->label(__('hr.fields.created_at'))
|
||||||
->dateTime()
|
->dateTime('d.m.Y H:i')
|
||||||
->placeholder('-'),
|
->placeholder('—'),
|
||||||
TextEntry::make('updated_at')
|
TextEntry::make('updated_at')
|
||||||
->label(__('hr.fields.updated_at'))
|
->label(__('hr.fields.updated_at'))
|
||||||
->dateTime()
|
->dateTime('d.m.Y H:i')
|
||||||
->placeholder('-'),
|
->placeholder('—'),
|
||||||
TextEntry::make('deleted_at')
|
TextEntry::make('deleted_at')
|
||||||
->label(__('hr.fields.deleted_at'))
|
->label(__('hr.fields.deleted_at'))
|
||||||
->dateTime()
|
->dateTime('d.m.Y H:i')
|
||||||
->visible(fn (UnpaidLeave $record): bool => $record->trashed()),
|
->visible(fn (UnpaidLeave $record): bool => $record->trashed()),
|
||||||
|
])
|
||||||
|
->columns(2),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user