diff options
author | Julius Härtl <jus@bitgrid.net> | 2018-05-22 08:58:35 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2018-06-06 11:40:09 +0200 |
commit | a8a655b1c0a393f873bff89e55d8a26697aa9a59 (patch) | |
tree | e2c270096423420c9e2a939581bc95f6006dc2b9 /settings | |
parent | bb50ee08e94b9c466b0d73547e326394f1424c9c (diff) | |
download | nextcloud-server-a8a655b1c0a393f873bff89e55d8a26697aa9a59.tar.gz nextcloud-server-a8a655b1c0a393f873bff89e55d8a26697aa9a59.zip |
Add group fetching to vuex group store
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'settings')
-rw-r--r-- | settings/src/store/users.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/settings/src/store/users.js b/settings/src/store/users.js index 5fac0c6f327..d3acb2ce553 100644 --- a/settings/src/store/users.js +++ b/settings/src/store/users.js @@ -48,12 +48,12 @@ const mutations = { state.groups = orderGroups(state.groups, state.orderBy); }, - addGroup(state, gid) { + addGroup(state, {gid, displayName}) { try { // extend group to default values let group = Object.assign({}, defaults.group, { id: gid, - name: gid + name: displayName, }); state.groups.push(group); state.groups = orderGroups(state.groups, state.orderBy); @@ -197,6 +197,21 @@ const actions = { .catch((error) => context.commit('API_FAILURE', error)); }, + getGroups(context) { /* { offset, limit, search } */ + //search = typeof search === 'string' ? search : ''; + return api.get(OC.linkToOCS(`cloud/groups`, 2)) /* ?offset=${offset}&limit=${limit}&search=${search}` */ + .then((response) => { + if (Object.keys(response.data.ocs.data.groups).length > 0) { + response.data.ocs.data.groups.forEach(function(group) { + context.commit('addGroup', {gid: group, displayName: group}); + }); + return true; + } + return false; + }) + .catch((error) => context.commit('API_FAILURE', error)); + }, + /** * Get all users with full details * @@ -253,7 +268,7 @@ const actions = { addGroup(context, gid) { return api.requireAdmin().then((response) => { return api.post(OC.linkToOCS(`cloud/groups`, 2), {groupid: gid}) - .then((response) => context.commit('addGroup', gid)) + .then((response) => context.commit('addGroup', {gid: gid, displayName: gid})) .catch((error) => {throw error;}); }).catch((error) => { context.commit('API_FAILURE', { gid, error }); @@ -450,4 +465,4 @@ const actions = { } }; -export default { state, mutations, getters, actions };
\ No newline at end of file +export default { state, mutations, getters, actions }; |