mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
Default to empty array results in Ember services
This commit is contained in:
parent
38e8c4665a
commit
8d65c2d571
10 changed files with 36 additions and 11 deletions
|
@ -56,6 +56,8 @@ export default Service.extend({
|
|||
// Returns all active users for organization.
|
||||
getAll() {
|
||||
return this.get('ajax').request(`users?active=1`).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
|
||||
return response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
return this.get('store').push(data);
|
||||
|
@ -71,6 +73,8 @@ export default Service.extend({
|
|||
if (filter.length > 0) filter = encodeURIComponent(filter);
|
||||
|
||||
return this.get('ajax').request(`users?active=0&filter=${filter}`).then((response) => {
|
||||
if (is.not.array(response)) response = [];
|
||||
|
||||
return response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
return this.get('store').push(data);
|
||||
|
@ -86,6 +90,7 @@ export default Service.extend({
|
|||
method: "GET"
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
@ -167,10 +172,11 @@ export default Service.extend({
|
|||
return this.get('ajax').request('users/match', {
|
||||
method: 'POST',
|
||||
dataType: 'json',
|
||||
contentType: 'text',
|
||||
contentType: 'text',
|
||||
data: text
|
||||
}).then((response) => {
|
||||
let data = [];
|
||||
if (is.not.array(response)) response = [];
|
||||
|
||||
data = response.map((obj) => {
|
||||
let data = this.get('store').normalize('user', obj);
|
||||
|
@ -179,5 +185,5 @@ export default Service.extend({
|
|||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue