Make it possible to exclude admin groups from groups select2

This commit is contained in:
Vincent Petry 2016-05-20 10:15:07 +02:00
parent 8fbb63d316
commit 79f6b7b7ff
No known key found for this signature in database
GPG Key ID: AF8F9EFC56562186
1 changed files with 10 additions and 5 deletions

View File

@ -16,10 +16,13 @@ OC.Settings = _.extend(OC.Settings, {
* for groups)
*
* @param $elements jQuery element (hidden input) to setup select2 on
* @param [extraOptions] extra options hash to pass to select2
* @param {Array} [extraOptions] extra options hash to pass to select2
* @param {Array} [options] extra options
* @param {Array} [options.excludeAdmins=false] flag whether to exclude admin groups
*/
setupGroupsSelect: function($elements, extraOptions) {
setupGroupsSelect: function($elements, extraOptions, options) {
var self = this;
options = options || {};
if ($elements.length > 0) {
// note: settings are saved through a "change" event registered
// on all input fields
@ -48,9 +51,11 @@ OC.Settings = _.extend(OC.Settings, {
var results = [];
// add groups
$.each(data.data.adminGroups, function(i, group) {
results.push({id:group.id, displayname:group.name});
});
if (!options.excludeAdmins) {
$.each(data.data.adminGroups, function(i, group) {
results.push({id:group.id, displayname:group.name});
});
}
$.each(data.data.groups, function(i, group) {
results.push({id:group.id, displayname:group.name});
});