Browse Source

Improve manage table (select menu for actions and toggle all checkbox)

SABERES_37_STABLE
Johannes Burk 9 years ago
committed by test
parent
commit
8cb9ea0dfc
  1. 1
      amd/build/manage.min.js
  2. 38
      amd/src/manage.js
  3. 2
      lang/en/enrol_apply.php
  4. 19
      manage.php
  5. 2
      manage_table.php
  6. 36
      renderer.php
  7. 12
      style.css

1
amd/build/manage.min.js

@ -0,0 +1 @@
define(["jquery"],function(a){return{init:function(){a("#toggleall").on("change",function(){a('input[name="userenrolments[]"]').prop("checked",a("#toggleall").prop("checked"))}),a("#formaction").on("change",function(){a("#enrol_apply_manage_form").submit()})}}});

38
amd/src/manage.js

@ -0,0 +1,38 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* @package enrol_apply
* @copyright 2016 sudile GbR (http://www.sudile.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Johannes Burk <johannes.burk@sudile.com>
*/
/**
* @module enrol_apply/manage
*/
define(['jquery'], function($) {
return {
init: function() {
$('#toggleall').on('change', function() {
$('input[name="userenrolments[]"]').prop('checked', $('#toggleall').prop('checked'));
});
$('#formaction').on('change', function() {
$('#enrol_apply_manage_form').submit();
});
}
};
});

2
lang/en/enrol_apply.php

@ -61,7 +61,7 @@ $string['applyuser'] = 'First name / Surname';
$string['applyusermail'] = 'Email'; $string['applyusermail'] = 'Email';
$string['applydate'] = 'Enrol date'; $string['applydate'] = 'Enrol date';
$string['btnconfirm'] = 'Confirm requests'; $string['btnconfirm'] = 'Confirm requests';
$string['btnwait'] = 'put marked users on waiting list'; $string['btnwait'] = 'Defer requests';
$string['btncancel'] = 'Cancel requests'; $string['btncancel'] = 'Cancel requests';
$string['enrolusers'] = 'Enrol users'; $string['enrolusers'] = 'Enrol users';

19
manage.php

@ -28,6 +28,7 @@ require_once($CFG->dirroot.'/enrol/apply/manage_table.php');
require_once($CFG->dirroot.'/enrol/apply/renderer.php'); require_once($CFG->dirroot.'/enrol/apply/renderer.php');
$id = optional_param('id', null, PARAM_INT); $id = optional_param('id', null, PARAM_INT);
$formaction = optional_param('formaction', null, PARAM_TEXT);
$userenrolments = optional_param_array('userenrolments', null, PARAM_INT); $userenrolments = optional_param_array('userenrolments', null, PARAM_INT);
require_login(); require_login();
@ -57,14 +58,18 @@ $PAGE->navbar->add(get_string('confirmusers', 'enrol_apply'));
$PAGE->set_title(get_string('confirmusers', 'enrol_apply')); $PAGE->set_title(get_string('confirmusers', 'enrol_apply'));
$PAGE->requires->css('/enrol/apply/style.css'); $PAGE->requires->css('/enrol/apply/style.css');
if ($userenrolments != null) { if ($formaction != null && $userenrolments != null) {
$enrolapply = enrol_get_plugin('apply'); $enrolapply = enrol_get_plugin('apply');
if (optional_param('confirm', false, PARAM_BOOL)) { switch ($formaction) {
$enrolapply->confirm_enrolment($userenrolments); case 'confirm':
} else if (optional_param('wait', false, PARAM_BOOL)) { $enrolapply->confirm_enrolment($userenrolments);
$enrolapply->wait_enrolment($userenrolments); break;
} else if (optional_param('cancel', false, PARAM_BOOL)) { case 'wait':
$enrolapply->cancel_enrolment($userenrolments); $enrolapply->wait_enrolment($userenrolments);
break;
case 'cancel':
$enrolapply->cancel_enrolment($userenrolments);
break;
} }
redirect($manageurl); redirect($manageurl);
} }

2
manage_table.php

@ -55,6 +55,8 @@ class enrol_apply_manage_table extends table_sql {
JOIN {course} c ON c.id = e.courseid", JOIN {course} c ON c.id = e.courseid",
$sqlwhere, $sqlwhere,
$sqlparams); $sqlparams);
$this->no_sorting('checkboxcolumn');
} }
/** /**

36
renderer.php

@ -48,22 +48,24 @@ class enrol_apply_renderer extends plugin_renderer_base {
$this->manage_table($table); $this->manage_table($table);
echo html_writer::start_tag('p', array('align' => 'center')); if ($table->totalrows > 0) {
echo html_writer::empty_tag('br');
echo html_writer::empty_tag('input', array( echo html_writer::start_tag('div', array('class' => 'formaction'));
'type' => 'submit',
'name' => 'confirm', $formactions = array(
'value' => get_string('btnconfirm', 'enrol_apply'))); 'confirm' => get_string('btnconfirm', 'enrol_apply'),
echo html_writer::empty_tag('input', array( 'wait' => get_string('btnwait', 'enrol_apply'),
'type' => 'submit', 'cancel' => get_string('btncancel', 'enrol_apply'));
'name' => 'wait', echo html_writer::tag('label', get_string('withselectedusers'), array('for' => 'formaction'));
'value' => get_string('btnwait', 'enrol_apply'))); echo html_writer::select($formactions, 'formaction', '', array('' => 'choosedots'), array('id' => 'formaction'));
echo html_writer::empty_tag('input', array( echo html_writer::tag('noscript',
'type' => 'submit', html_writer::empty_tag('input', array('type' => 'submit', get_string('submit'))),
'name' => 'cancel', array('style' => 'display: inline;'));
'value' => get_string('btncancel', 'enrol_apply')));
echo html_writer::end_tag('div');
echo html_writer::end_tag('p');
$this->page->requires->js_call_amd('enrol_apply/manage', 'init');
}
echo html_writer::end_tag('form'); echo html_writer::end_tag('form');
} }
@ -76,7 +78,7 @@ class enrol_apply_renderer extends plugin_renderer_base {
'applydate', 'applydate',
'applycomment'); 'applycomment');
$headers = array( $headers = array(
'', html_writer::checkbox('toggleall', 'toggleall', false, '', array('id' => 'toggleall')),
get_string('course'), get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'. 'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'), get_string('email'),

12
style.css

@ -1,3 +1,11 @@
.enrol_apply_waitinglist_highlight { form#enrol_apply_manage_form tr {
border-left: 6px solid grey; border-left: 3px solid transparent;
}
form#enrol_apply_manage_form tr.enrol_apply_waitinglist_highlight {
border-color: grey;
}
.formaction {
text-align: center;
} }

Loading…
Cancel
Save