diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2013-03-19 14:49:02 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2013-03-19 14:49:02 +0100 |
commit | 06a7d39024b2ad4057a997a4ef59d0cfc166d12c (patch) | |
tree | 32a0c7d5a67c9a118007501ead3f4a419a5b3fa4 /settings/js | |
parent | e8100dc1a8f8b361d11cc0e82a18ade319092877 (diff) | |
download | nextcloud-server-06a7d39024b2ad4057a997a4ef59d0cfc166d12c.tar.gz nextcloud-server-06a7d39024b2ad4057a997a4ef59d0cfc166d12c.zip |
User list: Keep array of available groups. Should fix #873
Diffstat (limited to 'settings/js')
-rw-r--r-- | settings/js/users.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/settings/js/users.js b/settings/js/users.js index 632136b7ff7..7c935515c7a 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -6,6 +6,7 @@ var UserList = { useUndo: true, + availableGroups: [], /** * @brief Initiate user deletion process in UI @@ -78,8 +79,7 @@ var UserList = { var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('settings', 'Group Admin') + '">').attr('data-username', username).attr('data-user-groups', groups).attr('data-subadmin', subadmin); tr.find('td.subadmins').empty(); } - var allGroups = String($('#content table').attr('data-groups')).split(', '); - $.each(allGroups, function (i, group) { + $.each(this.availableGroups, function (i, group) { groupsSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>')); if (typeof subadminSelect !== 'undefined' && group != 'admin') { subadminSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>')); @@ -188,7 +188,6 @@ var UserList = { }); } }); - console.log('length', result.data.length); if (result.data.length > 0) { UserList.doSort(); } @@ -218,7 +217,14 @@ var UserList = { username: user, group: group }, - function () { + function (response) { + if(response.status === 'success' && response.data.action === 'add') { + if(UserList.availableGroups.indexOf(response.data.gropname) === -1) { + UserList.availableGroups.push(response.data.gropname); + } + } else { + OC.Notification.show(response.data.message); + } } ); }; @@ -289,6 +295,7 @@ var UserList = { $(document).ready(function () { UserList.doSort(); + UserList.availableGroups = $('#content table').attr('data-groups').split(', '); UserList.offset = $('tbody tr').length; $('tbody tr:last').bind('inview', function (event, isInView, visiblePartX, visiblePartY) { OC.Router.registerLoadedCallback(function () { @@ -421,6 +428,8 @@ $(document).ready(function () { OC.dialogs.alert(result.data.message, t('settings', 'Error creating user')); } else { + var addedGroups = result.data.groups.split(', '); + UserList.availableGroups = $.unique($.merge(UserList.availableGroups, addedGroups)); if($('tr[data-uid="' + username + '"]').length === 0) { UserList.add(username, username, result.data.groups, null, 'default', true); } |