diff --git a/frontend/src/app/components/datepicker/datepicker.modal.html b/frontend/src/app/components/datepicker/datepicker.modal.html index 21c5a1908b..297527cb71 100644 --- a/frontend/src/app/components/datepicker/datepicker.modal.html +++ b/frontend/src/app/components/datepicker/datepicker.modal.html @@ -136,6 +136,7 @@ [textContent]="text.cancel"> diff --git a/frontend/src/app/components/datepicker/datepicker.modal.sass b/frontend/src/app/components/datepicker/datepicker.modal.sass index da06693595..e74d74dc55 100644 --- a/frontend/src/app/components/datepicker/datepicker.modal.sass +++ b/frontend/src/app/components/datepicker/datepicker.modal.sass @@ -41,3 +41,10 @@ grid-column-gap: 30px margin-top: 20px justify-content: end + + .datepicker-modal--action[disabled] + color: var(--gray-dark) + cursor: not-allowed + + &:hover + text-decoration: none diff --git a/frontend/src/app/components/datepicker/datepicker.modal.ts b/frontend/src/app/components/datepicker/datepicker.modal.ts index fb0b4e26c0..aedd3bd12a 100644 --- a/frontend/src/app/components/datepicker/datepicker.modal.ts +++ b/frontend/src/app/components/datepicker/datepicker.modal.ts @@ -138,14 +138,23 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit { } save():void { - if (this.singleDate) { - this.changeset.setValue('date', this.datepickerHelper.mappedDate(this.dates.date)); - } else { - this.changeset.setValue('startDate', this.datepickerHelper.mappedDate(this.dates.start)); - this.changeset.setValue('dueDate', this.datepickerHelper.mappedDate(this.dates.end)); + if (!this.isSavable) { + return; } + // Apply the changed scheduling mode if any this.changeset.setValue('scheduleManually', this.scheduleManually); + + // Apply the dates if they could be changed + if (this.isSchedulable) { + if (this.singleDate) { + this.changeset.setValue('date', this.datepickerHelper.mappedDate(this.dates.date)); + } else { + this.changeset.setValue('startDate', this.datepickerHelper.mappedDate(this.dates.start)); + this.changeset.setValue('dueDate', this.datepickerHelper.mappedDate(this.dates.end)); + } + } + this.closeMe(); } @@ -191,7 +200,7 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit { } showTodayLink(key:DateKeys):boolean { - if (!this.datepickerHelper.isStateOfCurrentActivatedField(key) && !this.isSchedulable) { + if (!this.isSchedulable) { return false; } @@ -213,6 +222,10 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit { return this.scheduleManually || (!this.isParent && !this.isSwitchedFromManualToAutomatic); } + get isSavable():boolean { + return this.isSchedulable || this.isSwitchedFromManualToAutomatic; + } + /** * Determines whether the work package is a parent. It does so * by checking the children links. diff --git a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb index 03fca0d911..b93bf76d2f 100644 --- a/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb +++ b/spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb @@ -57,6 +57,8 @@ describe 'Manual scheduling', js: true do start_date.within_modal do expect(page).to have_selector('input[name="startDate"][disabled]') expect(page).to have_selector('input[name="endDate"][disabled]') + expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Cancel') + expect(page).to have_selector('.datepicker-modal--action[disabled]', text: 'Save') end start_date.toggle_scheduling_mode @@ -66,6 +68,9 @@ describe 'Manual scheduling', js: true do start_date.within_modal do expect(page).to have_selector('input[name="startDate"]:not([disabled])') expect(page).to have_selector('input[name="endDate"]:not([disabled])') + expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Cancel') + expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Save') + end start_date.cancel_by_click @@ -88,6 +93,9 @@ describe 'Manual scheduling', js: true do start_date.within_modal do expect(page).to have_selector('input[name=startDate][disabled]') expect(page).to have_selector('input[name=endDate][disabled]') + expect(page).to have_selector('.datepicker-modal--action:not([disabled])', text: 'Cancel') + expect(page).to have_selector('.datepicker-modal--action[disabled]', text: 'Save') + end start_date.toggle_scheduling_mode