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

allow creation of events without start/end time #2154

Conversation

petrjasek
Copy link
Member

STT-40

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)

@petrjasek petrjasek requested a review from thecalcc December 12, 2024 11:15
@@ -10,22 +9,41 @@ import {Button} from '../../';

import './style.scss';

interface IProps {
value: any;
onChange(value: string): void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably value type can be improved here with string | null since on line 101 you're passing null

@@ -64,7 +82,7 @@ export class TimeInputPopup extends React.Component {
const {onChange, close} = this.props;

if (addMinutes) {
let newTime = moment.clone(this.state.currentTime);
let newTime = moment(this.state.currentTime);
Copy link
Contributor

Choose a reason for hiding this comment

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

can be const

'dates.no_end_time': false,
};

this.props.onChange(changes, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

A second argument null is passed to onChange always here, so if it's easy could you remove that?

localDateToUtc(this.props.item.dates.end, this.props.item.dates.tz)
: null,
'dates.all_day': !hasStartTime,
'dates.no_end_time': hasStartTime,
Copy link
Contributor

Choose a reason for hiding this comment

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

So with this logic if there's a start time there has to also be end time and vise versa? No option for one without the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

there can be no time - all_day is true, or no end time - no_end_time is true, or there must be both.
we can't have just end time

* Combines date from the first argument with time from the second argument
*/
function combineDateTime(date: moment.MomentInput, time: moment.Moment, tz?: string): moment.Moment {
return moment.tz(moment(date).format('YYYY-MM-DD'), tz) // we only want the date part
Copy link
Contributor

Choose a reason for hiding this comment

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

Format is always YYYY-MM-DD on purpose, and we format based on format config later or it's a mistake here?

Copy link
Member Author

Choose a reason for hiding this comment

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

here it's on purpose to only take the date from timestamp and ignore the time

Comment on lines +290 to +291
moment.tz(date, tz).format('YYYY-MM-DD') :
moment(date).format('YYYY-MM-DD')
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

null;
const error = get(this.props.errors ?? {}, field);
const momentValue = value != null ? moment(value) : undefined; // use moment.utc?
const error = get(this.props.errors ?? {}, field) || undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundancy here - if get has to be used might be better to do
get(this.props.errors, field, undefined) if value isn't found, fall back value is returned, in this case would be undefined


const expectedEvent = {
...event,
'dates.end.date': event['dates.start.date'],
Copy link
Contributor

Choose a reason for hiding this comment

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

should there be validation if an event starts & ends at the same time or we automatically treat it as a single day event? Maybe if there's time and start & end have the same values that's invalid?

Copy link
Member Author

Choose a reason for hiding this comment

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

in general that's ok, there can be same values. we don't need to avoid it. but if there is a usecase that's another question 😄

@petrjasek petrjasek requested a review from thecalcc December 13, 2024 10:48
@petrjasek petrjasek merged commit d44272b into superdesk:feature/multiple-events-in-planning Dec 13, 2024
13 checks passed
@petrjasek petrjasek deleted the feat-events-no-time branch December 13, 2024 11:07
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.

2 participants