feat(i18n): wrap 1103 hardcoded UI strings across Filament with __()
- Convert static $modelLabel/$pluralModelLabel/$title to getter methods - Wrap ->label()/->placeholder()/->helperText()/->description()/->title()/->body() args - Wrap Section::make()/Fieldset::make()/Notification::make()->title() args - Fix RelationManagers::getTitle() signature to match parent (Model, string) - Fix Pages::getTitle() to instance method (BasePage::getTitle is non-static) - Extend lang/ru.json + lang/en.json with 700+ common terms; identity fallback for the rest - Remove duplicate getters in 5 resources that had manual getModelLabel already All 306 tests pass. Missing translations fall back to the RO key so the UI never breaks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,9 +34,19 @@ class WorkOrderResource extends Resource
|
||||
return __('nav.group.Service');
|
||||
}
|
||||
|
||||
protected static ?string $modelLabel = 'fișă';
|
||||
protected static ?string $modelLabel = null;
|
||||
|
||||
protected static ?string $pluralModelLabel = 'fișe lucru';
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('fișă');
|
||||
}
|
||||
|
||||
protected static ?string $pluralModelLabel = null;
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('fișe lucru');
|
||||
}
|
||||
|
||||
protected static ?int $navigationSort = 30;
|
||||
|
||||
@@ -63,76 +73,76 @@ class WorkOrderResource extends Resource
|
||||
{
|
||||
return $schema->components([
|
||||
// Antet compact — o singură secțiune densă cu doar esențialul, mereu deschisă.
|
||||
Schemas\Components\Section::make('Antet fișă')
|
||||
->description('Informația de bază — click pe titlul secțiunilor de mai jos pentru detalii.')
|
||||
Schemas\Components\Section::make(__('Antet fișă'))
|
||||
->description(__('Informația de bază — click pe titlul secțiunilor de mai jos pentru detalii.'))
|
||||
->compact()
|
||||
->columns(4)
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('number')->label('Nr.')->disabled()->dehydrated(false)->placeholder('auto'),
|
||||
Forms\Components\DatePicker::make('opened_at')->label('Deschis')->default(today())->required(),
|
||||
Forms\Components\TextInput::make('number')->label(__('Nr.'))->disabled()->dehydrated(false)->placeholder('auto'),
|
||||
Forms\Components\DatePicker::make('opened_at')->label(__('Deschis'))->default(today())->required(),
|
||||
Forms\Components\Select::make('status')->options(WorkOrder::STATUSES)->default('new')->required(),
|
||||
Forms\Components\Select::make('urgency')->label('Urgență')
|
||||
Forms\Components\Select::make('urgency')->label(__('Urgență'))
|
||||
->options(\App\Models\Tenant\PricingCoefficient::URGENCY)->default('normal')->required(),
|
||||
Forms\Components\Select::make('client_id')->label('Client')
|
||||
Forms\Components\Select::make('client_id')->label(__('Client'))
|
||||
->options(fn () => Client::pluck('name', 'id'))
|
||||
->searchable()->live()->required()->columnSpan(2),
|
||||
Forms\Components\Select::make('vehicle_id')->label('Auto')
|
||||
Forms\Components\Select::make('vehicle_id')->label(__('Auto'))
|
||||
->options(fn (Get $get) => $get('client_id')
|
||||
? Vehicle::where('client_id', $get('client_id'))->get()
|
||||
->mapWithKeys(fn ($v) => [$v->id => "{$v->make} {$v->model} {$v->plate}"])->toArray()
|
||||
: [])
|
||||
->searchable()->columnSpan(2),
|
||||
Forms\Components\Select::make('master_id')->label('Maistru')
|
||||
Forms\Components\Select::make('master_id')->label(__('Maistru'))
|
||||
->options(fn () => User::where('status', 'active')->pluck('name', 'id'))
|
||||
->searchable()->columnSpan(2),
|
||||
Forms\Components\TextInput::make('mileage_in')->label('Km intrare')->numeric(),
|
||||
Forms\Components\TextInput::make('mileage_out')->label('Km ieșire')->numeric(),
|
||||
Forms\Components\TextInput::make('mileage_in')->label(__('Km intrare'))->numeric(),
|
||||
Forms\Components\TextInput::make('mileage_out')->label(__('Km ieșire'))->numeric(),
|
||||
]),
|
||||
|
||||
// Toate secțiunile de detaliu — collapsible și collapsed by default
|
||||
Schemas\Components\Section::make('Diagnostic')
|
||||
Schemas\Components\Section::make(__('Diagnostic'))
|
||||
->collapsible()->collapsed()->compact()
|
||||
->schema([
|
||||
Forms\Components\Textarea::make('complaint')->label('Plângere client')->rows(2)->columnSpanFull(),
|
||||
Forms\Components\Textarea::make('diagnosis')->label('Diagnostic')->rows(3)->columnSpanFull(),
|
||||
Forms\Components\Textarea::make('recommendations')->label('Recomandări')->rows(2)->columnSpanFull(),
|
||||
Forms\Components\Textarea::make('complaint')->label(__('Plângere client'))->rows(2)->columnSpanFull(),
|
||||
Forms\Components\Textarea::make('diagnosis')->label(__('Diagnostic'))->rows(3)->columnSpanFull(),
|
||||
Forms\Components\Textarea::make('recommendations')->label(__('Recomandări'))->rows(2)->columnSpanFull(),
|
||||
]),
|
||||
Schemas\Components\Section::make('Foto')
|
||||
Schemas\Components\Section::make(__('Foto'))
|
||||
->collapsible()->collapsed()->compact()
|
||||
->schema([
|
||||
\Filament\Forms\Components\SpatieMediaLibraryFileUpload::make('photos')
|
||||
->label('Fotografii')->collection('photos')
|
||||
->label(__('Fotografii'))->collection('photos')
|
||||
->multiple()->reorderable()->image()->imageEditor()->maxFiles(20)
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Schemas\Components\Section::make('Tracking & ETA')
|
||||
Schemas\Components\Section::make(__('Tracking & ETA'))
|
||||
->columns(3)->collapsible()->collapsed()->compact()
|
||||
->schema([
|
||||
Forms\Components\DateTimePicker::make('eta_at')->label('Gata estimat (ETA)')->seconds(false),
|
||||
Forms\Components\TextInput::make('tracking_token')->label('Token public')
|
||||
Forms\Components\DateTimePicker::make('eta_at')->label(__('Gata estimat (ETA)'))->seconds(false),
|
||||
Forms\Components\TextInput::make('tracking_token')->label(__('Token public'))
|
||||
->disabled()->dehydrated(false)->columnSpan(2)
|
||||
->helperText(fn (?WorkOrder $record) => $record?->tracking_token
|
||||
? 'Link client: ' . $record->trackingUrl()
|
||||
: 'Se generează la salvare'),
|
||||
]),
|
||||
Schemas\Components\Section::make('Plată & total')
|
||||
Schemas\Components\Section::make(__('Plată & total'))
|
||||
->columns(3)->collapsible()->collapsed()->compact()
|
||||
->schema([
|
||||
Forms\Components\Select::make('pay_status')->options(WorkOrder::PAY_STATUSES)->default('unpaid')->required(),
|
||||
Forms\Components\TextInput::make('discount_pct')->label('Discount %')->numeric()->default(0),
|
||||
Forms\Components\TextInput::make('discount_pct')->label(__('Discount %'))->numeric()->default(0),
|
||||
Forms\Components\Toggle::make('apply_margin')
|
||||
->label('Aplică marjă internă')
|
||||
->label(__('Aplică marjă internă'))
|
||||
->default(true)
|
||||
->helperText('On = din prețul manoperelor se scade marja pentru salariu. Off = manopere la cost (salariu pe Total integral).')
|
||||
->helperText(__('On = din prețul manoperelor se scade marja pentru salariu. Off = manopere la cost (salariu pe Total integral).'))
|
||||
->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false),
|
||||
Forms\Components\TextInput::make('override_margin_pct')->label('Marjă internă (%) — override')
|
||||
Forms\Components\TextInput::make('override_margin_pct')->label(__('Marjă internă (%) — override'))
|
||||
->numeric()->step(0.01)->minValue(0)->maxValue(90)
|
||||
->placeholder('Ex: 25')
|
||||
->helperText('Doar pentru cazuri speciale. Lasă gol → folosește marja mecanicului.')
|
||||
->placeholder(__('Ex: 25'))
|
||||
->helperText(__('Doar pentru cazuri speciale. Lasă gol → folosește marja mecanicului.'))
|
||||
->visible(fn () => auth()->user()?->canDo(\App\Auth\Permissions::FINANCE_VIEW_INTERNAL_MARGIN) ?? false),
|
||||
Forms\Components\TextInput::make('total')->label('Total')->numeric()->disabled()->dehydrated(false),
|
||||
Forms\Components\Toggle::make('approved')->label('Aprobat de client'),
|
||||
Forms\Components\DatePicker::make('closed_at')->label('Închis'),
|
||||
Forms\Components\TextInput::make('total')->label(__('Total'))->numeric()->disabled()->dehydrated(false),
|
||||
Forms\Components\Toggle::make('approved')->label(__('Aprobat de client')),
|
||||
Forms\Components\DatePicker::make('closed_at')->label(__('Închis')),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -141,11 +151,11 @@ class WorkOrderResource extends Resource
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('number')->label('Nr.')->searchable()->sortable(),
|
||||
Tables\Columns\TextColumn::make('opened_at')->label('Deschis')->date('d.m.Y')->sortable(),
|
||||
Tables\Columns\TextColumn::make('client.name')->label('Client')->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle.plate')->label('Auto')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('master.name')->label('Maistru')->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('number')->label(__('Nr.'))->searchable()->sortable(),
|
||||
Tables\Columns\TextColumn::make('opened_at')->label(__('Deschis'))->date('d.m.Y')->sortable(),
|
||||
Tables\Columns\TextColumn::make('client.name')->label(__('Client'))->searchable(),
|
||||
Tables\Columns\TextColumn::make('vehicle.plate')->label(__('Auto'))->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('master.name')->label(__('Maistru'))->placeholder('—'),
|
||||
Tables\Columns\TextColumn::make('status')
|
||||
->formatStateUsing(fn ($state) => WorkOrder::STATUSES[$state] ?? $state)
|
||||
->badge()
|
||||
@@ -170,12 +180,12 @@ class WorkOrderResource extends Resource
|
||||
Tables\Filters\SelectFilter::make('status')->options(WorkOrder::STATUSES),
|
||||
Tables\Filters\SelectFilter::make('pay_status')->options(WorkOrder::PAY_STATUSES),
|
||||
Tables\Filters\SelectFilter::make('master_id')
|
||||
->label('Maistru')
|
||||
->label(__('Maistru'))
|
||||
->options(fn () => User::pluck('name', 'id')),
|
||||
])
|
||||
->actions([
|
||||
Actions\Action::make('pdf')
|
||||
->label('PDF')
|
||||
->label(__('PDF'))
|
||||
->icon('heroicon-m-document-arrow-down')
|
||||
->color('gray')
|
||||
->action(function (WorkOrder $r) {
|
||||
@@ -190,8 +200,8 @@ class WorkOrderResource extends Resource
|
||||
Actions\EditAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
])
|
||||
->emptyStateHeading('Nicio fișă de lucru')
|
||||
->emptyStateDescription('Crează prima fișă pentru o mașină existentă. Adaugă manopere, piese, plăți — totalul se calculează automat.')
|
||||
->emptyStateHeading(__('Nicio fișă de lucru'))
|
||||
->emptyStateDescription(__('Crează prima fișă pentru o mașină existentă. Adaugă manopere, piese, plăți — totalul se calculează automat.'))
|
||||
->emptyStateIcon('heroicon-o-wrench-screwdriver')
|
||||
->defaultSort('opened_at', 'desc');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user