diff --git a/admin/tool/monitor/classes/rule_form.php b/admin/tool/monitor/classes/rule_form.php index 99b3c8de892..66d59f6eac2 100644 --- a/admin/tool/monitor/classes/rule_form.php +++ b/admin/tool/monitor/classes/rule_form.php @@ -46,8 +46,6 @@ class rule_form extends \moodleform { $pluginlist = $this->_customdata['pluginlist']; $rule = $this->_customdata['rule']; $courseid = $this->_customdata['courseid']; - $eventlist = array_merge(array('' => get_string('choosedots')), $eventlist); - $pluginlist = array_merge(array('' => get_string('choosedots')), $pluginlist); // General section header. $mform->addElement('header', 'general', get_string('general')); diff --git a/admin/tool/monitor/edit.php b/admin/tool/monitor/edit.php index 8722da35d2d..c69e92e0620 100644 --- a/admin/tool/monitor/edit.php +++ b/admin/tool/monitor/edit.php @@ -55,7 +55,16 @@ $PAGE->set_url($url); $PAGE->set_pagelayout('report'); $PAGE->set_title($title); $PAGE->set_heading($title); -$PAGE->requires->yui_module('moodle-tool_monitor-dropdown', 'Y.M.tool_monitor.DropDown.init'); + +// Get data ready for mform. +$eventlist = tool_monitor\eventlist::get_all_eventlist(true); +$pluginlist = tool_monitor\eventlist::get_plugin_list(); +$eventlist = array_merge(array('' => get_string('choosedots')), $eventlist); +$pluginlist = array_merge(array('' => get_string('choosedots')), $pluginlist); + +// Set up the yui module. +$PAGE->requires->yui_module('moodle-tool_monitor-dropdown', 'Y.M.tool_monitor.DropDown.init', + array(array('eventlist' => $eventlist))); // Site level report. if (empty($courseid)) { @@ -65,9 +74,7 @@ if (empty($courseid)) { $PAGE->navigation->override_active_url($manageurl); } -// Get data ready for mform. -$eventlist = tool_monitor\eventlist::get_all_eventlist(true); -$pluginlist = tool_monitor\eventlist::get_plugin_list(); +// Mform setup. if (!empty($ruleid)) { $rule = \tool_monitor\rule_manager::get_rule($ruleid)->get_mform_set_data(); $rule->minutes = $rule->timewindow / MINSECS; diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js index 992c45be5b4..79184dd7bc1 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-debug.js @@ -66,22 +66,38 @@ Y.extend(DropDown, Y.Base, { * @method updateEventsList */ updateEventsList: function() { + var node, options, choosenode; var plugin = this.plugin.get('value'); // Get component name. var namespace = '\\' + plugin + '\\'; - this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options. - this.eventname.all(SELECTORS.OPTION).each(function(node) { - // Make sure we highlight only nodes with correct namespace. - if (node.get('value').substring(0, namespace.length) === namespace) { - node.show(); - } - }); + this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes. + options = this.get('eventlist'); + // Mark the default choose node as visible and selected. - var choosenode = this.eventname.one(SELECTORS.CHOOSE); - choosenode.show().set('selected', 'selected'); + choosenode = Y.Node.create(''); + choosenode.set('selected', 'selected'); + this.eventname.appendChild(choosenode); + + Y.Object.each(options, function(value, key) { + // Make sure we highlight only nodes with correct namespace. + if (key.substring(0, namespace.length) === namespace) { + node = Y.Node.create(''); + this.eventname.appendChild(node); + } + }, this); + } }, { NAME: 'dropDown', - ATTRS: {} + ATTRS: { + /** + * A list of events with components. + * + * @attribute eventlist + * @default null + * @type Object + */ + eventlist: null + } }); Y.namespace('M.tool_monitor.DropDown').init = function(config) { diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js index a95a95e6f06..c62a01318d7 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown-min.js @@ -1 +1 @@ -YUI.add("moodle-tool_monitor-dropdown",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r={PLUGIN:"#id_plugin",EVENTNAME:"#id_eventname",OPTION:"option",CHOOSE:'option[value=""]'};e.extend(n,e.Base,{plugin:null,eventname:null,initializer:function(){this.plugin=e.one(r.PLUGIN),this.eventname=e.one(r.EVENTNAME),this.plugin.on("change",this.updateEventsList,this)},updateEventsList:function(){var e=this.plugin.get("value"),t="\\"+e+"\\";this.eventname.all(r.OPTION).hide(),this.eventname.all(r.OPTION).each(function(e){e.get("value").substring(0,t.length)===t&&e.show()});var n=this.eventname.one(r.CHOOSE);n.show().set("selected","selected")}},{NAME:"dropDown",ATTRS:{}}),e.namespace("M.tool_monitor.DropDown").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","event","node"]}); +YUI.add("moodle-tool_monitor-dropdown",function(e,t){function n(){n.superclass.constructor.apply(this,arguments)}var r={PLUGIN:"#id_plugin",EVENTNAME:"#id_eventname",OPTION:"option",CHOOSE:'option[value=""]'};e.extend(n,e.Base,{plugin:null,eventname:null,initializer:function(){this.plugin=e.one(r.PLUGIN),this.eventname=e.one(r.EVENTNAME),this.plugin.on("change",this.updateEventsList,this)},updateEventsList:function(){var t,n,i,s=this.plugin.get("value"),o="\\"+s+"\\";this.eventname.all(r.OPTION).remove(!0),n=this.get("eventlist"),i=e.Node.create('"),i.set("selected","selected"),this.eventname.appendChild(i),e.Object.each(n,function(n,r){r.substring(0,o.length)===o&&(t=e.Node.create('"),this.eventname.appendChild(t))},this)}},{NAME:"dropDown",ATTRS:{eventlist:null}}),e.namespace("M.tool_monitor.DropDown").init=function(e){return new n(e)}},"@VERSION@",{requires:["base","event","node"]}); diff --git a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js index 992c45be5b4..79184dd7bc1 100644 --- a/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js +++ b/admin/tool/monitor/yui/build/moodle-tool_monitor-dropdown/moodle-tool_monitor-dropdown.js @@ -66,22 +66,38 @@ Y.extend(DropDown, Y.Base, { * @method updateEventsList */ updateEventsList: function() { + var node, options, choosenode; var plugin = this.plugin.get('value'); // Get component name. var namespace = '\\' + plugin + '\\'; - this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options. - this.eventname.all(SELECTORS.OPTION).each(function(node) { - // Make sure we highlight only nodes with correct namespace. - if (node.get('value').substring(0, namespace.length) === namespace) { - node.show(); - } - }); + this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes. + options = this.get('eventlist'); + // Mark the default choose node as visible and selected. - var choosenode = this.eventname.one(SELECTORS.CHOOSE); - choosenode.show().set('selected', 'selected'); + choosenode = Y.Node.create(''); + choosenode.set('selected', 'selected'); + this.eventname.appendChild(choosenode); + + Y.Object.each(options, function(value, key) { + // Make sure we highlight only nodes with correct namespace. + if (key.substring(0, namespace.length) === namespace) { + node = Y.Node.create(''); + this.eventname.appendChild(node); + } + }, this); + } }, { NAME: 'dropDown', - ATTRS: {} + ATTRS: { + /** + * A list of events with components. + * + * @attribute eventlist + * @default null + * @type Object + */ + eventlist: null + } }); Y.namespace('M.tool_monitor.DropDown').init = function(config) { diff --git a/admin/tool/monitor/yui/src/dropdown/js/dropdown.js b/admin/tool/monitor/yui/src/dropdown/js/dropdown.js index 00a53764e49..ff839b6ec42 100644 --- a/admin/tool/monitor/yui/src/dropdown/js/dropdown.js +++ b/admin/tool/monitor/yui/src/dropdown/js/dropdown.js @@ -64,22 +64,38 @@ Y.extend(DropDown, Y.Base, { * @method updateEventsList */ updateEventsList: function() { + var node, options, choosenode; var plugin = this.plugin.get('value'); // Get component name. var namespace = '\\' + plugin + '\\'; - this.eventname.all(SELECTORS.OPTION).hide(); // Hide all options. - this.eventname.all(SELECTORS.OPTION).each(function(node) { - // Make sure we highlight only nodes with correct namespace. - if (node.get('value').substring(0, namespace.length) === namespace) { - node.show(); - } - }); + this.eventname.all(SELECTORS.OPTION).remove(true); // Delete all nodes. + options = this.get('eventlist'); + // Mark the default choose node as visible and selected. - var choosenode = this.eventname.one(SELECTORS.CHOOSE); - choosenode.show().set('selected', 'selected'); + choosenode = Y.Node.create(''); + choosenode.set('selected', 'selected'); + this.eventname.appendChild(choosenode); + + Y.Object.each(options, function(value, key) { + // Make sure we highlight only nodes with correct namespace. + if (key.substring(0, namespace.length) === namespace) { + node = Y.Node.create(''); + this.eventname.appendChild(node); + } + }, this); + } }, { NAME: 'dropDown', - ATTRS: {} + ATTRS: { + /** + * A list of events with components. + * + * @attribute eventlist + * @default null + * @type Object + */ + eventlist: null + } }); Y.namespace('M.tool_monitor.DropDown').init = function(config) {