MDL-65933 mod_data: Use new core/checkbox_toggleall

This commit is contained in:
Jun Pataleta 2017-12-21 14:23:01 +13:00
parent 414eca8923
commit e274f1b29e
3 changed files with 28 additions and 36 deletions

View File

@ -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[] = '';
}

View File

@ -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');
};

View File

@ -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');