MDL-68463 report_participants: Use new shared participant actions module
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
define ("report_participation/participants",["exports","jquery","core/custom_interaction_events","core/modal_events","core/notification","core_user/local/participants/bulkactions"],function(a,b,c,d,e,f){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=g(b);c=g(c);d=g(d);e=g(e);function g(a){return a&&a.__esModule?a:{default:a}}var h={bulkActionSelect:"#formactionid",bulkUserSelectedCheckBoxes:"input[data-togglegroup^='participants-table']:checked",participantsForm:"#participantsform"};a.init=function init(){var a=document.querySelector(h.participantsForm),g=function(){c.default.define(h.bulkActionSelect,[c.default.events.accessibleChange]);(0,b.default)(h.bulkActionSelect).on(c.default.events.accessibleChange,function(b){var c=b.target.value,g=a.querySelectorAll(h.bulkUserSelectedCheckBoxes);if(-1!==c.indexOf("#")){b.preventDefault();var j=[];g.forEach(function(a){j.push(a.getAttribute("name").replace("user",""))});if("#messageselect"===c){(0,f.showSendMessage)(j).then(function(b){b.getRoot().on(d.default.hidden,function(){var b=a.querySelector(h.bulkActionSelect);i(b);b.focus()});return b}).catch(e.default.exception)}}else if(""!==c&&g.length){b.target.form().submit()}i(b.target)})},i=function(a){a.value=""};g()}});
|
||||
//# sourceMappingURL=participants.min.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,88 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Some UI stuff for participants page.
|
||||
* This is also used by the report/participants/index.php because it has the same functionality.
|
||||
*
|
||||
* @module core_user/participants
|
||||
* @package core_user
|
||||
* @copyright 2017 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import jQuery from 'jquery';
|
||||
import CustomEvents from 'core/custom_interaction_events';
|
||||
import ModalEvents from 'core/modal_events';
|
||||
import Notification from 'core/notification';
|
||||
import {showSendMessage} from 'core_user/local/participants/bulkactions';
|
||||
|
||||
const Selectors = {
|
||||
bulkActionSelect: "#formactionid",
|
||||
bulkUserSelectedCheckBoxes: "input[data-togglegroup^='participants-table']:checked",
|
||||
participantsForm: '#participantsform',
|
||||
};
|
||||
|
||||
export const init = () => {
|
||||
const root = document.querySelector(Selectors.participantsForm);
|
||||
|
||||
/**
|
||||
* Private method.
|
||||
*
|
||||
* @method registerEventListeners
|
||||
* @private
|
||||
*/
|
||||
const registerEventListeners = () => {
|
||||
CustomEvents.define(Selectors.bulkActionSelect, [CustomEvents.events.accessibleChange]);
|
||||
jQuery(Selectors.bulkActionSelect).on(CustomEvents.events.accessibleChange, e => {
|
||||
const action = e.target.value;
|
||||
const checkboxes = root.querySelectorAll(Selectors.bulkUserSelectedCheckBoxes);
|
||||
|
||||
if (action.indexOf('#') !== -1) {
|
||||
e.preventDefault();
|
||||
|
||||
const ids = [];
|
||||
checkboxes.forEach(checkbox => {
|
||||
ids.push(checkbox.getAttribute('name').replace('user', ''));
|
||||
});
|
||||
|
||||
if (action === '#messageselect') {
|
||||
showSendMessage(ids)
|
||||
.then(modal => {
|
||||
modal.getRoot().on(ModalEvents.hidden, () => {
|
||||
// Focus on the action select when the dialog is closed.
|
||||
const bulkActionSelector = root.querySelector(Selectors.bulkActionSelect);
|
||||
resetBulkAction(bulkActionSelector);
|
||||
bulkActionSelector.focus();
|
||||
});
|
||||
|
||||
return modal;
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
}
|
||||
} else if (action !== '' && checkboxes.length) {
|
||||
e.target.form().submit();
|
||||
}
|
||||
|
||||
resetBulkAction(e.target);
|
||||
});
|
||||
};
|
||||
|
||||
const resetBulkAction = bulkActionSelect => {
|
||||
bulkActionSelect.value = '';
|
||||
};
|
||||
|
||||
registerEventListeners();
|
||||
};
|
||||
@@ -385,7 +385,7 @@ if (!empty($instanceid) && !empty($roleid)) {
|
||||
$options->courseid = $course->id;
|
||||
$options->noteStateNames = note_get_state_names();
|
||||
$options->stateHelpIcon = $OUTPUT->help_icon('publishstate', 'notes');
|
||||
$PAGE->requires->js_call_amd('core_user/participants', 'init', [$options]);
|
||||
$PAGE->requires->js_call_amd('report_participation/participants', 'init', [$options]);
|
||||
}
|
||||
echo '</div>'."\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user