From 3035f5efbf8bdc8533e8341f14e4c3551495de9e Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Mon, 6 May 2024 16:06:29 +0200 Subject: [PATCH 1/2] implement belga specific coverage due date callback SDBELGA-782 --- client/index.tsx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/client/index.tsx b/client/index.tsx index 3a7e416c..75cbd1ff 100644 --- a/client/index.tsx +++ b/client/index.tsx @@ -8,6 +8,10 @@ import {AvatarContentText} from 'superdesk-ui-framework'; import belgaImage from './belga/image'; import belga360Archive from './belga/360archive'; import belgaPress from './belga/belgapress'; +import moment from 'moment'; +import {IEventItem, IPlanningItem} from 'superdesk-planning/client/interfaces'; +import {setCoverageDueDateCallback} from 'superdesk-planning/client/configure'; +import {eventUtils} from 'superdesk-planning/client/utils'; class UserAvatar extends React.PureComponent<{user: Partial}> { render() { @@ -24,6 +28,30 @@ class UserAvatar extends React.PureComponent<{user: Partial}> { } } +function getCoverageDueDate( + planningItem: IPlanningItem, + eventItem?: IEventItem, +): moment.Moment | null { + let coverageTime: moment.Moment | null = null; + + if (eventItem && eventUtils.isEventAllDay(eventItem.dates?.start, eventItem.dates?.end)) { + coverageTime = moment(eventItem?.dates?.end); + coverageTime.set('hour', 20); + coverageTime.set('minute', 0); + coverageTime.set('second', 0); + } else if (eventItem) { + coverageTime = moment(eventItem.dates?.end); + coverageTime.add(1, 'hour'); + + } else if (planningItem) { + coverageTime = moment(planningItem.planning_date); + } + + return coverageTime; +} + +setCoverageDueDateCallback(getCoverageDueDate); + setTimeout(() => { startApp([ { From bca99c22b556278d41c7b9330eccff8c88a82e25 Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Wed, 8 May 2024 10:08:06 +0200 Subject: [PATCH 2/2] make sure it stays on the same day --- client/index.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/index.tsx b/client/index.tsx index 75cbd1ff..59b292eb 100644 --- a/client/index.tsx +++ b/client/index.tsx @@ -10,7 +10,7 @@ import belga360Archive from './belga/360archive'; import belgaPress from './belga/belgapress'; import moment from 'moment'; import {IEventItem, IPlanningItem} from 'superdesk-planning/client/interfaces'; -import {setCoverageDueDateCallback} from 'superdesk-planning/client/configure'; +import {setCoverageDueDateStrategy} from 'superdesk-planning/client/configure'; import {eventUtils} from 'superdesk-planning/client/utils'; class UserAvatar extends React.PureComponent<{user: Partial}> { @@ -35,14 +35,17 @@ function getCoverageDueDate( let coverageTime: moment.Moment | null = null; if (eventItem && eventUtils.isEventAllDay(eventItem.dates?.start, eventItem.dates?.end)) { - coverageTime = moment(eventItem?.dates?.end); + coverageTime = moment(eventItem.dates?.end); coverageTime.set('hour', 20); coverageTime.set('minute', 0); coverageTime.set('second', 0); } else if (eventItem) { coverageTime = moment(eventItem.dates?.end); coverageTime.add(1, 'hour'); - + if (eventItem.dates?.end && !coverageTime.isSame(eventItem.dates?.end, 'day')) { + // make sure we're not going into the next day + coverageTime = moment(eventItem.dates?.end); + } } else if (planningItem) { coverageTime = moment(planningItem.planning_date); } @@ -50,7 +53,7 @@ function getCoverageDueDate( return coverageTime; } -setCoverageDueDateCallback(getCoverageDueDate); +setCoverageDueDateStrategy(getCoverageDueDate); setTimeout(() => { startApp([