in public/src/js/widgets/columns/story-package.js [100:141]
load(id) {
if (id !== this.front()) {
this.front(id);
}
if (!id) {
this.loaded = Promise.resolve();
return;
}
this.loaded = authedAjax.request({
url: '/story-package/' + id
})
.then(response => {
const newCollection = new Collection({
id: id,
front: this,
displayName: response.name,
lastUpdated: response.lastModify,
updatedBy: response.lastModifyByName,
updatedEmail: response.lastModifyBy,
groups: ['linked', 'included']
});
const oldCollection = this.collection();
this.collection(newCollection);
const latestPackages = this.baseModel.latestPackages();
if (!_.find(latestPackages, latestPackage => latestPackage.id === newCollection.id )) {
latestPackages.unshift(response);
this.baseModel.latestPackages(latestPackages);
this.front(newCollection.id);
}
return newCollection.loaded.then(() => {
if (oldCollection) {
oldCollection.dispose();
}
});
})
.then(() => mediator.emit('front:loaded', this))
.catch(response => {
alert('Failed loading story package ' + id + '\n' + response.responseText || response.message);
});
}