Closed slash12 closed 4 weeks ago
Hmm we need to update the table to have translateable labels. The table columns need
->label(__('vb-email-templates::email-templates.form-fields-labels.xxxxx'))
public static function table(Table $table): Table
{
return $table
->query(EmailTemplate::query())
->columns(
[
TextColumn::make('id')
->sortable()
->searchable(),
TextColumn::make('name')
->limit(50)
->sortable()
->searchable(),
TextColumn::make('language')
->limit(50),
TextColumn::make('subject')
->searchable()
->limit(50),
]
)
If you need it urgently then just create a new resource and extend this file. You'll just need to copy n paste the table method and add the labels. Pull request welcomed :-)
I did as you requested, here is my code:
namespace App\Filament\Resources\EmailTemplates;
use Filament\Notifications\Notification;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\View\View;
use Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource as VisualBuilderEmailTemplateResource;
class EmailTemplateResource extends VisualBuilderEmailTemplateResource
{
public static function getNavigationGroup(): ?string
{
return __('admin.site_general_settings');
}
public static function table(Table $table): Table
{
return $table
->query(EmailTemplate::query())
->columns(
[
TextColumn::make('id')
->sortable()
->searchable(),
TextColumn::make('test name')
->limit(50)
->sortable()
->searchable(),
TextColumn::make('language')
->limit(50),
TextColumn::make('subject')
->searchable()
->limit(50),
]
)
->filters(
[
Tables\Filters\TrashedFilter::make(),
]
)
->actions(
[
Action::make('create-mail-class')
->label("Build Class")
//Only show the button if the file does not exist
->visible(function (EmailTemplate $record) {
return !$record->mailable_exists;
})
->icon('heroicon-o-document-text')
// ->action('createMailClass'),
->action(function (EmailTemplate $record) {
$notify = app(CreateMailableInterface::class)->createMailable($record);
Notification::make()
->title($notify->title)
->icon($notify->icon)
->iconColor($notify->icon_color)
->duration(10000)
//Fix for bug where body hides the icon
->body("<span style='overflow-wrap: anywhere;'>" . $notify->body . "</span>")
->send();
}),
Tables\Actions\ViewAction::make('Preview')
->icon('heroicon-o-magnifying-glass')
->modalContent(fn(EmailTemplate $record): View => view(
'vb-email-templates::forms.components.iframe',
['record' => $record],
))->form(null)
->modalHeading(fn(EmailTemplate $record): string => 'Preview Email: ' . $record->name)
->modalSubmitAction(false)
->modalCancelAction(false)
->slideOver(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\ForceDeleteAction::make()
->before(function (EmailTemplate $record, \Visualbuilder\EmailTemplates\Resources\EmailTemplateResource $emailTemplateResource) {
$emailTemplateResource->handleLogoDelete($record->logo);
}),
Tables\Actions\RestoreAction::make(),
]
)
->bulkActions(
[
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]
);
}
}```
i change name heading to 'test name' but it is not overriden...and i don't why
No the attribute names must be the same as the database. Use the label property:-
TextColumn::make('name')
->label('Nome')
->limit(50)
->sortable()
->searchable(),
<?php
namespace App\Filament\Resources\EmailTemplates;
use Filament\Notifications\Notification;
use Filament\Tables;
use Filament\Tables\Actions\Action;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\View\View;
use Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource as VisualBuilderEmailTemplateResource;
class EmailTemplateResource extends VisualBuilderEmailTemplateResource
{
public static function getNavigationGroup(): ?string
{
return __('admin.site_general_settings');
}
public static function table(Table $table): Table
{
return $table
->query(EmailTemplate::query())
->columns(
[
TextColumn::make('id')
->sortable()
->searchable(),
TextColumn::make('name')
->label('test')
->limit(50)
->sortable()
->searchable(),
TextColumn::make('language')
->limit(50),
TextColumn::make('subject')
->searchable()
->limit(50),
]
)
->filters(
[
Tables\Filters\TrashedFilter::make(),
]
)
->actions(
[
Action::make('create-mail-class')
->label("Build Class")
//Only show the button if the file does not exist
->visible(function (EmailTemplate $record) {
return !$record->mailable_exists;
})
->icon('heroicon-o-document-text')
// ->action('createMailClass'),
->action(function (EmailTemplate $record) {
$notify = app(CreateMailableInterface::class)->createMailable($record);
Notification::make()
->title($notify->title)
->icon($notify->icon)
->iconColor($notify->icon_color)
->duration(10000)
//Fix for bug where body hides the icon
->body("<span style='overflow-wrap: anywhere;'>" . $notify->body . "</span>")
->send();
}),
Tables\Actions\ViewAction::make('Preview')
->icon('heroicon-o-magnifying-glass')
->modalContent(fn(EmailTemplate $record): View => view(
'vb-email-templates::forms.components.iframe',
['record' => $record],
))->form(null)
->modalHeading(fn(EmailTemplate $record): string => 'Preview Email: ' . $record->name)
->modalSubmitAction(false)
->modalCancelAction(false)
->slideOver(),
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
Tables\Actions\ForceDeleteAction::make()
->before(function (EmailTemplate $record, \Visualbuilder\EmailTemplates\Resources\EmailTemplateResource $emailTemplateResource) {
$emailTemplateResource->handleLogoDelete($record->logo);
}),
Tables\Actions\RestoreAction::make(),
]
)
->bulkActions(
[
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]
);
}
}
still not working
do you have this in your Panel provider config:-
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
Also is your namespace right?
namespace App\Filament\Resources\EmailTemplates;
perhaps it should be:-
namespace App\Filament\Resources;
can you try composer du to check your classes are loaded
do you have this in your Panel provider config: Yes this is defined
Also is your namespace right?
i have tried both App\Filament\Resources\EmailTemplates and App\Filament\Resources, but the problem persists
composer du:
Well, i finally got the solution, it was a crazy journey 🥲 , all i have done is remove this line 'EmailTemplatesPlugin::make()' from AdminPanelProvider.php and redefine the function 'getPages' in the EmailTemplateResource and EmailTemplateThemeResource to point to my overridden pages and it works finally
i try to override the email template resource, for the navigation group, it works but not for the headers. I'm kinda lost