From 6e0044b668b8eb99c7dfc5c47e6b8f9c9f23298c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Mon, 5 Mar 2018 16:16:43 +0100 Subject: [PATCH] Fixed sharing groups select and fixed search MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/workflowengine/js/admin.js | Bin 12016 -> 12093 bytes .../js/usergroupmembershipplugin.js | Bin 2338 -> 2372 bytes settings/js/settings.js | 121 +++++++++--------- 3 files changed, 58 insertions(+), 63 deletions(-) diff --git a/apps/workflowengine/js/admin.js b/apps/workflowengine/js/admin.js index d31add77ef4e752617fef773f8759b9217c5b810..891e50c4189236af24e78c7979ba738d1d4a2e10 100644 GIT binary patch delta 185 zcmewmyEksbUJ>@<(&XgS;^NH*MY0&{Q;Ul7i!{1QnU|`rqo5v|mzb23s!)=zP?TCyl$lxv zWM`x*q!;Cv7AWLo7MG}N>L^r~R2HOKDX4?ZQLojs=HiqF*^``~SDc@ds+W_W4sifb Q0thC5R21IaCzd1u06hUd&Hw-a delta 96 zcmdlR_aSz}UJ;g*{Jhl7M?|t1J<}31b2QRQ^O8$4^Yb){Qi}`n^NLe76{@*7K_D5( p%g;&GOD!tOFVawV1F9}9N>#{6EGS6LOHEPNQGjXLd{C@L0s!GABUS(a diff --git a/apps/workflowengine/js/usergroupmembershipplugin.js b/apps/workflowengine/js/usergroupmembershipplugin.js index c664481562ba36f3985f687ce13095de7b116c83..b89087bea065e8f64607384f22844c1d8195099b 100644 GIT binary patch delta 53 zcmZ1^bVO(aJDWzeLQ!gQX--M8l|p(^erZ9mjzURlMTwPydP-(-K~7?2USe*lxiv`A 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; + }, extraOptions || {})); }, - initSelection: function(element, callback) { - var selection = _.map(($(element).val() || []).split('|').sort(), function(groupId) { - return { - id: groupId, - displayname: groupId + 'FIXME' // FIXME - }; - }); - 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; + error : function(data) { + OC.Notification.show(t('settings', 'Unable to retrieve the group list'), {type: 'error'}); + console.log(data); } - }, extraOptions || {})); + }); } } }); -