Davo Smith
10 years ago
11 changed files with 248 additions and 3 deletions
@ -0,0 +1,45 @@ |
|||
YUI.add('moodle-mod_attendance-groupfilter', function (Y, NAME) { |
|||
|
|||
/*global M*/ |
|||
M.mod_attendance = M.mod_attendance || {}; |
|||
M.mod_attendance.groupfilter = { |
|||
groupmappings: null, |
|||
|
|||
init: function(opts) { |
|||
"use strict"; |
|||
|
|||
this.groupmappings = opts.groupmappings; |
|||
Y.one('#id_group').after('change', this.update_user_list, this); |
|||
}, |
|||
|
|||
/** |
|||
* Update the user list with those found in the selected group. |
|||
*/ |
|||
update_user_list: function() { |
|||
"use strict"; |
|||
var groupid, userlist, users, userid, opt; |
|||
|
|||
// Get the list of users in the current group.
|
|||
groupid = Y.one('#id_group').get('value'); |
|||
users = this.groupmappings[groupid]; |
|||
|
|||
// Remove the options from the users select.
|
|||
userlist = Y.one('#id_users'); |
|||
userlist.get('options').remove(); |
|||
|
|||
// Repopulate the users select with those users in the selected group (if any).
|
|||
if (users !== undefined) { |
|||
for (userid in users) { |
|||
if (users.hasOwnProperty(userid)) { |
|||
opt = Y.Node.create('<option></option>'); |
|||
opt.set('value', userid); |
|||
opt.set('text', users[userid]); |
|||
userlist.appendChild(opt); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
|
|||
}, '@VERSION@', {"requires": ["base", "node"]}); |
@ -0,0 +1 @@ |
|||
YUI.add("moodle-mod_attendance-groupfilter",function(e,t){M.mod_attendance=M.mod_attendance||{},M.mod_attendance.groupfilter={groupmappings:null,init:function(t){"use strict";this.groupmappings=t.groupmappings,e.one("#id_group").after("change",this.update_user_list,this)},update_user_list:function(){"use strict";var t,n,r,i,s;t=e.one("#id_group").get("value"),r=this.groupmappings[t],n=e.one("#id_users"),n.get("options").remove();if(r!==undefined)for(i in r)r.hasOwnProperty(i)&&(s=e.Node.create("<option></option>"),s.set("value",i),s.set("text",r[i]),n.appendChild(s))}}},"@VERSION@",{requires:["base","node"]}); |
@ -0,0 +1,45 @@ |
|||
YUI.add('moodle-mod_attendance-groupfilter', function (Y, NAME) { |
|||
|
|||
/*global M*/ |
|||
M.mod_attendance = M.mod_attendance || {}; |
|||
M.mod_attendance.groupfilter = { |
|||
groupmappings: null, |
|||
|
|||
init: function(opts) { |
|||
"use strict"; |
|||
|
|||
this.groupmappings = opts.groupmappings; |
|||
Y.one('#id_group').after('change', this.update_user_list, this); |
|||
}, |
|||
|
|||
/** |
|||
* Update the user list with those found in the selected group. |
|||
*/ |
|||
update_user_list: function() { |
|||
"use strict"; |
|||
var groupid, userlist, users, userid, opt; |
|||
|
|||
// Get the list of users in the current group.
|
|||
groupid = Y.one('#id_group').get('value'); |
|||
users = this.groupmappings[groupid]; |
|||
|
|||
// Remove the options from the users select.
|
|||
userlist = Y.one('#id_users'); |
|||
userlist.get('options').remove(); |
|||
|
|||
// Repopulate the users select with those users in the selected group (if any).
|
|||
if (users !== undefined) { |
|||
for (userid in users) { |
|||
if (users.hasOwnProperty(userid)) { |
|||
opt = Y.Node.create('<option></option>'); |
|||
opt.set('value', userid); |
|||
opt.set('text', users[userid]); |
|||
userlist.appendChild(opt); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
|
|||
}, '@VERSION@', {"requires": ["base", "node"]}); |
@ -0,0 +1,10 @@ |
|||
{ |
|||
"name": "moodle-mod_attendance-groupfilter", |
|||
"builds": { |
|||
"moodle-mod_attendance-groupfilter": { |
|||
"jsfiles": [ |
|||
"groupfilter.js" |
|||
] |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,40 @@ |
|||
/*global M*/ |
|||
M.mod_attendance = M.mod_attendance || {}; |
|||
M.mod_attendance.groupfilter = { |
|||
groupmappings: null, |
|||
|
|||
init: function(opts) { |
|||
"use strict"; |
|||
|
|||
this.groupmappings = opts.groupmappings; |
|||
Y.one('#id_group').after('change', this.update_user_list, this); |
|||
}, |
|||
|
|||
/** |
|||
* Update the user list with those found in the selected group. |
|||
*/ |
|||
update_user_list: function() { |
|||
"use strict"; |
|||
var groupid, userlist, users, userid, opt; |
|||
|
|||
// Get the list of users in the current group.
|
|||
groupid = Y.one('#id_group').get('value'); |
|||
users = this.groupmappings[groupid]; |
|||
|
|||
// Remove the options from the users select.
|
|||
userlist = Y.one('#id_users'); |
|||
userlist.get('options').remove(); |
|||
|
|||
// Repopulate the users select with those users in the selected group (if any).
|
|||
if (users !== undefined) { |
|||
for (userid in users) { |
|||
if (users.hasOwnProperty(userid)) { |
|||
opt = Y.Node.create('<option></option>'); |
|||
opt.set('value', userid); |
|||
opt.set('text', users[userid]); |
|||
userlist.appendChild(opt); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}; |
@ -0,0 +1,8 @@ |
|||
{ |
|||
"moodle-mod_attendance-groupfilter": { |
|||
"requires": [ |
|||
"base", |
|||
"node" |
|||
] |
|||
} |
|||
} |
Loading…
Reference in new issue