in public/src/js/models/collections/article.js [52:152]
constructor(opts = {}, withCapiData) {
super();
this.id = ko.observable(opts.id);
this.group = opts.group;
this.front = deepGet(opts, '.group.front');
this.props = asObservableProps(capiProps);
this.props.webPublicationDate.extend({ notify: 'always' });
this.fields = asObservableProps(capiFields);
this.meta = asObservableProps(_.pluck(metaFields, 'key'));
populateObservables(this.meta, opts.meta);
if (this.front && this.front.confirmSendingAlert()) {
populateObservables(this.meta, { imageHide: true });
}
this.metaDefaults = {};
this.collectionMetaDefaults = deepGet(opts, '.group.parent.itemDefaults');
this.uneditable = opts.uneditable;
this.slimEditor = opts.slimEditor;
this.state = asObservableProps([
'enableContentOverrides',
'underDrag',
'underControlDrag',
'isOpen',
'isLiveBlog',
'isLoaded',
'isEmpty',
'visited',
'inDynamicCollection',
'inFlexibleCollection',
'inFlexibleGeneralCollection',
'tone',
'primaryTag',
'sectionName',
'hasMainVideo',
'imageSrcFromCapi',
'imageCutoutSrcFromCapi',
'viewUrl',
'ophanUrl',
'sparkUrl',
'capiId',
'shortUrl',
'premium']);
this.state.enableContentOverrides(this.meta.snapType() !== 'latest');
this.state.inDynamicCollection(deepGet(opts, '.group.parent.isDynamic'));
this.state.inFlexibleCollection(deepGet(opts, '.group.parent.isFlexible'));
this.state.inFlexibleGeneralCollection(deepGet(opts, '.group.parent.isFlexibleGeneral'));
this.state.visited(opts.visited);
this.frontPublicationDate = opts.frontPublicationDate;
this.publishedBy = opts.publishedBy;
this.frontPublicationTime = ko.observable();
this.scheduledPublicationTime = ko.observable();
this.editors = ko.observableArray();
this.editorsDisplay = ko.observableArray();
this.headline = ko.pureComputed(headline, this);
this.headlineLength = ko.pureComputed(headlineLength, this);
this.headlineLengthAlert = ko.pureComputed(headlineLengthAlert, this);
this.webPublicationTime = ko.pureComputed(this.getWebPublicationHumanTime, this);
this.thumbImage = ko.pureComputed(thumbnail, this);
this.mainImage = ko.pureComputed(mainImage, this);
// Populate supporting
if (this.group && this.group.parentType !== 'Article') {
this.meta.supporting = new Group({
parent: this,
parentType: 'Article',
omitItem: this.save.bind(this),
front: this.front
});
this.meta.supporting.items(_.map((opts.meta || {}).supporting, (item) => {
return new Article(_.extend(item, {
group: this.meta.supporting
}));
}));
contentApi.decorateItems(this.meta.supporting.items());
this.addViewUrl();
}
if (withCapiData) {
this.addCapiData(opts);
} else {
this.updateEditorsDisplay();
}
}