Skip to content

Commit

Permalink
Added additional sort and search columns
Browse files Browse the repository at this point in the history
  • Loading branch information
cannycookie committed Aug 25, 2024
1 parent 0b1eb3b commit 188c03b
Showing 1 changed file with 103 additions and 102 deletions.
205 changes: 103 additions & 102 deletions src/Resources/EmailTemplateThemeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,128 +51,129 @@ 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();

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,
]
);
}
}

0 comments on commit 188c03b

Please sign in to comment.