diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-02 18:02:18 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-08 17:13:50 +0100 |
commit | e6a7a9f251cd77a7b571716bbc679687a548cc47 (patch) | |
tree | d2c6fd6e1ba5c6d53b1caba553dde6770b41fef0 /apps/workflowengine | |
parent | ddcd37121fc88b43c4bd181625496663ae4fafe7 (diff) | |
download | nextcloud-server-e6a7a9f251cd77a7b571716bbc679687a548cc47.tar.gz nextcloud-server-e6a7a9f251cd77a7b571716bbc679687a548cc47.zip |
Fixed select2 workflow
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/workflowengine')
-rw-r--r-- | apps/workflowengine/js/admin.js | 22 | ||||
-rw-r--r-- | apps/workflowengine/js/usergroupmembershipplugin.js | 48 |
2 files changed, 30 insertions, 40 deletions
diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js index ab122a8cd65..6df7b144818 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,24 @@ if (this.model.get('id') === undefined) { this.hasChanged = true; } + var self = this; + $.ajax({ + url: OC.generateUrl('settings/users/groups'), + dataType: 'json', + quietMillis: 100, + }).done(function(response) { + // add admin groups + $.each(response.data.adminGroups, function(id, group) { + self.groups.push({ id: group.id, displayname: group.name+'FIXME' }); + }); + // add groups + $.each(response.data.groups, function(id, group) { + self.groups.push({ id: group.id, displayname: group.name+'FIXME' }); + }); + self.render(); + }).fail(function(response) { + console.error('Failure happened', response); + }); }, delete: function() { if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { @@ -304,10 +323,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 10f2382db2c..c664481562b 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,48 +42,18 @@ $(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, displayname: group.name }); - }); - // add groups - $.each(response.data.groups, function(id, group) { - results.push({ id: group.id, displayname: group.name }); - }); - - // TODO once limit and offset is implemented for groups we should paginate the search results - return { - results: results, - more: false - }; - } - }, + data: groups, initSelection: function (element, callback) { var groupId = element.val(); - if (groupId) { + if (groupId && groups.length > 0) { + callback({ + id: groupId, + displayname: groups.find(group =>group.id === groupId).displayname + }); + } else if (groupId) { callback({ id: groupId, - displayname: groupId + 'FIXME' // FIXME + displayname: groupId }); } else { callback(); |