in public/components/content-list-item/content-list-item.js [98:228]
update(item) {
// TODO: Stubs have a different structure to content items
this.id = item.id || item.stubId;
this.composerId = item.composerId;
this.editorId = item.editorId;
this.wordCount = item.wordCount;
this.printWordCount = item.printWordCount;
this.commissionedLength = item.commissionedLength;
this.missingCommissionedLengthReason = item.missingCommissionedLengthReason;
this.headline = item.headline;
this.standfirst = stripHtml(item.standfirst);
this.workingTitle = item.workingTitle || item.title;
this.priority = item.priority;
this.prioritySortValue = item.priority !== undefined ? item.priority : 0;
this.hasComments = !!(item.commentable);
this.commentsTitle = this.hasComments ? 'on' : 'off';
this.hasMainMedia = !!(item.hasMainMedia)
this.trailtext = stripHtml(item.trailtext);
this.trailImageUrl = item.trailImageUrl;
this.assignee = item.assignee;
this.assigneeEmail = item.assigneeEmail;
this.assigneeInitials = item.assignee && toInitials(item.assignee);
this.contentType = item.contentType;
this.contentTypeTitle = toTitleCase(item.contentType);
this.formatIcon = getArticleFormat(item.contentType, item.displayHint);
this.formatTitle = getArticleFormatTitle(item.contentType, item.displayHint);
this.office = item.prodOffice;
this.officeTitle = getFullOfficeString(item.prodOffice);
this.status = item.status || 'Stub';
this.statusValues = this.status === 'Stub' ? statusLabels : contentStatusValues;
this.section = sections.filter((section) => section.name === item.section)[0]; // Get section object
this.needsLegal = item.needsLegal;
this.needsPictureDesk = item.needsPictureDesk;
this.note = item.note;
this.commissioningDesks = getCommissioningDeskNames(item.commissioningDesks);
// TODO: Decide if this is due or deadline
this.deadline = item.due;
this.created = item.createdAt;
this.lastModified = item.lastModified;
this.lastModifiedBy = item.lastModifiedBy;
this.firstPublished = item.timePublished;
this.hasEmbargoedDate =
item.embargoedUntil &&
new Date(item.embargoedUntil).getTime() > (new Date()).getTime();
this.isTakenDown = item.takenDown;
this.isPublished = item.published;
this.isEmbargoed = this.hasEmbargoedDate || item.embargoedIndefinitely;
this.isScheduled = Boolean(item.scheduledLaunchDate);
var lifecycleState = this.lifecycleState(item);
this.lifecycleState = lifecycleState.display;
this.lifecycleStateKey = lifecycleState.key;
this.lifecycleStateSupl = lifecycleState.supl;
this.lifecycleStateSuplDate = lifecycleState.suplDate;
this.publishedStates = this.publishedStates(item);
this.links = new ContentItemLinks(item);
this.path = item.path;
this.isOwnedByInCopy = item.activeInInCopy;
this.storyBundleId = item.storyBundleId;
/* it may be linked with InCopy but owned by composer */
this.linkedWithIncopy = (typeof item.storyBundleId === "string" &&
item.storyBundleId.length > 0);
this.incopyTitle = this.linkedWithIncopy ?
'Linked with InCopy Story Bundle ' + this.storyBundleId :
'Not linked with InCopy';
this.optimisedForWeb = !!(item.optimisedForWeb);
this.optimisedForWebChanged = !!(item.optimisedForWebChanged);
this.sensitive = !!(item.sensitive);
this.legallySensitive = !!(item.legallySensitive);
if (this.optimisedForWebChanged) {
this.optimisedForWebTitle = 'Content has been modified since being optimised'
} else {
this.optimisedForWebTitle = this.optimisedForWeb ? 'Optimised for web' : 'Not optimised for web';
}
this.sensitiveTitle = 'This content features children, vulnerable people, or is on a topic that is likely to attract online abuse.';
this.legallySensitiveTitle = 'This content involves active criminal proceedings.';
this.shortActualPrintLocationDescription = item.shortActualPrintLocationDescription;
this.longActualPrintLocationDescription = item.longActualPrintLocationDescription;
this.actualNewspaperPageNumber = item.actualNewspaperPageNumber;
this.actualNewspaperPublicationDate = item.actualNewspaperPublicationDate;
this.shortPlannedPrintLocationDescription = item.shortPlannedPrintLocationDescription;
this.longPlannedPrintLocationDescription = item.longPlannedPrintLocationDescription;
this.plannedNewspaperPageNumber = item.plannedNewspaperPageNumber;
this.plannedNewspaperPublicationDate = item.plannedNewspaperPublicationDate;
this.statusInPrint = item.statusInPrint;
this.lastModifiedInPrintBy = item.lastModifiedInPrintBy;
// These are derived values used for display purposes.
const {
shortPrintLocationDescription,
newspaperPageNumber,
newspaperPublicationDate,
longPrintLocationDescription,
printLocationType
} = this.getPrintValues(item);
if (shortPrintLocationDescription) {
const newspaperPageNumberStr = newspaperPageNumber
? `p. ${newspaperPageNumber}`
: '';
this.printLocationDisplayString = `${shortPrintLocationDescription}<br />${newspaperPageNumberStr} ${wfFormatDateTime(newspaperPublicationDate, 'DD MMMM')}`;
// We use 8601 dates to make the date sortable.
this.printLocationBookSection = shortPrintLocationDescription;
this.printLocationPublicationDate =wfFormatDateTime(newspaperPublicationDate, 'ISO8601');
this.printLocationPageNumber = newspaperPageNumber !== undefined ? newspaperPageNumber : Number.MAX_VALUE;
this.longPrintLocationDescription = longPrintLocationDescription;
this.printLocationType = printLocationType;
}
this.item = item;
}