summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2018-03-15 12:07:30 +0100
committerGitHub <noreply@github.com>2018-03-15 12:07:30 +0100
commit208e38e84e1a07a49699aa90dc5b7272d24489f0 (patch)
tree0a136997d2ba16d01c0a9ebc79ad67b550287cf5 /apps/workflowengine
parentfde08a961941323b445f5b5eed10cf25199fb5b4 (diff)
parent23a1553539d67f7eb317abd3857640d056853d50 (diff)
downloadnextcloud-server-208e38e84e1a07a49699aa90dc5b7272d24489f0.tar.gz
nextcloud-server-208e38e84e1a07a49699aa90dc5b7272d24489f0.zip
Merge pull request #8255 from nextcloud/bugfix/noid/group-display-name
Full implement group display names
Diffstat (limited to 'apps/workflowengine')
-rw-r--r--apps/workflowengine/js/admin.js23
-rw-r--r--apps/workflowengine/js/usergroupmembershipplugin.js56
2 files changed, 40 insertions, 39 deletions
diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js
index ab122a8cd65..891e50c4189 100644
--- a/apps/workflowengine/js/admin.js
+++ b/apps/workflowengine/js/admin.js
@@ -149,6 +149,7 @@
message: '',
errorMessage: '',
saving: false,
+ groups: [],
initialize: function() {
// this creates a new copy of the object to definitely have a new reference and being able to reset the model
this.originalModel = JSON.parse(JSON.stringify(this.model));
@@ -161,6 +162,25 @@
if (this.model.get('id') === undefined) {
this.hasChanged = true;
}
+ var self = this;
+ $.ajax({
+ url: OC.generateUrl('settings/users/groups'),
+ dataType: 'json',
+ quietMillis: 100,
+ }).success(function(response) {
+ // add admin groups
+ $.each(response.data.adminGroups, function(id, group) {
+ self.groups.push({ id: group.id, displayname: group.name });
+ });
+ // add groups
+ $.each(response.data.groups, function(id, group) {
+ self.groups.push({ id: group.id, displayname: group.name });
+ });
+ self.render();
+ }).error(function(data) {
+ OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), {type: 'error'});
+ console.log(data);
+ });
},
delete: function() {
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
@@ -304,10 +324,11 @@
id = $element.data('id'),
check = checks[id],
valueElement = $element.find('.check-value').first();
+ var self = this;
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.render)) {
- plugin.render(valueElement, check);
+ plugin.render(valueElement, check, self.groups);
}
});
}, this);
diff --git a/apps/workflowengine/js/usergroupmembershipplugin.js b/apps/workflowengine/js/usergroupmembershipplugin.js
index 1c09e7d5ccd..53f35fedf2d 100644
--- a/apps/workflowengine/js/usergroupmembershipplugin.js
+++ b/apps/workflowengine/js/usergroupmembershipplugin.js
@@ -34,7 +34,7 @@
]
};
},
- render: function(element, check) {
+ render: function(element, check, groups) {
if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\UserGroupMembership') {
return;
}
@@ -42,50 +42,30 @@
$(element).css('width', '400px');
$(element).select2({
- ajax: {
- url: OC.generateUrl('settings/users/groups'),
- dataType: 'json',
- quietMillis: 100,
- data: function (term) {
- return {
- pattern: term, //search term
- filterGroups: true,
- sortGroups: 2 // by groupname
- };
- },
- results: function (response) {
- // TODO improve error case
- if (response.data === undefined) {
- console.error('Failure happened', response);
- return;
- }
-
- var results = [];
-
- // add admin groups
- $.each(response.data.adminGroups, function(id, group) {
- results.push({ id: group.id });
+ data: { results: groups, text: 'displayname' },
+ initSelection: function (element, callback) {
+ var groupId = element.val();
+ if (groupId && groups.length > 0) {
+ callback({
+ id: groupId,
+ displayname: groups.find(function (group) {
+ return group.id === groupId;
+ }).displayname
});
- // add groups
- $.each(response.data.groups, function(id, group) {
- results.push({ id: group.id });
+ } else if (groupId) {
+ callback({
+ id: groupId,
+ displayname: groupId
});
-
- // TODO once limit and offset is implemented for groups we should paginate the search results
- return {
- results: results,
- more: false
- };
+ } else {
+ callback();
}
},
- initSelection: function (element, callback) {
- callback({id: element.val()});
- },
formatResult: function (element) {
- return '<span>' + escapeHTML(element.id) + '</span>';
+ return '<span>' + escapeHTML(element.displayname) + '</span>';
},
formatSelection: function (element) {
- return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.id)+'</span>';
+ return '<span title="'+escapeHTML(element.id)+'">'+escapeHTML(element.displayname)+'</span>';
}
});
}