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

Single date picker works in time entry modal

Benjamin Bädorfa066f8335048
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
index b2ba520c35f..8c453810344 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
+++ b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.html
@@ -38,7 +38,7 @@
>
<spot-text-field
slot="input"
- name="date"
+ name="startDate"
class="op-datepicker-modal--date-field"
[attr.data-qa-highlighted]="showFieldAsActive('start') || undefined"
[ngClass]="{'op-datepicker-modal--date-field_current' : showFieldAsActive('start')}"
@@ -61,7 +61,7 @@
>
<spot-text-field
slot="input"
- name="date"
+ name="endDate"
class="op-datepicker-modal--date-field"
[attr.data-qa-highlighted]="showFieldAsActive('end') || undefined"
[ngClass]="{'op-datepicker-modal--date-field_current' : showFieldAsActive('end')}"
@@ -87,10 +87,6 @@
<div #flatpickrTarget></div>
<div class="spot-action-bar">
- <div class="spot-action-bar--left">
- {{ dates.start }}
- {{ dates.end }}
- </div>
<div class="spot-action-bar--right">
<button
type="button"
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
index 60af539bac9..e1b8a3b31c2 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-picker/multi-date-picker.component.ts
@@ -162,7 +162,6 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
filter(() => !!this.datePickerInstance),
)
.subscribe(([field, update]) => {
- console.log('update', field, update);
// When clearing the one date, clear the others as well
if (update !== null) {
this.handleSingleDateUpdate(field, update);
@@ -255,7 +254,6 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
this.onTouched();
if (dates.length === 2) {
- console.log('two dates', dates);
this.setDates(dates[0], dates[1]);
this.toggleCurrentActivatedField();
this.cdRef.detectChanges();
@@ -265,7 +263,6 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
// Update with the same flow as entering a value
const { latestSelectedDateObj } = instance as { latestSelectedDateObj:Date };
const activeField = this.currentlyActivatedDateField;
- console.log('one date', dates, latestSelectedDateObj, activeField);
this.handleSingleDateUpdate(activeField, latestSelectedDateObj);
this.cdRef.detectChanges();
},
@@ -306,10 +303,6 @@ export class OpMultiDatePickerComponent extends UntilDestroyedMixin implements O
private setDates(newStart:Date, newEnd:Date) {
this.dates.start = this.timezoneService.formattedISODate(newStart);
this.dates.end = this.timezoneService.formattedISODate(newEnd);
- console.log(newStart, newEnd, { ...this.dates });
- setTimeout(() => {
- console.log(newStart, newEnd, { ...this.dates });
- }, 50);
}
private handleSingleDateUpdate(activeField:DateFields, selectedDate:Date) {
diff --git a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
index 224259bfd90..5a5d692531e 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-picker/single-date-picker.component.ts
@@ -90,8 +90,6 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor {
public datePickerInstance:DatePicker;
- public entityName = '';
-
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -123,12 +121,13 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor {
$event.preventDefault();
this.valueChange.emit(this.workingValue);
this.onChange(this.workingValue);
+ this.writeValue(this.workingValue);
this.close();
}
setToday():void {
const today = parseDate(new Date()) as Date;
- this.workingDate = today;
+ this.writeWorkingValue(this.timezoneService.formattedISODate(today));
this.enforceManualChangesToDatepicker(today);
}
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
index db77b3bb1aa..6335318d9bf 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts
@@ -26,44 +26,35 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import * as moment from 'moment';
import { EditFieldComponent } from 'core-app/shared/components/fields/edit/edit-field.component';
import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';
-import { OpModalService } from 'core-app/shared/components/modal/modal.service';
import { TimezoneService } from 'core-app/core/datetime/timezone.service';
@Component({
template: `
- <!--op-single-date-picker
- tabindex="-1"
- (changed)="onValueSelected($event)"
- (canceled)="onCancel()"
- (blurred)="submit($event)"
- (enterPressed)="submit($event)"
- [value]="formatter(value)"
- [required]="required"
- [disabled]="inFlight"
+ <op-single-date-picker
+ [(ngModel)]="value"
[id]="handler.htmlId"
classes="inline-edit--field"
- ></op-single-date-picker-->
+ ></op-single-date-picker>
`,
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DateEditFieldComponent extends EditFieldComponent implements OnInit {
@InjectField() readonly timezoneService:TimezoneService;
- @InjectField() opModalService:OpModalService;
-
ngOnInit():void {
super.ngOnInit();
}
- public onValueSelected(data:string):void {
- this.value = this.parser(data);
+ public get value() {
+ return this.formatter(this.resource[this.name]) || '';
}
- public submit(data:string):void {
- this.onValueSelected(data);
+ public set value(value:any) {
+ this.resource[this.name] = this.parseValue(value);
void this.handler.handleUserSubmit();
}
@@ -71,13 +62,6 @@ export class DateEditFieldComponent extends EditFieldComponent implements OnInit
this.handler.handleUserCancel();
}
- public parser(data:string):string|null {
- if (moment(data, 'YYYY-MM-DD', true).isValid()) {
- return data;
- }
- return null;
- }
-
public formatter(data:string):string|null {
if (moment(data, 'YYYY-MM-DD', true).isValid()) {
const d = this.timezoneService.parseDate(data);
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.module.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.module.ts
index 3ec917e9b04..bc9762aff1b 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.module.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.module.ts
@@ -1,13 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { DateEditFieldComponent } from 'core-app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component';
+import { OpSharedModule } from 'core-app/shared/shared.module';
@NgModule({
- declarations: [
- DateEditFieldComponent,
- ],
imports: [
CommonModule,
+ OpSharedModule,
+ ],
+ declarations: [
+ DateEditFieldComponent,
],
exports: [
DateEditFieldComponent,
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
index 6742d979d58..cfd525030cc 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-picker-edit-field.component.ts
@@ -69,6 +69,7 @@ export abstract class DatePickerEditFieldComponent extends EditFieldComponent im
}
public showDatePickerModal():void {
+ console.log('show datepicker modal');
/*
const component = this.change.schema.isMilestone ? SingleDateModalComponent : MultiDateModalComponent;
this.opModalService.show<SingleDateModalComponent|MultiDateModalComponent>(
diff --git a/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.html b/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.html
index 1a19c1ad72d..8d8156c5e8c 100644
--- a/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.html
+++ b/frontend/src/app/shared/components/grids/widgets/project-details/project-details.component.html
@@ -19,9 +19,10 @@
[attributeScope]="'Project'"></attribute-help-text>
</div>
<div class="attributes-map--value">
- <op-editable-attribute-field [resource]="project"
- [fieldName]="cf.key">
- </op-editable-attribute-field>
+ <op-editable-attribute-field
+ [resource]="project"
+ [fieldName]="cf.key"
+ ></op-editable-attribute-field>
</div>
</ng-container>
</div>
diff --git a/frontend/src/app/shared/components/time_entries/form/form.component.html b/frontend/src/app/shared/components/time_entries/form/form.component.html
index 998a5eb750f..6aed2845647 100644
--- a/frontend/src/app/shared/components/time_entries/form/form.component.html
+++ b/frontend/src/app/shared/components/time_entries/form/form.component.html
@@ -2,7 +2,8 @@
#editForm
[resource]="entry"
[inEditMode]="inEditMode"
- (onSaved)="signalModifiedEntry($event)">
+ (onSaved)="signalModifiedEntry($event)"
+>
<div class="attributes-map">
<ng-container *ngIf="showUserField && schema.user.writable">
<div class="attributes-map--key"
@@ -21,7 +22,7 @@
[ngClass]="{'-required': isRequired('spentOn')}"
[textContent]="schema.spentOn.name">
</div>
- <div class="attributes-map--value">
+ <div class="attributes-map--value attributes-map--value_overflow">
<op-editable-attribute-field [resource]="entry"
[wrapperClasses]="'-tiny'"
[fieldName]="'spentOn'">
diff --git a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html b/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html
index d235c28cd81..dda1a8d383e 100644
--- a/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html
+++ b/frontend/src/app/shared/components/time_entries/shared/modal/base.modal.html
@@ -1,5 +1,5 @@
<div
- class="spot-modal loading-indicator--location"
+ class="spot-modal spot-modal_allow-overflow loading-indicator--location"
data-indicator-name="modal"
>
<div class="spot-modal--header">
@@ -9,38 +9,42 @@
<div class="spot-divider"></div>
- <div class="ngdialog-body spot-modal--body spot-container">
- <te-form #editForm
- [changeset]="changeset"
- [showWorkPackageField]="showWorkPackageField"
- [showUserField]="showUserField"
- (modifiedEntry)="setModifiedEntry($event)">
- </te-form>
+ <div class="spot-modal--body spot-modal--body_no-scroll spot-container">
+ <te-form
+ #editForm
+ [changeset]="changeset"
+ [showWorkPackageField]="showWorkPackageField"
+ [showUserField]="showUserField"
+ (modifiedEntry)="setModifiedEntry($event)"
+ ></te-form>
</div>
<div class="spot-action-bar">
<div class="spot-action-bar--left">
- <button class="button button_no-margin -danger spot-action-bar--action"
- *ngIf="deleteAllowed"
- (click)="destroy()"
- [textContent]="text.delete"
- [attr.title]="text.delete">
- </button>
+ <button
+ class="button button_no-margin -danger spot-action-bar--action"
+ *ngIf="deleteAllowed"
+ (click)="destroy()"
+ [textContent]="text.delete"
+ [attr.title]="text.delete"
+ ></button>
</div>
<div class="spot-action-bar--right">
- <button class="button button_no-margin spot-modal--cancel-button spot-action-bar--action"
- *ngIf="saveAllowed"
- (click)="closeMe($event)"
- [textContent]="text.cancel"
- [attr.title]="text.cancel">
- </button>
- <button class="button -highlight button_no-margin spot-action-bar--action"
- *ngIf="saveAllowed"
- (click)="saveEntry()"
- [attr.title]="text.save"
- [textContent]="text.save"
- [disabled]="formInFlight">
- </button>
+ <button
+ class="button button_no-margin spot-modal--cancel-button spot-action-bar--action"
+ *ngIf="saveAllowed"
+ (click)="closeMe($event)"
+ [textContent]="text.cancel"
+ [attr.title]="text.cancel"
+ ></button>
+ <button
+ class="button -highlight button_no-margin spot-action-bar--action"
+ *ngIf="saveAllowed"
+ (click)="saveEntry()"
+ [attr.title]="text.save"
+ [textContent]="text.save"
+ [disabled]="formInFlight"
+ ></button>
</div>
</div>
</div>
diff --git a/frontend/src/app/shared/shared.module.ts b/frontend/src/app/shared/shared.module.ts
index f36664a9ba5..8b8d926454d 100644
--- a/frontend/src/app/shared/shared.module.ts
+++ b/frontend/src/app/shared/shared.module.ts
@@ -69,11 +69,11 @@ import { CopyToClipboardDirective } from './components/copy-to-clipboard/copy-to
import { OpDateTimeComponent } from './components/date/op-date-time.component';
import { ToastComponent } from './components/toaster/toast.component';
-import { OpWpSingleDateFormComponent } from './components/datepicker/wp-single-date-form/wp-single-date-form.component';
-import { OpSingleDatePickerComponent } from './components/datepicker/single-date-picker/single-date-picker.component';
-import { OpMultiDatePickerComponent } from './components/datepicker/multi-date-picker/multi-date-picker.component';
+import { OpWpSingleDateFormComponent } from 'core-app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component';
+import { OpSingleDatePickerComponent } from 'core-app/shared/components/datepicker/single-date-picker/single-date-picker.component';
+import { OpMultiDatePickerComponent } from 'core-app/shared/components/datepicker/multi-date-picker/multi-date-picker.component';
import { OpWpMultiDateFormComponent } from 'core-app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component';
-import { OpDatePickerBannerComponent } from './components/datepicker/banner/datepicker-banner.component';
+import { OpDatePickerBannerComponent } from 'core-app/shared/components/datepicker/banner/datepicker-banner.component';
import { OpDatePickerWorkingDaysToggleComponent } from 'core-app/shared/components/datepicker/toggle/datepicker-working-days-toggle.component';
import { OpDatePickerSchedulingToggleComponent } from 'core-app/shared/components/datepicker/scheduling-mode/datepicker-scheduling-toggle.component';
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.ts b/frontend/src/app/spot/components/text-field/text-field.component.ts
index 3339226004e..b4a68f7f3ad 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.ts
+++ b/frontend/src/app/spot/components/text-field/text-field.component.ts
@@ -103,7 +103,6 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
}
writeValue(value:string) {
- console.log('write value in text-field');
this.value = value || '';
this.cdRef.markForCheck();
}
diff --git a/frontend/src/app/spot/styles/sass/components/modal.sass b/frontend/src/app/spot/styles/sass/components/modal.sass
index 1abf7bb66e2..d111a2080a9 100644
--- a/frontend/src/app/spot/styles/sass/components/modal.sass
+++ b/frontend/src/app/spot/styles/sass/components/modal.sass
@@ -16,11 +16,10 @@
max-width: calc(100vw - 2rem)
max-height: calc(100vh - 2rem)
- overflow-y: auto
-
@media #{$spot-mq-mobile}
width: calc(100vw - 2rem)
max-height: calc(100vh - 5rem)
+ overflow-y: auto
@media (max-height: 480px)
max-height: calc(100vh - 2rem)
@@ -70,6 +69,9 @@
flex-shrink: 1
overflow-y: auto
+ &_no-scroll
+ overflow: visible
+
&:focus
outline-style: none
diff --git a/frontend/src/global_styles/content/_attributes_key_value.sass b/frontend/src/global_styles/content/_attributes_key_value.sass
index ea1f4619367..aa63a89f780 100644
--- a/frontend/src/global_styles/content/_attributes_key_value.sass
+++ b/frontend/src/global_styles/content/_attributes_key_value.sass
@@ -92,3 +92,6 @@
.attributes-map--value
zoom: 1
@include text-shortener(false)
+
+ &_overflow
+ overflow: visible
diff --git a/frontend/src/global_styles/content/work_packages/inplace_editing/_edit_fields.sass b/frontend/src/global_styles/content/work_packages/inplace_editing/_edit_fields.sass
index f5d028a729e..a5be25e0bcc 100644
--- a/frontend/src/global_styles/content/work_packages/inplace_editing/_edit_fields.sass
+++ b/frontend/src/global_styles/content/work_packages/inplace_editing/_edit_fields.sass
@@ -16,7 +16,7 @@
// Style actual edit inputs
// Checkboxes need to be excluded because the width
// causes an ugly increase of the box
- input:not([type='checkbox'])
+ input:not([type='checkbox']):not(.spot-text-field--input):not(.spot-input)
// Full width to inline-edit inputs
width: 100%
// Same height as the row - padding
@@ -28,7 +28,7 @@
border-radius: 2px
&.-tiny
- input:not([type='checkbox'])
+ input:not([type='checkbox']):not(.spot-text-field--input):not(.spot-input)
max-width: 100px
.inline-label