]> source.dussan.org Git - nextcloud-server.git/commitdiff
Ignore delete groups 20802/head
authorDaniel Kesselberg <mail@danielkesselberg.de>
Fri, 24 Jan 2020 15:03:39 +0000 (16:03 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Mon, 4 May 2020 08:05:24 +0000 (08:05 +0000)
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
apps/settings/js/settings.js

index 2c4f9c4c94fc1f3593f9c700af18570b2b5c9292..24384ee316be8a4f21bae758b076bd1c5954fc83 100644 (file)
@@ -6,9 +6,9 @@
 OC.Settings = OC.Settings || {};
 OC.Settings = _.extend(OC.Settings, {
 
-    _cachedGroups: null,
+       _cachedGroups: null,
 
-    /**
+       /**
      * Setup selection box for group selection.
      *
      * Values need to be separated by a pipe "|" character.
@@ -20,77 +20,81 @@ OC.Settings = _.extend(OC.Settings, {
      * @param {Array} [options] extra options
      * @param {Array} [options.excludeAdmins=false] flag whether to exclude admin groups
      */
-    setupGroupsSelect: function($elements, extraOptions, options) {
-        var self = this;
-        options = options || {};
-        if ($elements.length > 0) {
-            // Let's load the data and THEN init our select
-            $.ajax({
-                url: OC.linkToOCS('cloud/groups', 2) + 'details',
-                dataType: 'json',
-                success: function(data) {
-                    var results = [];
+       setupGroupsSelect: function($elements, extraOptions, options) {
+               var self = this;
+               options = options || {};
+               if ($elements.length > 0) {
+                       // Let's load the data and THEN init our select
+                       $.ajax({
+                               url: OC.linkToOCS('cloud/groups', 2) + 'details',
+                               dataType: 'json',
+                               success: function(data) {
+                                       var results = [];
 
-                    if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
+                                       if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
 
-                        data.ocs.data.groups.forEach(function(group) {
-                            if (!options.excludeAdmins || group.id !== 'admin') {
-                                results.push({ id: group.id, displayname: group.displayname });
-                            }
-                        })
+                                               data.ocs.data.groups.forEach(function(group) {
+                                                       if (!options.excludeAdmins || group.id !== 'admin') {
+                                                               results.push({ id: group.id, displayname: group.displayname });
+                                                       }
+                                               })
 
-                        // 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(function (group) {
-                                                return group.id === groupId;
-                                            }).displayname
-                                        };
-                                    });
-                                } else if (groups) {
-                                    selection = _.map((groups || []).split('|').sort(), function(groupId) {
-                                        return {
-                                            id: groupId,
-                                            displayname: groupId
-                                        };
-                                    });
-                                }
-                                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;
-                            }
-                        }, extraOptions || {}));
-                    } else {
-                        OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' });
-                        console.log(data);
-                    }
-                },
-                error: function(data) {
-                    OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' });
-                    console.log(data);
-                }
-            });
-        }
-    }
-});
\ No newline at end of file
+                                               // 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(_.filter((groups || []).split('|').sort(), function(groupId) {
+                                                                               return results.find(function(group) {
+                                                                                       return group.id === groupId
+                                                                               }) !== undefined
+                                                                       }), function(groupId) {
+                                                                               return {
+                                                                                       id: groupId,
+                                                                                       displayname: results.find(function(group) {
+                                                                                               return group.id === groupId
+                                                                                       }).displayname
+                                                                               }
+                                                                       })
+                                                               } else if (groups) {
+                                                                       selection = _.map((groups || []).split('|').sort(), function(groupId) {
+                                                                               return {
+                                                                                       id: groupId,
+                                                                                       displayname: groupId
+                                                                               };
+                                                                       });
+                                                               }
+                                                               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;
+                                                       }
+                                               }, extraOptions || {}));
+                                       } else {
+                                               OC.Notification.show(t('settings', 'Group list is empty'), { type: 'error' });
+                                               console.log(data);
+                                       }
+                               },
+                               error: function(data) {
+                                       OC.Notification.show(t('settings', 'Unable to retrieve the group list'), { type: 'error' });
+                                       console.log(data);
+                               }
+                       });
+               }
+       }
+});