MDL-84548 mod_qbank: Let delete bulk action set text-danger class.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
issueNumber: MDL-84548
|
||||
notes:
|
||||
mod_qbank:
|
||||
- message: >
|
||||
The bulk_action_base class has gotten a get_bulk_action_classes function
|
||||
to let bulk actions specify additional classes to add to the bulk action
|
||||
menu entry. If none is defined in the child, '' is returned.
|
||||
type: changed
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -56,7 +56,7 @@ export default class ModalQuestionBankBulkmove extends Modal {
|
||||
static init(contextId, categoryId) {
|
||||
document.addEventListener('click', (e) => {
|
||||
const trigger = e.target;
|
||||
if (trigger.className === 'dropdown-item' && trigger.getAttribute('name') === 'move') {
|
||||
if (trigger.classList.contains('dropdown-item') && trigger.getAttribute('name') === 'move') {
|
||||
e.preventDefault();
|
||||
ModalQuestionBankBulkmove.create({
|
||||
contextId,
|
||||
|
||||
@@ -44,6 +44,11 @@ class bulk_delete_action extends \core_question\local\bank\bulk_action_base {
|
||||
return new \moodle_url('/question/bank/deletequestion/delete.php', $params);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public function get_bulk_action_classes(): string {
|
||||
return 'text-danger';
|
||||
}
|
||||
|
||||
public function get_bulk_action_capabilities(): ?array {
|
||||
return [
|
||||
'moodle/question:editall',
|
||||
|
||||
@@ -69,6 +69,18 @@ abstract class bulk_action_base extends view_component {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the classes of the bulk action menu entry.
|
||||
*
|
||||
* If a bulk action needs to have some classes to be added to the entry to show in the list,
|
||||
* return them with this method.
|
||||
*
|
||||
* @return string For ex: 'text-danger'.
|
||||
*/
|
||||
public function get_bulk_action_classes(): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Override if you want to load your own javascript.
|
||||
*
|
||||
|
||||
@@ -1202,6 +1202,7 @@ class view {
|
||||
$actiondata->actionname = $action->get_bulk_action_title();
|
||||
$actiondata->actionkey = $key;
|
||||
$actiondata->actionurl = new \moodle_url($action->get_bulk_action_url(), $params);
|
||||
$actiondata->actionclasses = $action->get_bulk_action_classes();
|
||||
$bulkactiondata[] = $actiondata;
|
||||
|
||||
$bulkactiondatas ['bulkactionitems'] = $bulkactiondata;
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
"bulkactionitems": "<input value='Move to'>",
|
||||
"actionname": "Move to",
|
||||
"actionkey": "deleteselected",
|
||||
"actionurl": "/question/bank/bulkmove/move.php?courseid=2"
|
||||
"actionurl": "/question/bank/bulkmove/move.php?courseid=2",
|
||||
"actionclasses": "text-danger"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -36,7 +37,7 @@
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="bulkactionsui-selector">
|
||||
{{#bulkactionitems}}
|
||||
<input type="submit" value="{{actionname}}" class="dropdown-item" name="{{actionkey}}" data-action="toggle" data-togglegroup="qbank"
|
||||
<input type="submit" value="{{actionname}}" class="dropdown-item {{actionclasses}}" name="{{actionkey}}" data-action="toggle" data-togglegroup="qbank"
|
||||
data-toggle="action" form="questionsubmit" formaction="{{{actionurl}}}" disabled="disabled">
|
||||
{{/bulkactionitems}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user