Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/feature/multiple-events-in-pla…
Browse files Browse the repository at this point in the history
…nning' into adding-related-items-to-plannings-and-events
  • Loading branch information
tomaskikutis committed Oct 28, 2024
2 parents 8741a9d + 421c19b commit d64ce28
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
6 changes: 4 additions & 2 deletions client/components/Events/EventDateTime.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import {superdeskApi} from '../../superdeskApi';
import {IEventItem} from '../../interfaces';
import {IEventItem, IPlanningListItemProps} from '../../interfaces';

import {eventUtils, timeUtils} from '../../utils';

Expand All @@ -13,6 +13,7 @@ interface IProps {
item: IEventItem;
ignoreAllDay?: boolean;
displayLocalTimezone?: boolean;
planningProps?: IPlanningListItemProps;
}

export class EventDateTime extends React.PureComponent<IProps> {
Expand All @@ -23,6 +24,7 @@ export class EventDateTime extends React.PureComponent<IProps> {
const end = eventUtils.getEndDate(item);
const isAllDay = eventUtils.isEventAllDay(start, end);
const multiDay = !eventUtils.isEventSameDay(start, end);
const showEventStartDate = eventUtils.showEventStartDate(start, multiDay, this.props.planningProps?.date);
const isRemoteTimeZone = timeUtils.isEventInDifferentTimeZone(item);
const withYear = multiDay && start.year() !== end.year();
const localStart = timeUtils.getLocalDate(start, item.dates.tz);
Expand Down Expand Up @@ -79,7 +81,7 @@ export class EventDateTime extends React.PureComponent<IProps> {
</span>
)}
<DateTime
withDate={multiDay}
withDate={showEventStartDate}
withYear={withYear}
date={start}
{...commonProps}
Expand Down
5 changes: 3 additions & 2 deletions client/components/Events/EventDateTimeColumn.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import moment from 'moment-timezone';

import {IEventItem} from '../../interfaces';
import {IEventItem, IPlanningListItemProps} from '../../interfaces';
import {superdeskApi} from '../../superdeskApi';

import {eventUtils, timeUtils} from '../../utils';
Expand All @@ -13,6 +13,7 @@ import {EventDateTime} from './EventDateTime';
interface IProps {
item: IEventItem;
multiRow?: boolean;
planningProps?: IPlanningListItemProps;
}

export class EventDateTimeColumn extends React.PureComponent<IProps> {
Expand All @@ -23,7 +24,7 @@ export class EventDateTimeColumn extends React.PureComponent<IProps> {
return (
<Column border={false} className="flex-justify--start sd-padding-t--1">
<Row classes="sd-margin--0">
<EventDateTime item={this.props.item} />
<EventDateTime item={this.props.item} planningProps={this.props.planningProps} />
</Row>
</Column>
);
Expand Down
1 change: 1 addition & 0 deletions client/components/Events/EventItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class EventItemComponent extends React.Component<IProps, IState> {
<EventDateTimeColumn
item={item}
multiRow={listViewType === LIST_VIEW_TYPE.LIST}
planningProps={this.props.planningProps}
/>
{listViewType === LIST_VIEW_TYPE.SCHEDULE ? null : (
<CreatedUpdatedColumn
Expand Down
3 changes: 2 additions & 1 deletion client/components/Planning/PlanningItemWithEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class PlanningItemWithEvents extends React.Component<IProps, IState> {
return (
<WithLiveResources resources={[{resource: 'events', ids: this.props.relatedEventIds}]}>
{([res]) => (
<div>
<div style={{display: 'contents'}}>
{
res._items.map((item) => {
const event = eventUtils.modifyForClient(item);
Expand All @@ -69,6 +69,7 @@ export class PlanningItemWithEvents extends React.Component<IProps, IState> {
{...this.props.getEventProps(event)}
multiSelectDisabled
key={event._id}
planningProps={planningProps}
/>
);
})
Expand Down
1 change: 1 addition & 0 deletions client/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ export interface IAssignmentItem extends IBaseRestApiResponse {

export interface IBaseListItemProps<T> {
item: T;
planningProps?: IPlanningListItemProps;
lockedItems: ILockedItems;
session: ISession;
privileges: {[key: string]: number};
Expand Down
8 changes: 8 additions & 0 deletions client/utils/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ function isEventSameDay(startingDate: IDateTime, endingDate: IDateTime): boolean
return moment(startingDate).format('DD/MM/YYYY') === moment(endingDate).format('DD/MM/YYYY');
}

function showEventStartDate(eventDate: IDateTime, multiDay: boolean, planningDate?: IDateTime): boolean {
if (planningDate == null) {
return true;
}
return (!moment(eventDate).isSame(planningDate, 'day') || multiDay);
}

function eventHasPlanning(event: IEventItem): boolean {
return get(event, 'planning_ids', []).length > 0;
}
Expand Down Expand Up @@ -1557,6 +1564,7 @@ const self = {
canConvertToRecurringEvent,
canUpdateEventRepetitions,
isEventSameDay,
showEventStartDate,
isEventRecurring,
getDateStringForEvent,
getEventActions,
Expand Down

0 comments on commit d64ce28

Please sign in to comment.