diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-23 13:01:40 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-24 17:52:15 +0200 |
commit | ddd1c8bc8689017559f6d6af36898fb7ddb28adb (patch) | |
tree | bb5ae0a068641a67b9f43b2a133b11d9683f0bb8 /settings/src/store | |
parent | 55184158292d3b4d4835b3bdb724bb19edf88355 (diff) | |
download | nextcloud-server-ddd1c8bc8689017559f6d6af36898fb7ddb28adb.tar.gz nextcloud-server-ddd1c8bc8689017559f6d6af36898fb7ddb28adb.zip |
Disabled fix since new users list
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'settings/src/store')
-rw-r--r-- | settings/src/store/index.js | 6 | ||||
-rw-r--r-- | settings/src/store/users.js | 27 |
2 files changed, 26 insertions, 7 deletions
diff --git a/settings/src/store/index.js b/settings/src/store/index.js index 4332ece33e4..aa64b245396 100644 --- a/settings/src/store/index.js +++ b/settings/src/store/index.js @@ -10,7 +10,11 @@ const debug = process.env.NODE_ENV !== 'production'; const mutations = { API_FAILURE(state, error) { - let message = error.error.response.data.ocs.meta.message; + try { + let message = error.error.response.data.ocs.meta.message; + } catch(e) { + let message = error; + } OC.Notification.showHtml(t('settings','An error occured during the request. Unable to proceed.')+'<br>'+message, {timeout: 7}); console.log(state, error); } diff --git a/settings/src/store/users.js b/settings/src/store/users.js index dc8b9fe1cb8..63a1568e048 100644 --- a/settings/src/store/users.js +++ b/settings/src/store/users.js @@ -12,6 +12,15 @@ const orderGroups = function(groups, orderBy) { } }; +const defaults = { + group: { + id: '', + name: '', + usercount: 0, + disabled: 0 + } +} + const state = { users: [], groups: [], @@ -33,18 +42,20 @@ const mutations = { state.minPasswordLength = length!=='' ? length : 0; }, initGroups(state, {groups, orderBy, userCount}) { - state.groups = groups; + state.groups = groups.map(group => Object.assign({}, defaults.group, group)); state.orderBy = orderBy; state.userCount = userCount; state.groups = orderGroups(state.groups, state.orderBy); + }, addGroup(state, gid) { try { - state.groups.push({ + // extend group to default values + let group = Object.assign({}, defaults.group, { id: gid, - name: gid, - usercount: 0 // user will be added after the creation + name: gid }); + state.groups.push(group); state.groups = orderGroups(state.groups, state.orderBy); } catch (e) { console.log('Can\'t create group', e); @@ -90,11 +101,15 @@ const mutations = { state.users.push(response.data.ocs.data); }, enableDisableUser(state, { userid, enabled }) { - state.users.find(user => user.id == userid).enabled = enabled; + let user = state.users.find(user => user.id == userid); + user.enabled = enabled; // increment or not state.groups.find(group => group.id == 'disabled').usercount += enabled ? -1 : 1; state.userCount += enabled ? 1 : -1; - console.log(enabled); + user.groups.forEach(group => { + // Increment disabled count + state.groups.find(groupSearch => groupSearch.id == group).disabled += enabled ? -1 : 1; + }); }, setUserData(state, { userid, key, value }) { if (key === 'quota') { |