1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

list group members & non-members

This commit is contained in:
sauls8t 2018-02-28 14:55:36 +00:00
parent 19b4a3de49
commit 0680a72ee2
15 changed files with 360 additions and 60 deletions

View file

@ -64,5 +64,35 @@ export default BaseService.extend({
return this.get('ajax').request(`group/${groupId}`, {
method: 'DELETE'
});
}
},
// Returns users associated with given group
getGroupMembers(groupId) {
return this.get('ajax').request(`group/${groupId}/members`, {
method: 'GET'
}).then((response) => {
let data = [];
data = response.map((obj) => {
let data = this.get('store').normalize('group-member', obj);
return this.get('store').push(data);
});
return data;
});
},
// join adds user to group.
join(groupId, userId) {
return this.get('ajax').request(`group/${groupId}/join/${userId}`, {
method: 'POST'
});
},
// leave removes user from group.
leave(groupId, userId) {
return this.get('ajax').request(`group/${groupId}/leave/${userId}`, {
method: 'DELETE'
});
},
});

View file

@ -145,5 +145,24 @@ export default Service.extend({
method: "POST",
data: password
});
}
},
// matchUsers on firstname, lastname, email
matchUsers(text) {
return this.get('ajax').request('users/match', {
method: 'POST',
dataType: 'json',
contentType: 'text',
data: text
}).then((response) => {
let data = [];
data = response.map((obj) => {
let data = this.get('store').normalize('user', obj);
return this.get('store').push(data);
});
return data;
});
}
});