in public/src/js/models/collections/collection.js [361:398]
populate(rawCollection) {
this.raw = rawCollection || this.raw;
const loading = [];
if (this.raw) {
this.state.hasDraft(_.isArray(this.raw.draft));
if (this.hasOpenArticles()) {
this.state.hasConcurrentEdits(this.raw.updatedEmail !== vars.model.identity.email && this.state.lastUpdated());
} else if (!rawCollection || this.raw.lastUpdated !== this.state.lastUpdated()) {
const list = this.front.getCollectionList(this.raw);
_.each(this.groups, group => group.items.removeAll());
_.each(list, item => {
const itemGroupIndex = parseInt((item.meta || {}).group, 10) || 0;
const group = _.find(this.groups, g => itemGroupIndex === g.index) || this.groups[0];
const article = new Article(_.extend({}, item, {
group: group,
slimEditor: _.result(this.front, 'slimEditor')
}));
group.items.push(article);
});
this.populateHistory(this.raw.previously);
this.state.lastUpdated(this.raw.lastUpdated);
this.state.count(list.length);
loading.push(this.decorate());
}
}
loading.push(this.setPending(false));
return Promise.all(loading)
.then(() => mediator.emit('collection:populate', this))
.catch(() => {});
}