Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement belga specific coverage due date callback #452

Merged
merged 3 commits into from
May 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this should be fine, but ideally we should have a public interface for the Planning module that would provide these utils and configuration abilities.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep didn't want to complicate it now but some public interface would be the way to go

import {setCoverageDueDateStrategy} from 'superdesk-planning/client/configure';
import {eventUtils} from 'superdesk-planning/client/utils';

class UserAvatar extends React.PureComponent<{user: Partial<IUser>}> {
render() {
Expand All @@ -24,6 +28,33 @@ class UserAvatar extends React.PureComponent<{user: Partial<IUser>}> {
}
}

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');
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);
}

return coverageTime;
}

setCoverageDueDateStrategy(getCoverageDueDate);

setTimeout(() => {
startApp([
{
Expand Down
Loading