22
33namespace Visualbuilder \EmailTemplates \Resources ;
44
5+ use Filament \Actions \BulkActionGroup ;
6+ use Filament \Actions \CreateAction ;
7+ use Filament \Actions \DeleteBulkAction ;
8+ use Filament \Actions \EditAction ;
59use Filament \Forms \Components \ColorPicker ;
610use Filament \Forms \Components \TextInput ;
711use Filament \Forms \Components \Toggle ;
8- use Filament \Forms \Components \ViewField ;
12+ use Filament \Pages \Enums \SubNavigationPosition ;
13+ use Filament \Resources \Resource ;
914use Filament \Schemas \Components \Group ;
1015use Filament \Schemas \Components \Section ;
16+ use Filament \Schemas \Components \View ;
1117use Filament \Schemas \Schema ;
12- use Filament \Pages \Enums \SubNavigationPosition ;
13- use Filament \Resources \Resource ;
14- use Filament \Actions \BulkActionGroup ;
15- use Filament \Actions \CreateAction ;
16- use Filament \Actions \DeleteBulkAction ;
17- use Filament \Actions \EditAction ;
1818use Filament \Tables ;
1919use Filament \Tables \Table ;
2020use Illuminate \Database \Eloquent \Builder ;
@@ -72,68 +72,79 @@ public static function getSubNavigationPosition(): SubNavigationPosition
7272 public static function form (Schema $ schema ): Schema
7373 {
7474 return $ schema
75- ->schema ([
76- Group::make ()
77- ->columnSpanFull ()
78- ->schema ([
79- Section::make ()
80- ->schema ([
81- TextInput::make ('name ' )
82- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.theme-name ' ))
83- ->columnSpan (3 ),
84-
85- Toggle::make ('is_default ' )
86- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.is-default ' ))
87- ->inline (false )
88- ->onColor ('success ' )
89- ->offColor ('danger ' ),
90- ]),
91-
92- Section::make (__ ('vb-email-templates::email-templates.theme-form-fields-labels.set-colors ' ))
93- ->schema ([
94- ColorPicker::make ('colours.header_bg_color ' )
95- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.header-bg ' ))
96- ->live (),
97-
98- ColorPicker::make ('colours.body_bg_color ' )
99- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.body-bg ' ))
100- ->live (),
101-
102- ColorPicker::make ('colours.content_bg_color ' )
103- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.content-bg ' ))
104- ->live (),
105-
106- ColorPicker::make ('colours.footer_bg_color ' )
107- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.footer-bg ' )),
108-
109- ColorPicker::make ('colours.callout_bg_color ' )
110- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.callout-bg ' ))
111- ->live (),
112-
113- ColorPicker::make ('colours.button_bg_color ' )
114- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.button-bg ' ))
115- ->live (),
116-
117- ColorPicker::make ('colours.body_color ' )
118- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.body-color ' ))
119- ->live (),
120-
121- ColorPicker::make ('colours.callout_color ' )
122- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.callout-color ' ))
123- ->live (),
124-
125- ColorPicker::make ('colours.button_color ' )
126- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.button-color ' ))
127- ->live (),
128-
129- ColorPicker::make ('colours.anchor_color ' )
130- ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.anchor-color ' ))
131- ->live (),
132- ]),
133-
134- ])
135- ->columnSpan (['lg ' => 1 ]),
136- ])->columns (3 );
75+ ->schema ([
76+ Group::make ()
77+ ->schema ([
78+ Section::make (__ ('vb-email-templates::email-templates.theme-form-fields-labels.template-preview ' ))
79+ ->schema ([
80+ View::make ('preview ' )
81+ ->view ('vb-email-templates::email.default_preview ' ,
82+ ['data ' => self ::getPreviewData ()])
83+ ->dehydrated (false ),
84+ ])
85+ ->columnSpan (['lg ' => 2 ]),
86+ ])
87+ ->columnSpan (['lg ' => 2 ]),
88+ Group::make ()
89+ ->schema ([
90+ Section::make ()
91+ ->schema ([
92+ TextInput::make ('name ' )
93+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.theme-name ' ))
94+ ->columnSpan (3 ),
95+
96+ Toggle::make ('is_default ' )
97+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.is-default ' ))
98+ ->inline (false )
99+ ->onColor ('success ' )
100+ ->offColor ('danger ' ),
101+ ]),
102+
103+ Section::make (__ ('vb-email-templates::email-templates.theme-form-fields-labels.set-colors ' ))
104+ ->schema ([
105+ ColorPicker::make ('colours.header_bg_color ' )
106+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.header-bg ' ))
107+ ->live (),
108+
109+ ColorPicker::make ('colours.body_bg_color ' )
110+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.body-bg ' ))
111+ ->live (),
112+
113+ ColorPicker::make ('colours.content_bg_color ' )
114+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.content-bg ' ))
115+ ->live (),
116+
117+ ColorPicker::make ('colours.footer_bg_color ' )
118+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.footer-bg ' )),
119+
120+ ColorPicker::make ('colours.callout_bg_color ' )
121+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.callout-bg ' ))
122+ ->live (),
123+
124+ ColorPicker::make ('colours.button_bg_color ' )
125+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.button-bg ' ))
126+ ->live (),
127+
128+ ColorPicker::make ('colours.body_color ' )
129+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.body-color ' ))
130+ ->live (),
131+
132+ ColorPicker::make ('colours.callout_color ' )
133+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.callout-color ' ))
134+ ->live (),
135+
136+ ColorPicker::make ('colours.button_color ' )
137+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.button-color ' ))
138+ ->live (),
139+
140+ ColorPicker::make ('colours.anchor_color ' )
141+ ->label (__ ('vb-email-templates::email-templates.theme-form-fields-labels.anchor-color ' ))
142+ ->live (),
143+ ]),
144+
145+ ])
146+ ->columnSpan (['lg ' => 1 ]),
147+ ])->columns (3 );
137148 }
138149
139150 public static function getPreviewData ()
@@ -146,43 +157,43 @@ public static function getPreviewData()
146157 public static function table (Table $ table ): Table
147158 {
148159 return $ table
149- ->columns ([
150- Tables \Columns \TextColumn::make ('id ' )->sortable ()->searchable (),
151- Tables \Columns \TextColumn::make ('name ' )->sortable ()->searchable (),
152- Tables \Columns \IconColumn::make ('is_default ' )->boolean (),
153- ])
154- ->filters ([
155- //
156- ])
157- ->actions ([
158- EditAction::make (),
159- ])
160- ->bulkActions ([
161- BulkActionGroup::make ([
162- DeleteBulkAction::make (),
163- ]),
164- ])
165- ->emptyStateActions ([
166- CreateAction::make (),
167- ]);
160+ ->columns ([
161+ Tables \Columns \TextColumn::make ('id ' )->sortable ()->searchable (),
162+ Tables \Columns \TextColumn::make ('name ' )->sortable ()->searchable (),
163+ Tables \Columns \IconColumn::make ('is_default ' )->boolean (),
164+ ])
165+ ->filters ([
166+ //
167+ ])
168+ ->actions ([
169+ EditAction::make (),
170+ ])
171+ ->bulkActions ([
172+ BulkActionGroup::make ([
173+ DeleteBulkAction::make (),
174+ ]),
175+ ])
176+ ->emptyStateActions ([
177+ CreateAction::make (),
178+ ]);
168179 }
169180
170181 public static function getPages (): array
171182 {
172183 return [
173- 'index ' => Pages \ListEmailTemplateThemes::route ('/ ' ),
174- 'create ' => Pages \CreateEmailTemplateTheme::route ('/create ' ),
175- 'edit ' => Pages \EditEmailTemplateTheme::route ('/{record}/edit ' ),
184+ 'index ' => Pages \ListEmailTemplateThemes::route ('/ ' ),
185+ 'create ' => Pages \CreateEmailTemplateTheme::route ('/create ' ),
186+ 'edit ' => Pages \EditEmailTemplateTheme::route ('/{record}/edit ' ),
176187 ];
177188 }
178189
179190 public static function getEloquentQuery (): Builder
180191 {
181192 return parent ::getEloquentQuery ()
182- ->withoutGlobalScopes (
183- [
184- SoftDeletingScope::class,
185- ]
186- );
193+ ->withoutGlobalScopes (
194+ [
195+ SoftDeletingScope::class,
196+ ]
197+ );
187198 }
188199}
0 commit comments