78ff8d4b43
User screenshots showed the tenant admin panel (Filament) had sidebar
labels stuck in Romanian even when switching to Russian: 'Cereri',
'Calendar vizual', 'Atelierul meu', 'KPI mecanici', 'Fișe lucru',
'Norme-ore', 'Tehnicieni', 'Șabloane servicii', 'Depozite', 'Scaner',
'Depozit', 'VIN-căutare', 'Furnizori', 'Achiziții', 'Procentaj',
'Coeficienți preț', plus all group headers.
Root cause: every Filament Resource and Page had static properties
'protected static ?string $navigationLabel = "Fișe lucru"' — string
literals baked into class definitions. Static properties don't run
through the translation layer.
Fix in two parts:
1. New translation files with 52 label keys + 12 group keys:
- lang/ro/nav.php — Romanian (identity)
- lang/ru/nav.php — full Russian translations (Заказ-наряды,
Автомобили, Клиенты, Календарь, Моя мастерская, Механики KPI,
Настройки, etc.)
- lang/en/nav.php — English translations (Work orders, Vehicles,
Clients, Calendar, My workshop, Mechanic KPI, Settings, etc.)
Keyed by the Romanian original so lookups map 1:1 —
'nav.label.Fișe lucru' returns 'Заказ-наряды' in RU, 'Work orders'
in EN, 'Fișe lucru' in RO.
2. Python transformer converted 54 files:
- 33 Filament Tenant Resources
- 15 Filament Tenant Pages
- 4 Filament Central Resources
- 1 Filament Central Page
- 1 Widget
Each 'protected static ?string $navigationLabel = "X";' became
'public static function getNavigationLabel(): string { return
__("nav.label.X"); }'. Same treatment for $navigationGroup.
Cleanup: 6 resources already had manually-added getNavigationLabel
methods from an earlier partial effort — those used flat JSON keys
(__("Cereri")) that never resolved. Deduped so only the nav.label.*
version remains.
Untouched (intentional):
- $modelLabel / $pluralModelLabel (used in breadcrumbs and headings —
still hardcoded, next tier of work)
- Section titles, column headers, form field labels (medium priority)
- $navigationSort (numeric, no translation needed)
- $navigationIcon (icon reference)
Suite: 306 passed (853 assertions). Unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
110 lines
4.1 KiB
PHP
110 lines
4.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tenant\Resources;
|
|
|
|
use App\Auth\Permissions;
|
|
use App\Filament\Tenant\Resources\PostResource\Pages;
|
|
use App\Models\Tenant\Post;
|
|
use App\Models\Tenant\User;
|
|
use Filament\Actions;
|
|
use Filament\Forms;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class PostResource extends Resource
|
|
{
|
|
protected static ?string $model = Post::class;
|
|
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-wrench-screwdriver';
|
|
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return __('nav.label.Posturi de lucru');
|
|
}
|
|
|
|
public static function getNavigationGroup(): ?string
|
|
{
|
|
return __('nav.group.Admin');
|
|
}
|
|
|
|
protected static ?string $modelLabel = 'pod';
|
|
|
|
protected static ?string $pluralModelLabel = 'posturi de lucru';
|
|
|
|
protected static ?int $navigationSort = 76;
|
|
|
|
public static function canViewAny(): bool
|
|
{
|
|
return auth()->user()?->canDo(Permissions::ADMIN_SETTINGS_EDIT) ?? false;
|
|
}
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema->components([
|
|
Schemas\Components\Section::make('Pod / Spațiu lucru')
|
|
->columns(2)
|
|
->schema([
|
|
Forms\Components\TextInput::make('name')
|
|
->label('Nume')
|
|
->required()
|
|
->maxLength(80)
|
|
->placeholder('Ex: Pod 1, Curte 1, Atelier electric'),
|
|
Forms\Components\ColorPicker::make('color')
|
|
->default('#3b82f6'),
|
|
Forms\Components\TextInput::make('hours_per_day')
|
|
->label('Ore disponibile / zi')
|
|
->numeric()
|
|
->step(0.5)
|
|
->default(10)
|
|
->helperText('Capacitatea zilnică în ore'),
|
|
Forms\Components\Select::make('default_master_id')
|
|
->label('Mecanic implicit')
|
|
->options(fn () => User::where('status', 'active')->pluck('name', 'id'))
|
|
->searchable()
|
|
->placeholder('Niciun mecanic implicit')
|
|
->helperText('Va fi pre-completat când creezi o programare pentru acest pod'),
|
|
Forms\Components\TextInput::make('description')
|
|
->label('Descriere')
|
|
->maxLength(255)
|
|
->placeholder('Ex: cu lift, fără lift, doar diagnoză...')
|
|
->columnSpanFull(),
|
|
Forms\Components\TextInput::make('sort_order')
|
|
->numeric()
|
|
->default(100),
|
|
Forms\Components\Toggle::make('is_active')->label('Activ')->default(true),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')->searchable()->sortable(),
|
|
Tables\Columns\ColorColumn::make('color'),
|
|
Tables\Columns\TextColumn::make('hours_per_day')->label('Ore/zi')->sortable(),
|
|
Tables\Columns\TextColumn::make('defaultMaster.name')->label('Mecanic implicit')->placeholder('—'),
|
|
Tables\Columns\TextColumn::make('description')->placeholder('—')->limit(40)->toggleable(),
|
|
Tables\Columns\TextColumn::make('appointments_count')->counts('appointments')->label('Programări')->badge(),
|
|
Tables\Columns\ToggleColumn::make('is_active')->label('Activ'),
|
|
])
|
|
->actions([
|
|
Actions\EditAction::make(),
|
|
Actions\DeleteAction::make(),
|
|
])
|
|
->defaultSort('sort_order');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListPosts::route('/'),
|
|
'create' => Pages\CreatePost::route('/create'),
|
|
'edit' => Pages\EditPost::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|