[33901] Disable the button and disallow editing for scheduled parents

https://community.openproject.com/wp/33901
pull/8517/head
Oliver Günther 4 years ago
parent 23d5eb925b
commit e80fcfbeac
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 1
      frontend/src/app/components/datepicker/datepicker.modal.html
  2. 7
      frontend/src/app/components/datepicker/datepicker.modal.sass
  3. 17
      frontend/src/app/components/datepicker/datepicker.modal.ts
  4. 8
      spec/features/work_packages/table/scheduling/manual_scheduling_spec.rb

@ -136,6 +136,7 @@
[textContent]="text.cancel">
</a>
<a (click)="save()"
[attr.disabled]="!this.isSavable || undefined"
class="datepicker-modal--action"
[textContent]="text.save">
</a>

@ -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

@ -138,14 +138,23 @@ export class DatePickerModal extends OpModalComponent implements AfterViewInit {
}
save():void {
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.changeset.setValue('scheduleManually', this.scheduleManually);
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.

@ -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

Loading…
Cancel
Save