OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix date modal opening for new resources
Benjamin Bädorf581d1b7ea998
diff --git a/frontend/src/app/shared/components/datepicker/services/date-modal-relations.service.ts b/frontend/src/app/shared/components/datepicker/services/date-modal-relations.service.tsindex eb07fa614b5..97d4757f3ca 100644--- a/frontend/src/app/shared/components/datepicker/services/date-modal-relations.service.ts+++ b/frontend/src/app/shared/components/datepicker/services/date-modal-relations.service.ts@@ -39,6 +39,7 @@ import {shareReplay,switchMap,take,+ tap,} from 'rxjs/operators';import {combineLatest,diff --git a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.tsindex 23e2c56438a..514f35f7ef4 100644--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.ts@@ -53,7 +53,6 @@ import {map,switchMap,} from 'rxjs/operators';-import { activeFieldContainerClassName } from 'core-app/shared/components/fields/edit/edit-form/edit-form';import {fromEvent,merge,@@ -80,6 +79,7 @@ import { DatePicker } from '../datepicker';import DateOption = flatpickr.Options.DateOption;import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';+import isNewResource from 'core-app/features/hal/helpers/is-new-resource';export type DateKeys = 'start'|'end';export type DateFields = DateKeys|'duration';@@ -283,17 +283,24 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements A}ngAfterViewInit():void {+ const init = (date:Date|null) => {+ this.initializeDatepicker(date);++ // Autofocus duration if that's what activated us+ if (this.initialActivatedField === 'duration') {+ this.focusHelper.focus(this.durationField.nativeElement);+ }+ };++ if (isNewResource(this.changeset.pristineResource)) {+ init(null);+ return;+ }+this.dateModalRelations.getMinimalDateFromPreceeding()- .subscribe((date) => {- this.initializeDatepicker(date);-- // Autofocus duration if that's what activated us- if (this.initialActivatedField === 'duration') {- this.focusHelper.focus(this.durationField.nativeElement);- }- });+ .subscribe((date) => init(date));}changeSchedulingMode():void {diff --git a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.html b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.htmlindex 6e16b2fa54d..853b63421e4 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.html+++ b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.html@@ -13,7 +13,7 @@/><op-wp-single-date-form- *ngIf="!isMultiDate"+ *ngIf="opened && !isMultiDate"[value]="dates"[changeset]="change"(save)="save()"@@ -21,7 +21,7 @@slot="body"></op-wp-single-date-form><op-wp-multi-date-form- *ngIf="isMultiDate"+ *ngIf="opened && isMultiDate"[value]="dates"[changeset]="change"[fieldName]="name"diff --git a/spec/features/work_packages/new/new_work_package_spec.rb b/spec/features/work_packages/new/new_work_package_spec.rbindex 82efe66ca91..3c30aef9f3a 100644--- a/spec/features/work_packages/new/new_work_package_spec.rb+++ b/spec/features/work_packages/new/new_work_package_spec.rb@@ -291,6 +291,7 @@ describe 'new work package', js: true dodate_field = wp_page.edit_field(:date)+ byebugdate_field.expect_value(I18n.t('js.label_no_date'))# Set date@@ -339,6 +340,7 @@ describe 'new work package', js: true docreate_work_package_globally(type_bug, project.name)date_field = wp_page.edit_field(:combinedDate)+ byebugdate_field.expect_value("no start date - no finish date")click_on 'Cancel'@@ -363,6 +365,7 @@ describe 'new work package', js: true do# Open datepickerdate_field = wp_page.edit_field(:combinedDate)+ byebugdate_field.click_to_open_datepicker# Select date@@ -488,6 +491,7 @@ describe 'new work package', js: true dodate_field = split_create_page.edit_field(:combinedDate)date_field.expect_value("#{parent.start_date} - #{parent.due_date}")+ byebugdate_field.click_to_open_datepickerdate_field.update ['', parent.due_date]diff --git a/spec/support/edit_fields/date_edit_field.rb b/spec/support/edit_fields/date_edit_field.rbindex cd10b846479..f44e1c66d07 100644--- a/spec/support/edit_fields/date_edit_field.rb+++ b/spec/support/edit_fields/date_edit_field.rb@@ -95,7 +95,7 @@ class DateEditField < EditFieldif active?modal_element.find(input_selector)else- page.find(".#{property_name}.-editable")+ page.find(".#{property_name} .spot-input")endend@@ -151,7 +151,7 @@ class DateEditField < EditFieldenddef expect_value(value)- expect(page).to have_selector(".#{property_name}.-editable", text: value)+ expect(page).to have_selector(".#{property_name} .spot-input", value: value)enddef set_active_date(value)