From 188c03b02386f0642428c981ad9d369e94856385 Mon Sep 17 00:00:00 2001 From: Lee Evans Date: Mon, 26 Aug 2024 00:51:18 +0100 Subject: [PATCH] Added additional sort and search columns --- src/Resources/EmailTemplateThemeResource.php | 205 ++++++++++--------- 1 file changed, 103 insertions(+), 102 deletions(-) diff --git a/src/Resources/EmailTemplateThemeResource.php b/src/Resources/EmailTemplateThemeResource.php index c63f93f..68848f2 100644 --- a/src/Resources/EmailTemplateThemeResource.php +++ b/src/Resources/EmailTemplateThemeResource.php @@ -51,6 +51,82 @@ public static function getSubNavigationPosition(): SubNavigationPosition return config('filament-email-templates.navigation.templates.position'); } + public static function form(Form $form): Form + { + return $form + ->schema([ + Forms\Components\Group::make() + ->schema([ + Forms\Components\Section::make(__('vb-email-templates::email-templates.theme-form-fields-labels.template-preview')) + ->schema([ + Forms\Components\ViewField::make('preview')->view('vb-email-templates::email.default_preview', ['data' => self::getPreviewData()]), + ]) + ->columnSpan(['lg' => 2]), + ]) + ->columnSpan(['lg' => 2]), + + Forms\Components\Group::make() + ->schema([ + Forms\Components\Section::make() + ->schema([ + Forms\Components\TextInput::make('name') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.theme-name')) + ->columnSpan(3), + + Forms\Components\Toggle::make('is_default') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.is-default')) + ->inline(false) + ->onColor('success') + ->offColor('danger'), + ]), + + Forms\Components\Section::make(__('vb-email-templates::email-templates.theme-form-fields-labels.set-colors')) + ->schema([ + Forms\Components\ColorPicker::make('colours.header_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.header-bg')) + ->live(), + + Forms\Components\ColorPicker::make('colours.body_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.body-bg')) + ->live(), + + Forms\Components\ColorPicker::make('colours.content_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.content-bg')) + ->live(), + + Forms\Components\ColorPicker::make('colours.footer_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.footer-bg')), + + Forms\Components\ColorPicker::make('colours.callout_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.callout-bg')) + ->live(), + + Forms\Components\ColorPicker::make('colours.button_bg_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.button-bg')) + ->live(), + + Forms\Components\ColorPicker::make('colours.body_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.body-color')) + ->live(), + + Forms\Components\ColorPicker::make('colours.callout_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.callout-color')) + ->live(), + + Forms\Components\ColorPicker::make('colours.button_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.button-color')) + ->live(), + + Forms\Components\ColorPicker::make('colours.anchor_color') + ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.anchor-color')) + ->live(), + ]), + + ]) + ->columnSpan(['lg' => 1]), + ])->columns(3); + } + public static function getPreviewData() { $emailTemplate = EmailTemplate::first(); @@ -58,121 +134,46 @@ public static function getPreviewData() return $emailTemplate->getEmailPreviewData(); } - public static function form(Form $form): Form - { - return $form - ->schema([ - Forms\Components\Group::make() - ->schema([ - Forms\Components\Section::make(__('vb-email-templates::email-templates.theme-form-fields-labels.template-preview')) - ->schema([ - Forms\Components\ViewField::make('preview')->view('vb-email-templates::email.default_preview', ['data' => self::getPreviewData()]), - ]) - ->columnSpan(['lg' => 2]), - ]) - ->columnSpan(['lg' => 2]), - - Forms\Components\Group::make() - ->schema([ - Forms\Components\Section::make() - ->schema([ - Forms\Components\TextInput::make('name') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.theme-name')) - ->columnSpan(3), - - Forms\Components\Toggle::make('is_default') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.is-default')) - ->inline(false) - ->onColor('success') - ->offColor('danger'), - ]), - - Forms\Components\Section::make(__('vb-email-templates::email-templates.theme-form-fields-labels.set-colors')) - ->schema([ - Forms\Components\ColorPicker::make('colours.header_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.header-bg')) - ->live(), - - Forms\Components\ColorPicker::make('colours.body_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.body-bg')) - ->live(), - - Forms\Components\ColorPicker::make('colours.content_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.content-bg')) - ->live(), - - Forms\Components\ColorPicker::make('colours.footer_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.footer-bg')), - - Forms\Components\ColorPicker::make('colours.callout_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.callout-bg')) - ->live(), - - Forms\Components\ColorPicker::make('colours.button_bg_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.button-bg')) - ->live(), - - Forms\Components\ColorPicker::make('colours.body_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.body-color')) - ->live(), - - Forms\Components\ColorPicker::make('colours.callout_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.callout-color')) - ->live(), - - Forms\Components\ColorPicker::make('colours.button_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.button-color')) - ->live(), - - Forms\Components\ColorPicker::make('colours.anchor_color') - ->label(__('vb-email-templates::email-templates.theme-form-fields-labels.anchor-color')) - ->live(), - ]), - - ]) - ->columnSpan(['lg' => 1]), - ])->columns(3); - } - public static function table(Table $table): Table { return $table - ->columns([ - Tables\Columns\TextColumn::make('name'), - Tables\Columns\IconColumn::make('is_default')->boolean(), - ]) - ->filters([ - // - ]) - ->actions([ - Tables\Actions\EditAction::make(), - ]) - ->bulkActions([ - Tables\Actions\BulkActionGroup::make([ - Tables\Actions\DeleteBulkAction::make(), - ]), - ]) - ->emptyStateActions([ - Tables\Actions\CreateAction::make(), - ]); + ->columns([ + Tables\Columns\TextColumn::make('id')->sortable()->searchable(), + Tables\Columns\TextColumn::make('name')->sortable()->searchable(), + Tables\Columns\IconColumn::make('is_default')->boolean(), + ]) + ->filters([ + // + ]) + ->actions([ + Tables\Actions\EditAction::make(), + ]) + ->bulkActions([ + Tables\Actions\BulkActionGroup::make([ + Tables\Actions\DeleteBulkAction::make(), + ]), + ]) + ->emptyStateActions([ + Tables\Actions\CreateAction::make(), + ]); } public static function getPages(): array { return [ - 'index' => Pages\ListEmailTemplateThemes::route('/'), - 'create' => Pages\CreateEmailTemplateTheme::route('/create'), - 'edit' => Pages\EditEmailTemplateTheme::route('/{record}/edit'), + 'index' => Pages\ListEmailTemplateThemes::route('/'), + 'create' => Pages\CreateEmailTemplateTheme::route('/create'), + 'edit' => Pages\EditEmailTemplateTheme::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { return parent::getEloquentQuery() - ->withoutGlobalScopes( - [ - SoftDeletingScope::class, - ] - ); + ->withoutGlobalScopes( + [ + SoftDeletingScope::class, + ] + ); } }