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 editor specs
Benjamin Bädorf207b11128d2d
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 a0cbc7a78de..1fca9847331 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@@ -265,8 +265,6 @@ export class OpWpMultiDateFormComponent extends UntilDestroyedMixin implements Athis.scheduleManually = !!this.changeset.value('scheduleManually');this.ignoreNonWorkingDays = !!this.changeset.value('ignoreNonWorkingDays');- console.log('onInit', this.scheduleManually);-// Ensure we get the writable values from the loaded formvoid this.changesetdiff --git a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.tsindex 14c29209103..a6433eb4c79 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/combined-date-edit-field.component.ts@@ -71,7 +71,6 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponentpublic cancel():void {this.handler.reset();this.onModalClosed();- this.cdRef.markForCheck();}// Overwrite super in order to set the initial dates.diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.tsindex bf2d0324f2d..6714ee2a156 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts+++ b/frontend/src/app/spot/components/drop-modal/drop-modal-portal.component.ts@@ -1,6 +1,8 @@import {AfterViewChecked,+ ChangeDetectionStrategy,Component,+ ElementRef,} from '@angular/core';import { SpotDropModalTeleportationService } from './drop-modal-teleportation.service';@@ -9,13 +11,16 @@ export const spotDropModalPortalComponentSelector = 'spot-drop-modal-portal';@Component({selector: spotDropModalPortalComponentSelector,template: '<ng-container *ngTemplateOutlet="template$ | async"></ng-container>',+ changeDetection: ChangeDetectionStrategy.OnPush,})export class SpotDropModalPortalComponent implements AfterViewChecked {+constructor(- readonly template$: SpotDropModalTeleportationService,+ readonly template$:SpotDropModalTeleportationService,+ readonly elementRef:ElementRef,) { }ngAfterViewChecked(): void {- this.template$.hasRendered$.next();+ this.template$.hasRendered$.next(!!this.elementRef.nativeElement.children.length);}}diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal-teleportation.service.ts b/frontend/src/app/spot/components/drop-modal/drop-modal-teleportation.service.tsindex 31773f6637e..e6111e376fe 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal-teleportation.service.ts+++ b/frontend/src/app/spot/components/drop-modal/drop-modal-teleportation.service.ts@@ -3,13 +3,16 @@ import {TemplateRef,} from '@angular/core';import { BehaviorSubject, Subject } from 'rxjs';+import { distinctUntilChanged } from 'rxjs/operators';export type TeleportInstance = TemplateRef<any>;@Injectable({ providedIn: 'root' })export class SpotDropModalTeleportationService extends BehaviorSubject<TeleportInstance|null> {- public hasRendered$ = new Subject();+ public hasRendered$ = new Subject<boolean>();++ public hasRenderedFiltered$ = this.hasRendered$.pipe(distinctUntilChanged());constructor() {super(null);diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.tsindex 457f4b7e6d5..e7d9b7ef086 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts@@ -16,7 +16,7 @@ import { I18nService } from 'core-app/core/i18n/i18n.service';import { findAllFocusableElementsWithin } from 'core-app/shared/helpers/focus-helpers';import SpotDropAlignmentOption from '../../drop-alignment-options';import { SpotDropModalTeleportationService } from './drop-modal-teleportation.service';-import { take } from 'rxjs/operators';+import { filter, take } from 'rxjs/operators';import { debounce } from 'lodash';const findClippingParent = (el:HTMLElement):HTMLElement => {@@ -139,8 +139,12 @@ export class SpotDropModalComponent implements OnDestroy {this.teleportationService.activate(this.body)});- this.teleportationService.hasRendered$- .pipe(take(1))+ this.teleportationService+ .hasRenderedFiltered$+ .pipe(+ filter((hasRendered) => hasRendered),+ take(1),+ ).subscribe(() => {/** We have to set these listeners next tick, because they're so far up the tree.@@ -177,12 +181,6 @@ export class SpotDropModalComponent implements OnDestroy {*/setTimeout(() => {this.teleportationService.clear();- this._opened = false;- this.cdRef.markForCheck();- });-- this.teleportationService.hasRendered$.pipe(take(1)).subscribe(() => {- this.closed.emit();document.body.removeEventListener('click', this.onGlobalClick);document.body.removeEventListener('keydown', this.onEscape);@@ -190,6 +188,18 @@ export class SpotDropModalComponent implements OnDestroy {window.removeEventListener('resize', this.onResize);window.removeEventListener('orientationchange', this.onResize);});++ this.teleportationService+ .hasRenderedFiltered$+ .pipe(+ filter((hasRendered) => !hasRendered),+ take(1),+ )+ .subscribe(() => {+ this._opened = false;+ this.closed.emit();+ this.cdRef.markForCheck();+ });}private onGlobalClick = this.close.bind(this);diff --git a/spec/features/work_packages/details/date_editor_spec.rb b/spec/features/work_packages/details/date_editor_spec.rbindex cc30a5e2ce8..0a5d739aa8c 100644--- a/spec/features/work_packages/details/date_editor_spec.rb+++ b/spec/features/work_packages/details/date_editor_spec.rb@@ -299,6 +299,7 @@ describe 'date inplace editor',# Open date pickercf_field.input_element.clickdatepicker.set_date Time.zone.today+ datepicker.save!create_page.edit_field(:subject).set_value 'My subject!'create_page.save!diff --git a/spec/support/components/datepicker/datepicker.rb b/spec/support/components/datepicker/datepicker.rbindex 6715f064f8c..e664aa3eba7 100644--- a/spec/support/components/datepicker/datepicker.rb+++ b/spec/support/components/datepicker/datepicker.rb@@ -75,6 +75,10 @@ module Componentsselect_day date.dayend+ def save!+ container.find('[data-qa-selector="op-datepicker-modal"] .button', text: "Save").click+ end+### Expect the selected monthdef expect_month(month)