diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-09-10 14:30:02 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-09-22 10:14:18 +0200 |
commit | 2aaad09062c773012b6cce1e79483e611e3a0bd4 (patch) | |
tree | a200da014b81145766f238c1af2ecbd03b5613c9 /settings/js | |
parent | 996c68aa2eeb8f861413083d51f692853b4d5ca4 (diff) | |
download | nextcloud-server-2aaad09062c773012b6cce1e79483e611e3a0bd4.tar.gz nextcloud-server-2aaad09062c773012b6cce1e79483e611e3a0bd4.zip |
Fixed select2 for admin and apps page
Added explicit escaping.
Now internally using a pipe symbol as separator for select2, to make it
possible to use group names containing commas.
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/admin.js | 11 | ||||
-rw-r--r-- | settings/js/apps.js | 12 | ||||
-rw-r--r-- | settings/js/settings.js | 16 |
3 files changed, 27 insertions, 12 deletions
diff --git a/settings/js/admin.js b/settings/js/admin.js index 943bf78e024..95be13d2288 100644 --- a/settings/js/admin.js +++ b/settings/js/admin.js @@ -20,6 +20,15 @@ $(document).ready(function(){ $('#excludedGroups').each(function (index, element) { OC.Settings.setupGroupsSelect($(element)); + $(element).change(function(ev) { + var groups = ev.val || []; + if (groups.length > 0) { + groups = ev.val.join(','); // FIXME: make this JSON + } else { + groups = ''; + } + OC.AppConfig.setValue('core', $(this).attr('name'), groups); + }); }); @@ -42,7 +51,7 @@ $(document).ready(function(){ $('#shareAPI p:not(#enable)').toggleClass('hidden', !this.checked); }); - $('#shareAPI input').change(function() { + $('#shareAPI input:not(#excludedGroups)').change(function() { if ($(this).attr('type') === 'checkbox') { if (this.checked) { var value = 'yes'; diff --git a/settings/js/apps.js b/settings/js/apps.js index aafbdaf958a..3f4c149c8a1 100644 --- a/settings/js/apps.js +++ b/settings/js/apps.js @@ -123,10 +123,10 @@ OC.Settings.Apps = OC.Settings.Apps || { page.find("label[for='groups_enable']").hide(); page.find("#groups_enable").attr('checked', null); } else { - $('#group_select').val((app.groups || []).join(',')); if (app.active) { if (app.groups.length) { OC.Settings.Apps.setupGroupsSelect(); + $('#group_select').select2('val', app.groups || []); page.find("#groups_enable").attr('checked','checked'); } else { page.find("#groups_enable").attr('checked', null); @@ -377,14 +377,10 @@ $(document).ready(function(){ } }); - $('#group_select').change(function() { + $('#group_select').change(function(ev) { var element = $('#app-content input.enable'); - var groups = $(this).val(); - if (groups && groups !== '') { - groups = groups.split(','); - } else { - groups = []; - } + // getting an array of values from select2 + var groups = ev.val || []; var appid = element.data('appid'); if (appid) { OC.Settings.Apps.enableApp(appid, false, element, groups); diff --git a/settings/js/settings.js b/settings/js/settings.js index 85e8996ae7f..6e44c473185 100644 --- a/settings/js/settings.js +++ b/settings/js/settings.js @@ -7,6 +7,11 @@ OC.Settings = OC.Settings || {}; OC.Settings = _.extend(OC.Settings, { /** * Setup selection box for group selection. + * + * Values need to be separated by a pipe "|" character. + * (mostly because a comma is more likely to be used + * for groups) + * * @param $elements jQuery element (hidden input) to setup select2 on * @param [extraOptions] extra options hash to pass to select2 */ @@ -18,6 +23,7 @@ OC.Settings = _.extend(OC.Settings, { placeholder: t('core', 'Groups'), allowClear: true, multiple: true, + separator: '|', ajax: { url: OC.generateUrl('/settings/ajax/grouplist'), dataType: 'json', @@ -50,7 +56,7 @@ OC.Settings = _.extend(OC.Settings, { }, initSelection: function(element, callback) { var selection = - _.map(($(element).val() || []).split(',').sort(), + _.map(($(element).val() || []).split('|').sort(), function(groupName) { return { id: groupName, @@ -60,10 +66,14 @@ OC.Settings = _.extend(OC.Settings, { callback(selection); }, formatResult: function (element) { - return element.displayname; + return escapeHTML(element.displayname); }, formatSelection: function (element) { - return element.displayname; + return escapeHTML(element.displayname); + }, + escapeMarkup: function(m) { + // prevent double markup escape + return m; } }, extraOptions || {})); } |