summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/workflowengine/js/admin.js7
-rw-r--r--apps/workflowengine/js/usergroupmembershipplugin.js2
-rw-r--r--settings/js/settings.js121
3 files changed, 63 insertions, 67 deletions
diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js
index d31add77ef4..891e50c4189 100644
--- a/apps/workflowengine/js/admin.js
+++ b/apps/workflowengine/js/admin.js
@@ -167,7 +167,7 @@
url: OC.generateUrl('settings/users/groups'),
dataType: 'json',
quietMillis: 100,
- }).done(function(response) {
+ }).success(function(response) {
// add admin groups
$.each(response.data.adminGroups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name });
@@ -177,8 +177,9 @@
self.groups.push({ id: group.id, displayname: group.name });
});
self.render();
- }).fail(function(response) {
- console.error('Failure happened', response);
+ }).error(function(data) {
+ OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), {type: 'error'});
+ console.log(data);
});
},
delete: function() {
diff --git a/apps/workflowengine/js/usergroupmembershipplugin.js b/apps/workflowengine/js/usergroupmembershipplugin.js
index c664481562b..b89087bea06 100644
--- a/apps/workflowengine/js/usergroupmembershipplugin.js
+++ b/apps/workflowengine/js/usergroupmembershipplugin.js
@@ -42,7 +42,7 @@
$(element).css('width', '400px');
$(element).select2({
- data: groups,
+ data: { results: groups, text: 'displayname' },
initSelection: function (element, callback) {
var groupId = element.val();
if (groupId && groups.length > 0) {
diff --git a/settings/js/settings.js b/settings/js/settings.js
index ad0ab758e9e..dd4a3a4cc7d 100644
--- a/settings/js/settings.js
+++ b/settings/js/settings.js
@@ -24,75 +24,70 @@ OC.Settings = _.extend(OC.Settings, {
var self = this;
options = options || {};
if ($elements.length > 0) {
- // note: settings are saved through a "change" event registered
- // on all input fields
- $elements.select2(_.extend({
- placeholder: t('core', 'Groups'),
- allowClear: true,
- multiple: true,
- toggleSelect: true,
- separator: '|',
- query: _.debounce(function(query) {
- var queryData = {};
- if (self._cachedGroups && query.term === '') {
- query.callback({results: self._cachedGroups});
- return;
- }
- if (query.term !== '') {
- queryData = {
- pattern: query.term,
- filterGroups: 1
- };
- }
- $.ajax({
- url: OC.generateUrl('/settings/users/groups'),
- data: queryData,
- dataType: 'json',
- success: function(data) {
- var results = [];
+ // Let's load the data and THEN init our select
+ $.ajax({
+ url: OC.generateUrl('/settings/users/groups'),
+ dataType: 'json',
+ success: function(data) {
+ var results = [];
- // add groups
- if (!options.excludeAdmins) {
- $.each(data.data.adminGroups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
+ // add groups
+ 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});
+ });
+ },
+ always: function() {
+ // note: settings are saved through a "change" event registered
+ // on all input fields
+ $elements.select2(_.extend({
+ placeholder: t('core', 'Groups'),
+ allowClear: true,
+ multiple: true,
+ toggleSelect: true,
+ separator: '|',
+ data: { results: results, text: 'displayname' },
+ initSelection: function(element, callback) {
+ var groups = $(element).val();
+ var selection;
+ if (groups && results.length > 0) {
+ selection = _.map((groups || []).split('|').sort(), function(groupId) {
+ return {
+ id: groupId,
+ displayname: results.find(group =>group.id === groupId).displayname
+ };
+ });
+ } else if (groups) {
+ selection = _.map((groups || []).split('|').sort(), function(groupId) {
+ return {
+ id: groupId,
+ displayname: groupId
+ };
});
}
- $.each(data.data.groups, function(i, group) {
- results.push({id:group.id, displayname:group.name});
- });
-
- if (query.term === '') {
- // cache full list
- self._cachedGroups = results;
- }
- query.callback({results: results});
+ callback(selection);
+ },
+ formatResult: function (element) {
+ return escapeHTML(element.displayname);
+ },
+ formatSelection: function (element) {
+ return escapeHTML(element.displayname);
+ },
+ escapeMarkup: function(m) {
+ // prevent double markup escape
+ return m;
}
- });
- }, 100, true),
- id: function(element) {
- return element.id;
- },
- initSelection: function(element, callback) {
- var selection = _.map(($(element).val() || []).split('|').sort(), function(groupId) {
- return {
- id: groupId,
- displayname: groupId + 'FIXME' // FIXME
- };
- });
- callback(selection);
+ }, extraOptions || {}));
},
- formatResult: function (element) {
- return escapeHTML(element.displayname);
- },
- formatSelection: function (element) {
- return escapeHTML(element.displayname);
- },
- escapeMarkup: function(m) {
- // prevent double markup escape
- return m;
+ error : function(data) {
+ OC.Notification.show(t('settings', 'Unable to retrieve the group list'), {type: 'error'});
+ console.log(data);
}
- }, extraOptions || {}));
+ });
}
}
});
-