1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-02 20:15:26 +02:00

Problem: we are showing inactive users in lists

Solution: allow optional parameter to show/hide inactive users
This commit is contained in:
Harvey Kandola 2017-03-22 12:04:48 +00:00
parent 90eb4f9517
commit fa0f176613
5 changed files with 73 additions and 10 deletions

View file

@ -11,10 +11,12 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import constants from '../../../utils/constants';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
userService: Ember.inject.service('user'),
global: Ember.inject.service('global'),
appMeta: Ember.inject.service(),
beforeModel: function () {
if (!this.session.isAdmin) {
@ -24,11 +26,17 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
model() {
return new Ember.RSVP.Promise((resolve) => {
this.get('global').syncExternalUsers().then(() => {
this.get('userService').getAll().then((users) =>{
if (this.get('appMeta.authProvider') == constants.AuthProvider.Keycloak) {
this.get('global').syncExternalUsers().then(() => {
this.get('userService').getComplete().then((users) =>{
resolve(users);
});
});
} else {
this.get('userService').getComplete().then((users) =>{
resolve(users);
});
});
}
});
},

View file

@ -46,9 +46,9 @@ export default Ember.Service.extend({
});
},
// Returns all users for organization.
// Returns all active users for organization.
getAll() {
return this.get('ajax').request(`users`).then((response) => {
return this.get('ajax').request(`users?active=1`).then((response) => {
return response.map((obj) => {
let data = this.get('store').normalize('user', obj);
return this.get('store').push(data);
@ -56,6 +56,17 @@ export default Ember.Service.extend({
});
},
// Returns all active and inactive users for organization.
getComplete() {
return this.get('ajax').request(`users?active=0`).then((response) => {
return response.map((obj) => {
let data = this.get('store').normalize('user', obj);
return this.get('store').push(data);
});
});
},
// Returns all users that can see folder.
getFolderUsers(folderId) {
let url = `users/folder/${folderId}`;