diff --git a/src/current-user/CurrentUser.js b/src/current-user/CurrentUser.js index 3a03bd12..27b9f57e 100644 --- a/src/current-user/CurrentUser.js +++ b/src/current-user/CurrentUser.js @@ -149,6 +149,15 @@ class CurrentUser { this.dataStore = UserDataStore.getUserDataStore() } + /** + * Get a list of group ids the current user belongs to. + * + * @returns {Array} The list of ids of all the user's groups. + */ + getUserGroupIds() { + return this[propertySymbols.userGroups] + } + /** * Get a ModelCollection of userGroup models that are assigned to the currentUser * @@ -157,15 +166,17 @@ class CurrentUser { * * The request done is equivalent do doing https://play.dhis2.org/demo/api/27/me.json?fields=userGroups[:all] * + * @param {Object} [listOptions={}] Additional query parameters that should be send with the request. * @returns {Promise} The model collection that contains the user's groups. */ - getUserGroups() { + getUserGroups(listOptions = {}) { const userGroupIds = this[propertySymbols.userGroups] - return this[models].userGroup.list({ - filter: [`id:in:[${userGroupIds.join(',')}]`], - paging: false, - }) + return this[models].userGroup.list( + Object.assign({ paging: false }, listOptions, { + filter: [`id:in:[${userGroupIds.join(',')}]`], + }) + ) } /**