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

Fix custom action spec, fix change detection errors in drop modal teleportation

Benjamin Bädorfd1118119bff5
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.component.ts b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.component.ts
index 5f3c7656497..9b03ba1d003 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.component.ts
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.component.ts
@@ -40,11 +40,11 @@ export const customDateActionAdminSelector = 'custom-date-action-admin';
export class CustomDateActionAdminComponent implements OnInit {
public valueVisible = false;
- public fieldName:string;
+ public fieldName:string = '';
- public fieldValue:string;
+ public fieldValue:string = '';
- public visibleValue:string;
+ public visibleValue:string = '';
public selectedOperator:any;
@@ -68,8 +68,8 @@ export class CustomDateActionAdminComponent implements OnInit {
// cannot use $onInit as it would be called before the operators gets filled
public ngOnInit() {
const element = this.elementRef.nativeElement as HTMLElement;
- this.fieldName = element.dataset.fieldName!;
- this.fieldValue = element.dataset.fieldValue!;
+ this.fieldName = element.dataset.fieldName! || '';
+ this.fieldValue = element.dataset.fieldValue! || '';
if (this.fieldValue === this.currentFieldValue) {
this.selectedOperator = this.operators[1];
diff --git a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
index 2c1e4b60c63..5fe6acfb3fc 100644
--- a/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
+++ b/frontend/src/app/features/work-packages/components/wp-custom-actions/date-action/custom-date-action-admin.html
@@ -14,8 +14,8 @@
<op-single-date-picker
[id]="fieldId + '_visible'"
[name]="fieldId + '_input'"
- [initialDate]="fieldValue"
- (changed)="updateField($event)"
+ [value]="fieldValue"
+ (valueChange)="updateField($event)"
classes="form--text-field">
</op-single-date-picker>
</span>
diff --git a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relation-create.template.html b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relation-create.template.html
index 815cff0bf0d..47b1b19ee62 100644
--- a/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relation-create.template.html
+++ b/frontend/src/app/features/work-packages/components/wp-relations/wp-relations-create/wp-relation-create.template.html
@@ -28,7 +28,7 @@
id="relation-type--select"
role="listbox"
[(ngModel)]="selectedRelationType"
- opAutoFocus>
+ opAutofocus>
<option *ngFor="let type of relationTypes"
[textContent]="type.label"
[value]="type.name"></option>
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 00d3f54248b..d2330cfdc6c 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
@@ -166,6 +166,7 @@ export class OpSingleDatePickerComponent implements ControlValueAccessor, AfterC
this.onChange(this.workingValue);
this.writeValue(this.workingValue);
this.opened = false;
+ this.cdRef.detectChanges();
}
setToday():void {
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 e0b74b8e985..7fafd0ee8b3 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
@@ -38,6 +38,7 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';
[(ngModel)]="value"
[id]="handler.htmlId"
class="inline-edit--field"
+ [opAutofocus]
></op-single-date-picker>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
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.ts
index 76212962aed..2a44d850ce3 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,4 +1,5 @@
import {
+ OnInit,
AfterViewChecked,
ChangeDetectionStrategy,
Component,
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.ts
index ed9519d77c6..cff64acc36f 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
@@ -128,6 +128,7 @@ export class SpotDropModalComponent implements OnDestroy {
this._opened = true;
this.repositionAnchor();
this.updateAppHeight();
+ this.cdRef.detectChanges();
/*
* If we don't activate the body after one tick, angular will complain because
@@ -173,7 +174,9 @@ export class SpotDropModalComponent implements OnDestroy {
close():void {
this._opened = false;
+ this.closed.emit();
this.teleportationService.clear();
+ this.cdRef.detectChanges();
/*
* The same as with opening; if we don't deactivate the body after
@@ -195,7 +198,6 @@ close():void {
take(1),
)
.subscribe(() => {
- this.closed.emit();
this.cdRef.detectChanges();
});
}
diff --git a/spec/features/work_packages/custom_actions/custom_actions_spec.rb b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
index 2b72a64dbd7..9c609a81d49 100644
--- a/spec/features/work_packages/custom_actions/custom_actions_spec.rb
+++ b/spec/features/work_packages/custom_actions/custom_actions_spec.rb
@@ -293,6 +293,7 @@ describe 'Custom actions', js: true do
find("#custom_action_actions_custom_field_#{date_custom_field.id}_visible").click
datepicker = Components::Datepicker.new 'body'
datepicker.set_date date
+ datepicker.save!
new_ca_page.add_action('Type', other_type.name)
new_ca_page.expect_action('type', other_type.id)
diff --git a/spec/support/pages/admin/custom_actions/form.rb b/spec/support/pages/admin/custom_actions/form.rb
index b5a077d489f..a7f4226acbd 100644
--- a/spec/support/pages/admin/custom_actions/form.rb
+++ b/spec/support/pages/admin/custom_actions/form.rb
@@ -36,6 +36,7 @@ module Pages
include ::Components::Autocompleter::NgSelectAutocompleteHelpers
def set_name(name)
+ fill_in 'Name', with: ''
fill_in 'Name', with: name
end