Skip to content

Commit 181796c

Browse files
committed
Display an alert message if the record being deleted has child records
1 parent b3ed685 commit 181796c

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

resources/lang/en/filament-tree.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,11 @@
2121
'components.tree.buttons.deselect_all.label' => 'Deselect All',
2222
'components.tree.buttons.expand_all.label' => 'Expand All',
2323
'components.tree.buttons.collapse_all.label' => 'Collapse All',
24+
25+
/*
26+
|--------------------------------------------------------------------------
27+
| Message
28+
|--------------------------------------------------------------------------
29+
*/
30+
'actions.delete.confirmation.with_children' => 'Are you sure delete this record and its children?',
2431
];

resources/lang/zh-HK/filament-tree.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121
'components.tree.buttons.deselect_all.label' => '取消全選',
2222
'components.tree.buttons.expand_all.label' => '全部展開',
2323
'components.tree.buttons.collapse_all.label' => '全部折叠',
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Message
27+
|--------------------------------------------------------------------------
28+
*/
29+
'actions.delete.confirmation.with_children' => '你確定要刪除這條記錄及其子記錄嗎?',
2430
];

resources/lang/zh-Hant/filament-tree.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121
'components.tree.buttons.deselect_all.label' => '取消全選',
2222
'components.tree.buttons.expand_all.label' => '全部展開',
2323
'components.tree.buttons.collapse_all.label' => '全部折叠',
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Message
27+
|--------------------------------------------------------------------------
28+
*/
29+
'actions.delete.confirmation.with_children' => '你確定要刪除這條記錄及其子記錄嗎?',
2430
];

resources/lang/zh/filament-tree.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,11 @@
2020
'components.tree.buttons.select_all.label' => '选择全部',
2121
'components.tree.buttons.deselect_all.label' => '取消全选',
2222
'components.tree.buttons.expand_all.label' => '全部展开',
23-
'components.tree.buttons.collapse_all.label' => '全部折叠',
23+
'components.tree.buttons.collapse_all.label' => '全部折叠',
24+
/*
25+
|--------------------------------------------------------------------------
26+
| Message
27+
|--------------------------------------------------------------------------
28+
*/
29+
'actions.delete.confirmation.with_children' => '你确定要删除这条记录及其子记录吗?',
2430
];

src/Actions/DeleteAction.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ protected function setUp(): void
2222

2323
$this->modalHeading(fn (): string => __('filament-support::actions/delete.single.modal.heading', ['label' => $this->getRecordTitle()]));
2424

25-
2625
$this->successNotificationTitle(__('filament-support::actions/delete.single.messages.deleted'));
2726

2827
$this->color('danger');
@@ -33,6 +32,16 @@ protected function setUp(): void
3332

3433
$this->requiresConfirmation();
3534

35+
$this->modalSubheading(function (Model $record) {
36+
if (collect($record->children)->isNotEmpty()) {
37+
return __('filament-tree::filament-tree.actions.delete.confirmation.with_children');
38+
39+
} else {
40+
return __('filament-support::actions/modal.confirmation');
41+
42+
}
43+
});
44+
3645
$this->hidden(static function (Model $record): bool {
3746
if (! method_exists($record, 'trashed')) {
3847
return false;

0 commit comments

Comments
 (0)