diff options
Diffstat (limited to 'settings/src/store')
-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 }; |