mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Allow customised deletion messages in lists
Provides the ability for developers to specify a custom message for bulk deletion actions, as well as a custom message when no records could be deleted due to missing selections or an altered query not finding any applicable records.
This commit is contained in:
parent
5d0988559b
commit
00849268ed
@ -297,16 +297,6 @@ class ListController extends ControllerBehavior
|
||||
return call_user_func_array([$this->controller, 'onDelete'], func_get_args());
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate checked identifiers
|
||||
*/
|
||||
$checkedIds = post('checked');
|
||||
|
||||
if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
|
||||
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
|
||||
return $this->controller->listRefresh();
|
||||
}
|
||||
|
||||
/*
|
||||
* Establish the list definition
|
||||
*/
|
||||
@ -318,6 +308,20 @@ class ListController extends ControllerBehavior
|
||||
|
||||
$listConfig = $this->controller->listGetConfig($definition);
|
||||
|
||||
/*
|
||||
* Validate checked identifiers
|
||||
*/
|
||||
$checkedIds = post('checked');
|
||||
|
||||
if (!$checkedIds || !is_array($checkedIds) || !count($checkedIds)) {
|
||||
Flash::error(Lang::get(
|
||||
(!empty($listConfig->noRecordsDeletedMessage))
|
||||
? $listConfig->noRecordsDeletedMessage
|
||||
: 'backend::lang.list.delete_selected_empty'
|
||||
));
|
||||
return $this->controller->listRefresh();
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the model
|
||||
*/
|
||||
@ -344,10 +348,18 @@ class ListController extends ControllerBehavior
|
||||
$record->delete();
|
||||
}
|
||||
|
||||
Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
|
||||
Flash::success(Lang::get(
|
||||
(!empty($listConfig->deleteMessage))
|
||||
? $listConfig->deleteMessage
|
||||
: 'backend::lang.list.delete_selected_success'
|
||||
));
|
||||
}
|
||||
else {
|
||||
Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
|
||||
Flash::error(Lang::get(
|
||||
(!empty($listConfig->noRecordsDeletedMessage))
|
||||
? $listConfig->noRecordsDeletedMessage
|
||||
: 'backend::lang.list.delete_selected_empty'
|
||||
));
|
||||
}
|
||||
|
||||
return $this->controller->listRefresh($definition);
|
||||
|
Loading…
x
Reference in New Issue
Block a user