Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
codelist: Ember.computed('objectArray', function() {
const objArray = this.get('objectArray');
let inList = new Ember.RSVP.Promise(function(resolve, reject) {
// succeed
resolve(objArray);
// or reject
reject(new Error('Couldn\'t create a promise.'));
});
let codeId = this.get('valuePath');
let codeName = this.get('namePath');
let tooltip = this.get('tooltipPath');
let icons = this.get('icons');
let defaultIcon = this.get('defaultIcon');
let outList = Ember.A();
return DS.PromiseArray.create({
promise: inList.then(function(arr) {
arr.forEach(function(item) {
let newObject = {
codeId: get(item, codeId),
codeName: get(item, codeName),
tooltip: false,
icon: icons.get(item[codeName].toString()) || icons.get(
defaultIcon)
};
if(tooltip) {
newObject.tooltip = get(item, tooltip);
}
outList.pushObject(newObject);
});
return outList;
if (relationshipType === 'manyToNone' || relationshipType === 'manyToMany' || relationshipType === 'manyToOne') {
if (this.isEmbedded(relationship)) {
if (snapshot.hasMany(relationship.key)) {
json[key] = snapshot.hasMany(relationship.key).map(function (embeddedSnapshot) {
var data = embeddedSnapshot.record.serialize({includeId: true});
return data;
});
} else {
json[key] = [];
}
} else {
var relationData = snapshot.hasMany(relationship.key);
// We can't deal with promises here. We need actual data
if (relationData instanceof DS.PromiseArray) {
// We need the content of the promise. Make sure it is fulfilled
if (relationData.get('isFulfilled')) {
// Use the fulfilled array
relationData = relationData.get('content');
} else {
// If the property hasn't been fulfilled then it hasn't changed.
// Fall back to the internal data. It contains enough for relationshipToResourceUri.
relationData = snapshot.hasMany(relationship.key).mapBy('id').map(function(_id) {
return {id: _id};
}) || [];
}
}
json[key] = relationData.map(function (next){
return this.relationshipToResourceUri(relationship, next, this.store);
}, this);
get() {
return DS.PromiseArray.create({
init() {
var promise = new Ember.RSVP.Promise((resolve) => {
var request = Ember.$.get(`${env.apiHost}/me/following?type=artist`);
request.then((data) => resolve(data.artists.items.compact()));
});
this.set('promise', promise);
}
});
}
})
get() {
return DS.PromiseArray.create({
init() {
var promise = new Ember.RSVP.Promise((resolve) => {
var request = Ember.$.get(`${env.apiHost}/browse/featured-playlists`);
request.then((data) => resolve(data.playlists.items));
});
this.set('promise', promise);
}
});
}
}),
let futureAppointments = result.filter(function(data) {
let startDate = get(data, 'startDate');
return startDate && moment(startDate).isAfter(moment(visitDate), 'day');
}).sortBy('startDate');
if (!futureAppointments.length) {
return null;
}
if (!outPatient) {
let [appointment] = futureAppointments;
return appointment;
} else {
return futureAppointments.slice(0, 3);
}
});
return (outPatient) ? DS.PromiseArray.create({ promise }) : DS.PromiseObject.create({ promise });
},
export const asResolvedPromise = function(returnedObject, PromiseTypeConstructor = DS.PromiseObject) {
if (_.isArray(returnedObject)) {
PromiseTypeConstructor = DS.PromiseArray;
}
return PromiseTypeConstructor.create({
promise: new Ember.RSVP.Promise(function (resolve, reject) {
resolve(returnedObject);
})
});
};
allDescendantUsers: computed('users.[]', 'children.@each.users', function(){
var deferred = Ember.RSVP.defer();
this.get('users').then(users => {
this.get('children').then(children => {
map(children.mapBy('allDescendantUsers'), childUsers => {
users.addObjects(childUsers);
}).then(() => {
deferred.resolve(users.uniq());
});
});
});
return DS.PromiseArray.create({
promise: deferred.promise
});
}),
usersOnlyAtThisLevel: computed('users.[]', 'allDescendants.[]', function(){
findStacksFor(organization) {
var organizationUrl = organization.get('data.links.self');
let promise = this.find('stack').then(() => {
return this.filter('stack', (stack) => {
return stack.get('data.links.organization') === organizationUrl;
});
});
return DS.PromiseArray.create({ promise });
},
subCompetencies.sortBy('title');
}
}
}
));
});
Ember.RSVP.all(promises).then(function(){
var domains = domainIds.map(function(id){
return domainContainer[id];
}).filter(
domain => domain.get('subCompetencies').length > 0
).sortBy('title');
defer.resolve(domains);
});
return DS.PromiseArray.create({
promise: defer.promise
});
}),
selectedDomains: computed('selectedCompetencies.@each.domain', function(){
if(!subCompetencies.contains(competency)){
subCompetencies.pushObject(competency);
subCompetencies.sortBy('title');
}
}
}
));
});
Ember.RSVP.all(promises).then(function(){
var domains = domainIds.map(function(id){
return domainContainer[id];
}).sortBy('title');
defer.resolve(domains);
});
return DS.PromiseArray.create({
promise: defer.promise
});
}),
actions: {