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

Remove logs, fix wp single date form initializion

Benjamin Bädorfc218f1c26d3c
diff --git a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html
index 5467c185d83..a5f367a1da1 100644
--- a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html
+++ b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html
@@ -44,6 +44,7 @@
</spot-form-field>
<input
+ #flatpickrTarget
id="flatpickr-input"
hidden
>
diff --git a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts
index 9aa55859ec9..9cfb602055e 100644
--- a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts
+++ b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.ts
@@ -67,6 +67,7 @@ import {
} from 'core-app/shared/components/datepicker/helpers/date-modal.helpers';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { WorkPackageChangeset } from 'core-app/features/work-packages/components/wp-edit/work-package-changeset';
+import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
@Component({
selector: 'op-wp-single-date-form',
@@ -89,12 +90,14 @@ export class OpWpSingleDateFormComponent extends UntilDestroyedMixin implements
@Input() changeset:ResourceChangeset;
- @ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
-
@Output() cancel = new EventEmitter();
@Output() save = new EventEmitter();
+ @ViewChild('flatpickrTarget') flatpickrTarget:ElementRef;
+
+ @ViewChild('modalContainer') modalContainer:ElementRef<HTMLElement>;
+
text = {
save: this.I18n.t('js.button_save'),
cancel: this.I18n.t('js.button_cancel'),
@@ -132,16 +135,25 @@ export class OpWpSingleDateFormComponent extends UntilDestroyedMixin implements
ngOnInit():void {
this.dateModalRelations.setChangeset(this.changeset as WorkPackageChangeset);
this.dateModalScheduling.setChangeset(this.changeset as WorkPackageChangeset);
+ if (!moment(this.value).isValid()) {
+ this.value = '';
+ this.date = '';
+ return;
+ }
this.date = this.timezoneService.formattedISODate(this.value);
}
ngAfterViewInit():void {
- this
- .dateModalRelations
- .getMinimalDateFromPreceeding()
- .subscribe((date) => {
- this.initializeDatepicker(date);
- });
+ if (isNewResource(this.changeset.pristineResource)) {
+ this.initializeDatepicker(null);
+ } else {
+ this
+ .dateModalRelations
+ .getMinimalDateFromPreceeding()
+ .subscribe((date) => {
+ this.initializeDatepicker(date);
+ });
+ }
this
.dateChangedManually$
@@ -234,7 +246,7 @@ export class OpWpSingleDateFormComponent extends UntilDestroyedMixin implements
);
},
},
- null,
+ this.flatpickrTarget.nativeElement,
);
}
diff --git a/frontend/src/app/shared/directives/focus/autofocus.directive.ts b/frontend/src/app/shared/directives/focus/autofocus.directive.ts
index 9752ca4174f..e6e411bf76e 100644
--- a/frontend/src/app/shared/directives/focus/autofocus.directive.ts
+++ b/frontend/src/app/shared/directives/focus/autofocus.directive.ts
@@ -28,7 +28,6 @@ export class AutofocusDirective implements AfterViewInit {
// <my-input opAutofocus />
//
if (this.condition || this.condition === '') {
- console.log('focus', this.elementRef.nativeElement);
this.FocusHelper.focus(this.elementRef.nativeElement);
}
}
diff --git a/spec/features/work_packages/new/new_work_package_spec.rb b/spec/features/work_packages/new/new_work_package_spec.rb
index eb15d010e59..82efe66ca91 100644
--- a/spec/features/work_packages/new/new_work_package_spec.rb
+++ b/spec/features/work_packages/new/new_work_package_spec.rb
@@ -291,7 +291,6 @@ describe 'new work package', js: true do
date_field = wp_page.edit_field(:date)
- byebug
date_field.expect_value(I18n.t('js.label_no_date'))
# Set date
@@ -340,7 +339,6 @@ describe 'new work package', js: true do
create_work_package_globally(type_bug, project.name)
date_field = wp_page.edit_field(:combinedDate)
- byebug
date_field.expect_value("no start date - no finish date")
click_on 'Cancel'
@@ -365,7 +363,6 @@ describe 'new work package', js: true do
# Open datepicker
date_field = wp_page.edit_field(:combinedDate)
- byebug
date_field.click_to_open_datepicker
# Select date