Skip to content

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

Multi date picker opens correctly

Benjamin Bädorfd2ca6969d2fa
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.html b/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.html
index 179d199d242..18c6ad23883 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.html
+++ b/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.html
@@ -1,5 +1,5 @@
<form
- class="spot-modal op-datepicker-modal loading-indicator--location"
+ class="spot-modal"
data-qa-selector="op-datepicker-modal"
[attr.id]="htmlId"
#modalContainer
@@ -8,7 +8,7 @@
cdkFocusInitial
cdkTrapFocus
[cdkTrapFocusAutoCapture]="true"
- (submit)="save($event)"
+ (submit)="doSave($event)"
>
<op-datepicker-banner [scheduleManually]="scheduleManually"></op-datepicker-banner>
@@ -112,7 +112,7 @@
<div class="spot-action-bar--right">
<button
type="button"
- (click)="cancel()"
+ (click)="doCancel()"
class="op-datepicker-modal--action spot-modal--cancel-button button button_no-margin spot-action-bar--action"
data-qa-selector="op-datepicker-modal--action"
[textContent]="text.cancel"
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.ts b/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.ts
index d00f275e0a3..dc427a3ba3f 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-form/multi-date-form.component.ts
@@ -38,6 +38,8 @@ import {
ViewChild,
ViewEncapsulation,
OnInit,
+ Output,
+ HostBinding,
} from '@angular/core';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { HalResourceEditingService } from 'core-app/shared/components/fields/edit/services/hal-resource-editing.service';
@@ -111,6 +113,10 @@ export type FieldUpdates =
],
})
export class OpMultiDateFormComponent extends UntilDestroyedMixin implements AfterViewInit, OnInit {
+ @HostBinding('class.op-datepicker-modal') className = true;
+
+ @HostBinding('class.op-datepicker-modal_wide') classNameWide = true;
+
@ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
@ViewChild('durationField', { read: ElementRef }) durationField:ElementRef<HTMLElement>;
@@ -119,6 +125,10 @@ export class OpMultiDateFormComponent extends UntilDestroyedMixin implements Aft
@Input() fieldName:string = '';
+ @Output() cancel = new EventEmitter();
+
+ @Output() save = new EventEmitter();
+
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -302,7 +312,7 @@ export class OpMultiDateFormComponent extends UntilDestroyedMixin implements Aft
this.cdRef.detectChanges();
}
- save($event:Event):void {
+ doSave($event:Event):void {
$event.preventDefault();
// Apply the changed scheduling mode if any
this.changeset.setValue('scheduleManually', this.scheduleManually);
@@ -317,11 +327,11 @@ export class OpMultiDateFormComponent extends UntilDestroyedMixin implements Aft
this.changeset.setValue('duration', this.durationAsIso8601);
}
- // this.closeMe();
+ this.save.emit();
}
- cancel():void {
- // this.closeMe();
+ doCancel():void {
+ this.cancel.emit();
}
updateDate(key:DateKeys, val:string|null):void {
@@ -352,20 +362,6 @@ export class OpMultiDateFormComponent extends UntilDestroyedMixin implements Aft
this.setCurrentActivatedField(nextActive);
}
- // eslint-disable-next-line class-methods-use-this
- reposition(element:JQuery<HTMLElement>, target:JQuery<HTMLElement>):void {
- if (this.deviceService.isMobile) {
- return;
- }
-
- element.position({
- my: 'left top',
- at: 'left bottom',
- of: target,
- collision: 'flipfit',
- });
- }
-
showTodayLink():boolean {
return this.isSchedulable;
}
@@ -452,7 +448,6 @@ export class OpMultiDateFormComponent extends UntilDestroyedMixin implements Aft
instance.calendarContainer.classList.add('op-datepicker-modal--flatpickr-instance');
if (!this.modalPositioned) {
- this.reposition(jQuery(this.modalContainer.nativeElement), jQuery(`.${activeFieldContainerClassName}`));
this.modalPositioned = true;
}
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.ts
index b8356ac9d01..eb07fa614b5 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
@@ -43,6 +43,7 @@ import {
import {
combineLatest,
Observable,
+ ReplaySubject,
Subject,
} from 'rxjs';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
@@ -52,7 +53,7 @@ import { parseDate } from 'core-app/shared/components/datepicker/helpers/date-mo
@Injectable()
export class DateModalRelationsService {
- private changeset$:Subject<WorkPackageChangeset> = new Subject();
+ private changeset$:Subject<WorkPackageChangeset> = new ReplaySubject();
private changeset:WorkPackageChangeset;
setChangeset(changeset:WorkPackageChangeset) {
diff --git a/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.html b/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.html
index e8450ea26fe..cc57de795aa 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.html
+++ b/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.html
@@ -4,7 +4,7 @@
[attr.id]="htmlId"
#modalContainer
data-indicator-name="modal"
- (submit)="save($event)"
+ (submit)="doSave($event)"
tabindex="0"
cdkFocusInitial
cdkTrapFocus
@@ -60,7 +60,7 @@
<div class="spot-action-bar--right">
<button
type="button"
- (click)="cancel()"
+ (click)="doCancel()"
class="op-datepicker-modal--action spot-modal--cancel-button button button_no-margin spot-action-bar--action"
data-qa-selector="op-datepicker-modal--action"
[textContent]="text.cancel"
diff --git a/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.ts b/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.ts
index 4135b55ab79..08810335e6d 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-form/single-date-form.component.ts
@@ -73,7 +73,10 @@ import { WorkPackageChangeset } from 'core-app/features/work-packages/components
@Component({
selector: 'op-single-date-form',
templateUrl: './single-date-form.component.html',
- styleUrls: ['../styles/datepicker.modal.sass', '../styles/datepicker_mobile.modal.sass'],
+ styleUrls: [
+ '../styles/datepicker.modal.sass',
+ '../styles/datepicker_mobile.modal.sass',
+ ],
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
providers: [
@@ -84,14 +87,16 @@ import { WorkPackageChangeset } from 'core-app/features/work-packages/components
export class OpSingleDateFormComponent extends UntilDestroyedMixin implements AfterViewInit, OnInit {
@HostBinding('class.op-datepicker-modal') className = true;
- @Output('savedOrCancelled') savedOrCancelled = new EventEmitter();
-
@Input('value') value = '';
@Input() changeset:ResourceChangeset;
@ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
+ @Output() cancel = new EventEmitter();
+
+ @Output() save = new EventEmitter();
+
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -181,7 +186,7 @@ export class OpSingleDateFormComponent extends UntilDestroyedMixin implements Af
this.cdRef.detectChanges();
}
- save($event:Event):void {
+ doSave($event:Event):void {
$event.preventDefault();
// Apply the changed scheduling mode if any
this.changeset.setValue('scheduleManually', this.scheduleManually);
@@ -194,11 +199,11 @@ export class OpSingleDateFormComponent extends UntilDestroyedMixin implements Af
this.changeset.setValue('date', mappedDate(this.date));
}
- this.savedOrCancelled.emit();
+ this.save.emit();
}
- cancel():void {
- this.savedOrCancelled.emit();
+ doCancel():void {
+ this.cancel.emit();
}
updateDate(val:string|null):void {
diff --git a/frontend/src/app/shared/components/datepicker/styles/datepicker.modal.sass b/frontend/src/app/shared/components/datepicker/styles/datepicker.modal.sass
index c600f26dde5..a89a116d527 100644
--- a/frontend/src/app/shared/components/datepicker/styles/datepicker.modal.sass
+++ b/frontend/src/app/shared/components/datepicker/styles/datepicker.modal.sass
@@ -1,11 +1,15 @@
@import '../../app/spot/styles/sass/variables'
.op-datepicker-modal
+ min-height: 200px
width: 100vw
// Basically the width of the two calendars next to each other + spacings
// will be overwritten on mobile
max-width: 300px
+ &_wide
+ max-width: 500px
+
&--toggle-actions-container
display: grid
grid-template-columns: auto auto 1fr
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.html
index 0d5a11226a3..42fef77d354 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
@@ -1,6 +1,7 @@
<spot-drop-modal
[open]="isOpened"
- (closed)="onModalClosed"
+ (closed)="cancel()"
+ alignment="bottom-center"
>
<button
slot="trigger"
@@ -13,6 +14,8 @@
*ngIf="!isMultiDate"
[value]="dates"
[changeset]="change"
+ (save)="save()"
+ (cancel)="cancel()"
slot="body"
></op-single-date-form>
<op-multi-date-form
@@ -20,6 +23,8 @@
[value]="dates"
[changeset]="change"
[fieldName]="name"
+ (save)="save()"
+ (cancel)="cancel()"
slot="body"
></op-multi-date-form>
</spot-drop-modal>
diff --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.ts
index 63a4d6f6091..01262980d56 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
@@ -36,7 +36,7 @@ import { WorkPackageResource } from 'core-app/features/hal/resources/work-packag
export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent {
dates = '';
- isOpened = false;
+ isOpened = true;
text = {
placeholder: {
@@ -47,7 +47,7 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent
};
get isMultiDate():boolean {
- return this.change.schema.isMilestone;
+ return !this.change.schema.isMilestone;
/*
this
@@ -66,6 +66,14 @@ export class CombinedDateEditFieldComponent extends DatePickerEditFieldComponent
super.onModalClosed();
}
+ public save():void {
+ this.handler.deactivate(true);
+ }
+
+ public cancel():void {
+ this.handler.reset();
+ }
+
// Overwrite super in order to set the initial dates.
protected initialize():void {
super.initialize();