From e773533258c7cd3206977fac52e5ed92ac71f425 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Thu, 14 Mar 2019 12:32:09 +0800 Subject: [PATCH] MDL-65949 report_participation: Use new core/checkbox-toggleall --- lang/en/moodle.php | 1 + report/participation/index.php | 42 ++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lang/en/moodle.php b/lang/en/moodle.php index 668823bfcdaea..2f4981c6efea2 100644 --- a/lang/en/moodle.php +++ b/lang/en/moodle.php @@ -505,6 +505,7 @@ $string['description'] = 'Description'; $string['descriptiona'] = 'Description: {$a}'; $string['deselectall'] = 'Deselect all'; +$string['deselectnos'] = 'Deselect all \'No\''; $string['detailedless'] = 'Less detailed'; $string['detailedmore'] = 'More detailed'; $string['digitalminor'] = 'Digital minor'; diff --git a/report/participation/index.php b/report/participation/index.php index 9708951c6cf21..2688e3ba6cf45 100644 --- a/report/participation/index.php +++ b/report/participation/index.php @@ -152,7 +152,15 @@ $table->define_headers(array(get_string('user'), $actionheader)); } else { $table->define_columns(array('fullname', 'count', 'select')); - $table->define_headers(array(get_string('user'), $actionheader, get_string('select'))); + $mastercheckbox = new \core\output\checkbox_toggleall('participants-table', true, [ + 'id' => 'select-all-participants', + 'name' => 'select-all-participants', + 'label' => get_string('select'), + // Consistent labels to prevent select column from resizing. + 'selectall' => get_string('select'), + 'deselectall' => get_string('select'), + ]); + $table->define_headers(array(get_string('user'), $actionheader, $OUTPUT->render($mastercheckbox))); } $table->define_baseurl($baseurl); @@ -317,7 +325,16 @@ $data[] = !empty($u->count) ? get_string('yes').' ('.$u->count.') ' : get_string('no'); if (!empty($CFG->messaging)) { - $data[] = ''; + $togglegroup = 'participants-table'; + if (empty($u->count)) { + $togglegroup .= ' no'; + } + $checkbox = new \core\output\checkbox_toggleall($togglegroup, false, [ + 'classes' => 'usercheckbox', + 'name' => 'user' . $u->userid, + 'value' => $u->count, + ]); + $data[] = $OUTPUT->render($checkbox); } $table->add_data($data); } @@ -337,18 +354,29 @@ } if (!empty($CFG->messaging)) { - $buttonclasses = 'btn btn-secondary'; echo '
'; - echo ' '."\n"; - echo ' '."\n"; if ($perpage >= $matchcount) { - echo ''."\n"; + $checknos = new \core\output\checkbox_toggleall('participants-table no', true, [ + 'id' => 'select-nos', + 'name' => 'select-nos', + 'label' => get_string('selectnos'), + 'selectall' => get_string('selectnos'), + 'deselectall' => get_string('deselectnos'), + ], true); + echo $OUTPUT->render($checknos); } echo '
'; echo '
'; echo html_writer::label(get_string('withselectedusers'), 'formactionselect'); $displaylist['#messageselect'] = get_string('messageselectadd'); - echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), array('id' => 'formactionid')); + $withselectedparams = array( + 'id' => 'formactionid', + 'data-action' => 'toggle', + 'data-togglegroup' => 'participants-table', + 'data-toggle' => 'action', + 'disabled' => true + ); + echo html_writer::select($displaylist, 'formaction', '', array('' => 'choosedots'), $withselectedparams); echo '
'; echo ''."\n"; echo ''."\n";