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

[EAM-1124] Shift scheduled end date with the start date #108

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JuhQ
Copy link
Contributor

@JuhQ JuhQ commented Apr 20, 2021

This pull request shifts the scheduled end date according to the date difference to the start date, when scheduled start date is changed

const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim();
const initialEndDate = scheduledEndDate.replace('00:00', '').trim();

const dateFormat = 'dd-MMM-yyyy';
Copy link
Member

Choose a reason for hiding this comment

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

We have constants for date formats and datetime formats in eam-components, that can be reused for this.
https://github.com/cern-eam/eam-components/blob/master/src/enums/Constants.js

};
}

const initialStartDate = (scheduledStartDate || value).replace('00:00', '').trim();
Copy link
Member

Choose a reason for hiding this comment

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

Why removing time part instead of processing the date with a datetime format?

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 datepicker gives date format, having time in the format will cause an error. Not sure if the error comes from date-fns format/parse or the datepicker. The datepicker handles dates, not datetimes, the time itself is then not needed. I guess the time values come from the backend?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add Activity dialog seems to be giving current time in the value, will change the hardcoded 00:00 to a regex.

@@ -136,6 +138,40 @@ class Workorder extends Entity {
}
}

updateScheduleProperty = (key, value) => {
Copy link
Member

Choose a reason for hiding this comment

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

Although this implementation can be used for the scheduled start/end dates of a Work Order, we still need the same behavior for the 'Add Activity' dialog start/end dates.

I believe the logic to add the days difference could be extracted in order to be reused.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated the logic to a utils file, it's now used in both places

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