Fix deriving due date if altering start date in range (Fix scenario 14)

pull/11151/head
Oliver Günther 2 years ago
parent b28220cacc
commit af3050f77c
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 11
      frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
  2. 14
      spec/features/work_packages/datepicker/datepicker_logic_spec.rb

@ -585,7 +585,7 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
const parsedEndDate = parseDate(this.dates.end || '') as Date;
if (selectedDate < parsedStartDate) {
this.applyNewDates([selectedDate, parsedEndDate]);
this.applyNewDates([selectedDate]);
this.setCurrentActivatedField('end');
} else if (selectedDate > parsedEndDate) {
if (activeField === 'end') {
@ -616,6 +616,15 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
if (this.dates.start && this.dates.end) {
this.formUpdates$.next({ startDate: this.dates.start, dueDate: this.dates.end });
}
// If only one is set, derive from duration
if (this.dates.start && !this.dates.end && !!this.duration) {
this.formUpdates$.next({ startDate: this.dates.start, duration: this.durationAsIso8601 });
}
if (this.dates.end && !this.dates.start && !!this.duration) {
this.formUpdates$.next({ dueDate: this.dates.end, duration: this.durationAsIso8601 });
}
}
private onDataChange() {

@ -574,20 +574,20 @@ describe 'Datepicker modal logic test cases (WP #43539)',
datepicker.select_day 5
datepicker.expect_start_date '2021-02-05'
datepicker.expect_due_date '2021-02-11'
datepicker.expect_duration 5
datepicker.expect_due_date '2021-02-10'
datepicker.expect_duration 4
# Focus is on finish date
datepicker.expect_due_highlighted
datepicker.select_day 10
datepicker.select_day 15
datepicker.expect_start_date '2021-02-05'
datepicker.expect_due_date '2021-02-10'
datepicker.expect_duration 4
datepicker.expect_due_date '2021-02-15'
datepicker.expect_duration 7
apply_and_expect_saved duration: 4,
apply_and_expect_saved duration: 7,
start_date: Date.parse('2021-02-05'),
due_date: Date.parse('2021-02-10')
due_date: Date.parse('2021-02-15')
end
end

Loading…
Cancel
Save