mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 18:04:43 +02:00
MDL-65933 mod_data: Use new core/checkbox_toggleall
This commit is contained in:
parent
414eca8923
commit
e274f1b29e
@ -1448,7 +1448,13 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r
|
||||
|
||||
$patterns[]='##delcheck##';
|
||||
if ($canmanageentries) {
|
||||
$replacement[] = html_writer::checkbox('delcheck[]', $record->id, false, '', array('class' => 'recordcheckbox'));
|
||||
$checkbox = new \core\output\checkbox_toggleall('listview-entries', false, [
|
||||
'id' => "entry_{$record->id}",
|
||||
'name' => 'delcheck[]',
|
||||
'class' => 'recordcheckbox',
|
||||
'value' => $record->id,
|
||||
]);
|
||||
$replacement[] = $OUTPUT->render($checkbox);
|
||||
} else {
|
||||
$replacement[] = '';
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
M.mod_data = {};
|
||||
|
||||
M.mod_data.init_view = function(Y) {
|
||||
Y.on('click', function(e) {
|
||||
Y.all('input.recordcheckbox').each(function() {
|
||||
this.set('checked', 'checked');
|
||||
});
|
||||
}, '#checkall');
|
||||
|
||||
Y.on('click', function(e) {
|
||||
Y.all('input.recordcheckbox').each(function() {
|
||||
this.set('checked', '');
|
||||
});
|
||||
}, '#checknone');
|
||||
};
|
@ -508,27 +508,28 @@ if ($showactivity) {
|
||||
}
|
||||
|
||||
if ($mode != 'single' && $canmanageentries) {
|
||||
echo html_writer::empty_tag('input', array(
|
||||
'type' => 'button',
|
||||
'id' => 'checkall',
|
||||
'value' => get_string('selectall'),
|
||||
'class' => 'btn btn-secondary mr-1'
|
||||
));
|
||||
echo html_writer::empty_tag('input', array(
|
||||
'type' => 'button',
|
||||
'id' => 'checknone',
|
||||
'value' => get_string('deselectall'),
|
||||
'class' => 'btn btn-secondary mr-1'
|
||||
));
|
||||
echo html_writer::empty_tag('input', array(
|
||||
'class' => 'form-submit',
|
||||
'type' => 'submit',
|
||||
'value' => get_string('deleteselected'),
|
||||
'class' => 'btn btn-secondary mr-1'
|
||||
));
|
||||
// Build the select/deselect all control.
|
||||
$selectallid = 'selectall-listview-entries';
|
||||
$togglegroup = 'listview-entries';
|
||||
$mastercheckbox = new \core\output\checkbox_toggleall($togglegroup, true, [
|
||||
'id' => $selectallid,
|
||||
'name' => $selectallid,
|
||||
'value' => 1,
|
||||
'label' => get_string('selectall'),
|
||||
'classes' => 'mr-1',
|
||||
], true);
|
||||
echo $OUTPUT->render($mastercheckbox);
|
||||
|
||||
$module = array('name' => 'mod_data', 'fullpath' => '/mod/data/module.js');
|
||||
$PAGE->requires->js_init_call('M.mod_data.init_view', null, false, $module);
|
||||
$deleteselected = html_writer::empty_tag('input', array(
|
||||
'class' => 'btn btn-secondary',
|
||||
'type' => 'submit',
|
||||
'value' => get_string('deleteselected'),
|
||||
'disabled' => true,
|
||||
'data-action' => 'toggle',
|
||||
'data-togglegroup' => $togglegroup,
|
||||
'data-toggle' => 'action',
|
||||
));
|
||||
echo $deleteselected;
|
||||
}
|
||||
|
||||
echo html_writer::end_tag('form');
|
||||
|
Loading…
x
Reference in New Issue
Block a user