Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
danharrin committed Feb 24, 2022
1 parent d2c3c1f commit 1e481fa
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 30 deletions.
1 change: 0 additions & 1 deletion packages/admin/src/Commands/MakeWidgetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function handle(): int
'Radar chart',
'Scatter chart',
],
0,
);

$this->copyStubToApp('ChartWidget', $path, [
Expand Down
18 changes: 8 additions & 10 deletions packages/admin/src/Resources/Pages/CreateRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ public function create(bool $another = false): void

$this->callHook('afterCreate');

$this->getCreatedNotification(another: $another);

$this->notify(
'success',
$this->getCreatedNotificationMessage(),
isAfterRedirect: ! $another,
);

if ($another) {
// Ensure that the form record is anonymized so that relationships aren't loaded.
$this->form->model($this->record::class);
Expand All @@ -77,17 +81,11 @@ public function create(bool $another = false): void
$this->redirect($this->getRedirectUrl());
}

public function getCreatedNotification(bool $another): void
protected function getCreatedNotificationMessage(): string
{
$this->notify(
'success',
__('filament::resources/pages/create-record.messages.created'),
isAfterRedirect: !$another,
);
return __('filament::resources/pages/create-record.messages.created');
}



public function createAndCreateAnother(): void
{
$this->create(another: true);
Expand Down
21 changes: 13 additions & 8 deletions packages/admin/src/Resources/Pages/EditRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,20 @@ public function save(bool $shouldRedirect = true): void

$shouldRedirect = $shouldRedirect && ($redirectUrl = $this->getRedirectUrl());

$this->getUpdatedNotification(isAfterRedirect: $shouldRedirect);
$this->notify(
'success',
$this->getSavedNotificationMessage(),
isAfterRedirect: $shouldRedirect,
);

if ($shouldRedirect) {
$this->redirect($redirectUrl);
}
}

public function getUpdatedNotification(bool $isAfterRedirect): void
protected function getSavedNotificationMessage(): string
{
$this->notify(
'success',
__('filament::resources/pages/edit-record.messages.saved'),
isAfterRedirect: $isAfterRedirect,
);
return __('filament::resources/pages/edit-record.messages.saved');
}

protected function handleRecordUpdate(Model $record, array $data): Model
Expand Down Expand Up @@ -127,13 +127,18 @@ public function delete(): void

$this->notify(
'success',
__('filament::resources/pages/edit-record.actions.delete.messages.deleted'),
$this->getDeletedNotificationMessage(),
isAfterRedirect: true,
);

$this->redirect($this->getDeleteRedirectUrl());
}

protected function getDeletedNotificationMessage(): string
{
return __('filament::resources/pages/edit-record.actions.delete.messages.deleted');
}

protected function getActions(): array
{
$resource = static::getResource();
Expand Down
7 changes: 6 additions & 1 deletion packages/admin/src/Resources/Pages/ListRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ public function bulkDelete(): void

$this->callHook('afterBulkDelete');

$this->notify('success', __('filament::resources/pages/list-records.table.bulk_actions.delete.messages.deleted'));
$this->notify('success', $this->getBulkDeletedNotificationMessage());
}

protected function getBulkDeletedNotificationMessage(): string
{
return __('filament::resources/pages/list-records.table.bulk_actions.delete.messages.deleted');
}

protected function handleRecordBulkDeletion(Collection $records): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public function delete(): void

$this->callHook('afterDelete');

$this->notify('success', __('filament::resources/pages/list-records.table.actions.delete.messages.deleted'));
$this->notify('success', $this->getDeletedNotificationMessage());
}

protected function getDeletedNotificationMessage(): string
{
return __('filament::resources/pages/list-records.table.actions.delete.messages.deleted');
}

protected function handleRecordDeletion(Model $record): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public function save(): void

$this->callHook('afterSave');

$this->notify('success', __('filament::resources/pages/list-records.table.actions.edit.messages.saved'));
$this->notify('success', $this->getSavedNotificationMessage());
}

protected function getSavedNotificationMessage(): string
{
return __('filament::resources/pages/list-records.table.actions.edit.messages.saved');
}

protected function handleRecordUpdate(Model $record, array $data): Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ public function attach(bool $another = false): void
$form->fill();
}

$this->notify('success', __('filament::resources/relation-managers/attach.action.messages.attached'));
$this->notify('success', $this->getAttachedNotificationMessage());
}

protected function getAttachedNotificationMessage(): string
{
return __('filament::resources/relation-managers/attach.action.messages.attached');
}

public function attachAndAttachAnother(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public function create(bool $another = false): void
$form->fill();
}

$this->notify('success', __('filament::resources/relation-managers/create.action.messages.created'));
$this->notify('success', $this->getCreatedNotificationMessage());
}

protected function getCreatedNotificationMessage(): string
{
return __('filament::resources/relation-managers/create.action.messages.created');
}

public function createAndCreateAnother(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public function delete(): void

$this->callHook('afterDelete');

$this->notify('success', __('filament::resources/relation-managers/delete.action.messages.deleted'));
$this->notify('success', $this->getDeletedNotificationMessage());
}

protected function getDeletedNotificationMessage(): string
{
return __('filament::resources/relation-managers/delete.action.messages.deleted');
}

public function bulkDelete(): void
Expand All @@ -36,7 +41,12 @@ public function bulkDelete(): void

$this->callHook('afterBulkDelete');

$this->notify('success', __('filament::resources/relation-managers/delete.bulk_action.messages.deleted'));
$this->notify('success', $this->getBulkDeletedNotificationMessage());
}

protected function getBulkDeletedNotificationMessage(): string
{
return __('filament::resources/relation-managers/delete.bulk_action.messages.deleted');
}

protected function getDeleteAction(): Tables\Actions\Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public function detach(): void

$this->callHook('afterDetach');

$this->notify('success', __('filament::resources/relation-managers/detach.action.messages.detached'));
$this->notify('success', $this->getDetachedNotificationMessage());
}

protected function getDetachedNotificationMessage(): string
{
return __('filament::resources/relation-managers/detach.action.messages.detached');
}

public function bulkDetach(): void
Expand All @@ -43,7 +48,12 @@ public function bulkDetach(): void

$this->callHook('afterBulkDetach');

$this->notify('success', __('filament::resources/relation-managers/detach.bulk_action.messages.detached'));
$this->notify('success', $this->getBulkDetachedNotificationMessage());
}

protected function getBulkDetachedNotificationMessage(): string
{
return __('filament::resources/relation-managers/detach.bulk_action.messages.detached');
}

protected function getDetachAction(): Tables\Actions\Action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ public function save(): void

$this->callHook('afterSave');

$this->notify('success', __('filament::resources/relation-managers/edit.action.messages.saved'));
$this->notify('success', $this->getSavedNotificationMessage());
}

protected function getSavedNotificationMessage(): string
{
return __('filament::resources/relation-managers/edit.action.messages.saved');
}

protected function handleRecordUpdate(Model $record, array $data): Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ public function save(): void
if ($redirectUrl = $this->getRedirectUrl()) {
$this->redirect($redirectUrl);
} else {
$this->notify('success', __('filament-spatie-laravel-settings-plugin::pages/settings-page.messages.saved'));
$this->notify('success', $this->getSavedNotificationMessage());
}
}

protected function getSavedNotificationMessage(): string
{
return __('filament-spatie-laravel-settings-plugin::pages/settings-page.messages.saved');
}

protected function callHook(string $hook): void
{
if (! method_exists($this, $hook)) {
Expand Down

0 comments on commit 1e481fa

Please sign in to comment.