Implement HasLabel interface in multiple enum classes, refactor label methods to improve localization consistency, and update default phone configuration in HR settings. Enhance employee form with phone number formatting and localization tests for enum options.
This commit is contained in:
@@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum ApprovalStatus: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum ApprovalStatus: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Pending = 'pending';
|
case Pending = 'pending';
|
||||||
case Approved = 'approved';
|
case Approved = 'approved';
|
||||||
case Rejected = 'rejected';
|
case Rejected = 'rejected';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Pending => __('enums.approval_status.pending'),
|
self::Pending => __('enums.approval_status.pending'),
|
||||||
@@ -19,6 +21,11 @@ enum ApprovalStatus: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum BonusType: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum BonusType: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Performance = 'performance';
|
case Performance = 'performance';
|
||||||
case Holiday = 'holiday';
|
case Holiday = 'holiday';
|
||||||
case Retention = 'retention';
|
case Retention = 'retention';
|
||||||
case Other = 'other';
|
case Other = 'other';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Performance => __('enums.bonus_type.performance'),
|
self::Performance => __('enums.bonus_type.performance'),
|
||||||
@@ -21,6 +23,11 @@ enum BonusType: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum DisciplinarySeverity: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum DisciplinarySeverity: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Low = 'low';
|
case Low = 'low';
|
||||||
case Medium = 'medium';
|
case Medium = 'medium';
|
||||||
case High = 'high';
|
case High = 'high';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Low => __('enums.disciplinary_severity.low'),
|
self::Low => __('enums.disciplinary_severity.low'),
|
||||||
@@ -19,6 +21,11 @@ enum DisciplinarySeverity: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum DocumentType: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum DocumentType: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Passport = 'passport';
|
case Passport = 'passport';
|
||||||
case Contract = 'contract';
|
case Contract = 'contract';
|
||||||
@@ -12,7 +14,7 @@ enum DocumentType: string
|
|||||||
case EducationCertificate = 'education_certificate';
|
case EducationCertificate = 'education_certificate';
|
||||||
case Other = 'other';
|
case Other = 'other';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Passport => __('enums.document_type.passport'),
|
self::Passport => __('enums.document_type.passport'),
|
||||||
@@ -23,6 +25,11 @@ enum DocumentType: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum EmploymentStatus: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum EmploymentStatus: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Active = 'active';
|
case Active = 'active';
|
||||||
case Inactive = 'inactive';
|
case Inactive = 'inactive';
|
||||||
case Terminated = 'terminated';
|
case Terminated = 'terminated';
|
||||||
case OnLeave = 'on_leave';
|
case OnLeave = 'on_leave';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Active => __('enums.employment_status.active'),
|
self::Active => __('enums.employment_status.active'),
|
||||||
@@ -21,6 +23,11 @@ enum EmploymentStatus: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,13 +4,15 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum Gender: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum Gender: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Male = 'male';
|
case Male = 'male';
|
||||||
case Female = 'female';
|
case Female = 'female';
|
||||||
// case Other = 'other';
|
// case Other = 'other';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Male => __('enums.gender.male'),
|
self::Male => __('enums.gender.male'),
|
||||||
@@ -19,6 +21,11 @@ enum Gender: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum ImportType: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum ImportType: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Employees = 'employees';
|
case Employees = 'employees';
|
||||||
case Vacations = 'vacations';
|
case Vacations = 'vacations';
|
||||||
case Bonuses = 'bonuses';
|
case Bonuses = 'bonuses';
|
||||||
case Reports = 'reports';
|
case Reports = 'reports';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Employees => __('enums.import_type.employees'),
|
self::Employees => __('enums.import_type.employees'),
|
||||||
@@ -21,6 +23,11 @@ enum ImportType: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,14 +4,16 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace App\Enums;
|
namespace App\Enums;
|
||||||
|
|
||||||
enum VacationType: string
|
use Filament\Support\Contracts\HasLabel;
|
||||||
|
|
||||||
|
enum VacationType: string implements HasLabel
|
||||||
{
|
{
|
||||||
case Annual = 'annual';
|
case Annual = 'annual';
|
||||||
case Marriage = 'marriage';
|
case Marriage = 'marriage';
|
||||||
case Study = 'study';
|
case Study = 'study';
|
||||||
case Other = 'other';
|
case Other = 'other';
|
||||||
|
|
||||||
public function label(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
self::Annual => __('enums.vacation_type.annual'),
|
self::Annual => __('enums.vacation_type.annual'),
|
||||||
@@ -21,6 +23,11 @@ enum VacationType: string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return $this->getLabel();
|
||||||
|
}
|
||||||
|
|
||||||
public function color(): string
|
public function color(): string
|
||||||
{
|
{
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ namespace App\Filament\Resources\Employees\Schemas;
|
|||||||
|
|
||||||
use App\Enums\EmploymentStatus;
|
use App\Enums\EmploymentStatus;
|
||||||
use App\Enums\Gender;
|
use App\Enums\Gender;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Support\RawJs;
|
||||||
use App\Filament\Support\HrForm;
|
use App\Filament\Support\HrForm;
|
||||||
use App\Support\Countries;
|
use App\Support\Countries;use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\DatePicker;
|
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Schemas\Components\Tabs;
|
use Filament\Schemas\Components\Tabs;
|
||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
@@ -59,9 +59,12 @@ class EmployeeForm
|
|||||||
|
|
||||||
TextInput::make('phone')
|
TextInput::make('phone')
|
||||||
->label(__('hr.fields.phone'))
|
->label(__('hr.fields.phone'))
|
||||||
->tel()
|
->prefix('+993')
|
||||||
->default(config('hr.default_phone'))
|
->mask(RawJs::make(<<<'JS'
|
||||||
|
'99 99-99-99'
|
||||||
|
JS))
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Textarea::make('address')
|
Textarea::make('address')
|
||||||
->label(__('hr.fields.address'))
|
->label(__('hr.fields.address'))
|
||||||
->rows(3)
|
->rows(3)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ return [
|
|||||||
|
|
||||||
'leave_calculation' => env('HR_LEAVE_CALCULATION', 'calendar'), // calendar|business
|
'leave_calculation' => env('HR_LEAVE_CALCULATION', 'calendar'), // calendar|business
|
||||||
|
|
||||||
'default_phone' => '+993 61 92 92 48',
|
'default_phone' => '+993',
|
||||||
|
|
||||||
'employee_number' => [
|
'employee_number' => [
|
||||||
'prefix' => 'EMP-',
|
'prefix' => 'EMP-',
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'gender' => [
|
'gender' => [
|
||||||
'male' => 'Erkek',
|
'male' => 'Male',
|
||||||
'female' => 'Aýal',
|
'female' => 'Female',
|
||||||
'other' => 'Other',
|
'other' => 'Other',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'employment_status' => [
|
'employment_status' => [
|
||||||
'active' => 'Işjeň',
|
'active' => 'Işleýär',
|
||||||
'inactive' => 'Işjeň däl',
|
'inactive' => 'Wagtlaýyn işlemeýär',
|
||||||
'terminated' => 'Işden boşadyldy',
|
'terminated' => 'Işden boşadyldy',
|
||||||
'on_leave' => 'Rugsatda',
|
'on_leave' => 'Rugsatda',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use App\Enums\EmploymentStatus;
|
||||||
use App\Enums\Gender;
|
use App\Enums\Gender;
|
||||||
use App\Enums\NavigationGroup;
|
use App\Enums\NavigationGroup;
|
||||||
use App\Filament\Resources\ActivityLogs\ActivityLogResource;
|
use App\Filament\Resources\ActivityLogs\ActivityLogResource;
|
||||||
use App\Filament\Resources\Departments\DepartmentResource;
|
use App\Filament\Resources\Departments\DepartmentResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use BezhanSalleh\LanguageSwitch\Events\LocaleChanged;
|
use BezhanSalleh\LanguageSwitch\Events\LocaleChanged;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Illuminate\Support\Facades\App;
|
use Illuminate\Support\Facades\App;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
|
|
||||||
@@ -35,6 +37,21 @@ it('returns translated navigation group labels', function (): void {
|
|||||||
expect(NavigationGroup::LeaveManagement->getLabel())->toBe('Dynç alyş dolandyryşy');
|
expect(NavigationGroup::LeaveManagement->getLabel())->toBe('Dynç alyş dolandyryşy');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns translated enum options for filament selects', function (): void {
|
||||||
|
App::setLocale('tk');
|
||||||
|
|
||||||
|
$options = Select::make('employment_status')
|
||||||
|
->options(EmploymentStatus::class)
|
||||||
|
->getOptions();
|
||||||
|
|
||||||
|
expect($options)->toBe([
|
||||||
|
'active' => 'Işleýär',
|
||||||
|
'inactive' => 'Wagtlaýyn işlemeýär',
|
||||||
|
'terminated' => 'Işden boşadyldy',
|
||||||
|
'on_leave' => 'Rugsatda',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('returns translated filament navigation group labels at request time', function (): void {
|
it('returns translated filament navigation group labels at request time', function (): void {
|
||||||
$admin = createAdminUser(['locale' => 'tk']);
|
$admin = createAdminUser(['locale' => 'tk']);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user