-
Notifications
You must be signed in to change notification settings - Fork 1
TT-85 fix: fix overlapping seconds on time entries #591
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
Changes from 4 commits
8b50d4f
3155406
29da434
85a4c93
1685b88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,29 +197,56 @@ export class DetailsFieldsComponent implements OnChanges, OnInit { | |
this.closeModal?.nativeElement?.click(); | ||
} | ||
|
||
startDateToSubmit(){ | ||
const startDate = this.entryForm.value.start_date; | ||
const initialStartDate = this.entryToEdit.start_date; | ||
const updatedStartDate = new Date(`${startDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(); | ||
const initialStartHour = formatDate(get(this.entryToEdit, 'start_date', '00:00'), 'HH:mm', 'en'); | ||
const updatedStartHour = this.entryForm.value.start_hour; | ||
const startHourHasNotChanged = updatedStartHour === initialStartHour; | ||
const result = startHourHasNotChanged ? initialStartDate : updatedStartDate; | ||
return result; | ||
} | ||
|
||
endDateToSubmit(){ | ||
const endDate = this.entryForm.value.end_date; | ||
const initialEndDate = this.entryToEdit.end_date; | ||
const updatedEndDate = new Date(`${endDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(); | ||
const initialEndHour = formatDate(get(this.entryToEdit, 'end_date', '00:00'), 'HH:mm', 'en'); | ||
const updatedEndHour = this.entryForm.value.end_hour; | ||
const endDateHasNotChanged = updatedEndHour === initialEndHour; | ||
const result = endDateHasNotChanged ? initialEndDate : updatedEndDate; | ||
return result; | ||
} | ||
|
||
onSubmit() { | ||
if (this.entryForm.invalid) { | ||
this.toastrService.warning('Make sure to select a project and activity'); | ||
return; | ||
} | ||
const startDate = this.entryForm.value.start_date; | ||
const endDate = this.entryForm.value.end_date; | ||
|
||
const startDateToSubmit = this.startDateToSubmit(); | ||
const endDateToSubmit = this.endDateToSubmit(); | ||
|
||
const entry = { | ||
project_id: this.entryForm.value.project_id, | ||
activity_id: this.entryForm.value.activity_id, | ||
technologies: get(this, 'selectedTechnologies', []), | ||
description: this.entryForm.value.description, | ||
start_date: new Date(`${startDate}T${this.entryForm.value.start_hour.trim()}`).toISOString(), | ||
end_date: new Date(`${endDate}T${this.entryForm.value.end_hour.trim()}`).toISOString(), | ||
start_date: startDateToSubmit, | ||
end_date: endDateToSubmit, | ||
uri: this.entryForm.value.uri, | ||
timezone_offset: new Date().getTimezoneOffset(), | ||
}; | ||
if (this.goingToWorkOnThis) { | ||
delete entry.end_date; | ||
} | ||
const isStartDateInTheFuture = moment(startDate).isAfter(moment()); | ||
const isEndDateInTheFuture = moment(endDate).isAfter(moment()); | ||
if (isStartDateInTheFuture || isEndDateInTheFuture) { | ||
|
||
const isStartDateInTheFuture = moment(startDateToSubmit).isAfter(moment()); | ||
const isEndDateInTheFuture = moment(endDateToSubmit).isAfter(moment()); | ||
const timeEntryIsInTheFuture = isStartDateInTheFuture || isEndDateInTheFuture; | ||
|
||
if (timeEntryIsInTheFuture) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember we made a change to extract There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried the function of not allowing a "time entry" in the future and it allowed me to add. It ignores the way we put it so I left it as it was. but with the tests, there was no problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok. Then, keep in mind that, when we may want to retake that little refactor. |
||
this.toastrService.error('You cannot start a time-entry in the future'); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change:
dateTest
tocurrentDate
startHourTest
tostartHour
I think is necessary use other name of variable per example
dateTest
todateCurrent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok it's changed