Implement Site Translations API and DataGrid View: Introduced a new API controller for managing site translations, including methods for listing, storing, updating, and deleting translations. Added a DataGrid view for the site translations page, allowing for enhanced user interaction and management of translations. Implemented session-based view toggling between traditional table and DataGrid formats, improving usability. Localization support has been integrated for all text elements, ensuring a seamless experience for users across different languages.
This commit is contained in:
@@ -5,17 +5,54 @@ namespace App\Filament\Admin\Resources\SiteTranslations\Pages;
|
||||
use App\Filament\Admin\Resources\SiteTranslations\SiteTranslationResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Actions\Action;
|
||||
use Illuminate\Contracts\View\View;
|
||||
|
||||
class ListSiteTranslations extends ListRecords
|
||||
{
|
||||
protected static string $resource = SiteTranslationResource::class;
|
||||
|
||||
public bool $useDataGrid = false;
|
||||
|
||||
public function mount(): void
|
||||
{
|
||||
parent::mount();
|
||||
|
||||
// Session'dan görünüm tercihini al, yoksa varsayılan olarak false (eski görünüm)
|
||||
$this->useDataGrid = session('site_translations_use_datagrid', false);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
Action::make('toggleView')
|
||||
->label(fn() => $this->useDataGrid ? 'Tablo Görünümü' : 'DataGrid Görünümü')
|
||||
->icon(fn() => $this->useDataGrid ? 'heroicon-o-table-cells' : 'heroicon-o-squares-2x2')
|
||||
->color('gray')
|
||||
->action(function () {
|
||||
$this->useDataGrid = !$this->useDataGrid;
|
||||
session(['site_translations_use_datagrid' => $this->useDataGrid]);
|
||||
|
||||
// Sayfayı yenile ki getContent() yeniden çağrılsın
|
||||
return redirect()->to($this->getResource()::getUrl('index'));
|
||||
}),
|
||||
CreateAction::make()
|
||||
->visible(fn() => !$this->useDataGrid), // Sadece eski görünümde göster
|
||||
];
|
||||
}
|
||||
|
||||
public function getContent(): View
|
||||
{
|
||||
// Session'dan direkt oku ki her render'da güncel değeri alsın
|
||||
$useDataGrid = session('site_translations_use_datagrid', false);
|
||||
|
||||
if ($useDataGrid) {
|
||||
return view('filament.admin.resources.site-translations.datagrid');
|
||||
}
|
||||
|
||||
// Eski Filament table görünümü
|
||||
return parent::getContent();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user