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

Nested single day events always shown only with time #2114

Conversation

dzonidoo
Copy link
Contributor

@dzonidoo dzonidoo commented Oct 17, 2024

STT-93

Front-end checklist

  • This pull request is adding missing TypeScript types to modified code segments where it's easy to do so with confidence
  • This pull request is using TypeScript interfaces instead of prop-types and updates usages where it's quick to do so
  • This pull request is using memo or PureComponent to define new React components (and updates existing usages in modified code segments)
  • This pull request is replacing lodash.get with optional chaining and nullish coalescing for modified code segments
  • This pull request is not importing anything from client-core directly (use superdeskApi)
  • This pull request is importing UI components from superdesk-ui-framework and superdeskApi when possible instead of using ones defined in this repository.
  • This pull request is not using planningApi where it is possible to use superdeskApi
  • This pull request is not adding redux based modals
  • In this pull request, properties of redux state are not being passed as props to components; instead, we connect it to the component that needs them. Except components where using a react key is required - do not connect those due to performance reasons.
  • This pull request is not adding redux actions that do not modify state (e.g. only calling angular services; those should be moved to planningApi)

@@ -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, this.props.planningItem?.date);
Copy link
Contributor

Choose a reason for hiding this comment

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

So if planningItem.date is null, this will continue working?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

@@ -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} planningItem={this.props.planningItem} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this component called EventDateTime and we're passing an event item and a planningItem? If it's meant to show both planning & event item times you should rename it accordingly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The component only renders the date and time of the event, but conditionally, when the event's date differs from the planning item's date.

@@ -80,6 +80,10 @@ function isEventSameDay(startingDate: IDateTime, endingDate: IDateTime): boolean
return moment(startingDate).format('DD/MM/YYYY') === moment(endingDate).format('DD/MM/YYYY');
}

function showEventStartDate(eventDate: IDateTime, planningDate: IDateTime): boolean {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since up in the code you're passing a possibly undefined planningDate it only makes sense to make this optional here, and handle the case where planningDate is undefined explicitly

@thecalcc
Copy link
Contributor

@tomaskikutis you can take a look as well if you want, but I feel confident in the review and that this is a simple feature

@superdesk superdesk deleted a comment from dzonidoo Oct 23, 2024
@tomaskikutis
Copy link
Member

I'll take a look

@@ -79,7 +81,7 @@ export class EventDateTime extends React.PureComponent<IProps> {
</span>
)}
<DateTime
withDate={multiDay}
withDate={(showEventStartDate || multiDay)}
Copy link
Member

Choose a reason for hiding this comment

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

Move multiDay check to showEventStartDate function

if (planningDate == null) {
return true;
}
return moment(eventDate).format('DD/MM/YYYY') != moment(planningDate).format('DD/MM/YYYY');
Copy link
Member

Choose a reason for hiding this comment

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

it'd be cleaner to use isSame method from moment. We don't care about date format here

@@ -69,6 +69,7 @@ export class PlanningItemWithEvents extends React.Component<IProps, IState> {
{...this.props.getEventProps(event)}
multiSelectDisabled
key={event._id}
planningItem={planningProps}
Copy link
Member

Choose a reason for hiding this comment

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

planningProps would be a more consistent naming for a prop

@dzonidoo dzonidoo merged commit 73d2311 into superdesk:feature/multiple-events-in-planning Oct 24, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants