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

Set URL after schema/form changes

Oliver Günther472564352b42
diff --git a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
index 8e96ee7891c..9405aeb237d 100644
--- a/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
+++ b/frontend/src/app/shared/components/fields/edit/field-types/user-edit-field.component.ts
@@ -57,7 +57,11 @@ import {
} from 'rxjs/operators';
import isNewResource from 'core-app/features/hal/helpers/is-new-resource';
import idFromLink from 'core-app/features/hal/helpers/id-from-link';
-import { IUserAutocompleteItem } from 'core-app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component';
+import { IUserAutocompleteItem } from 'core-app/shared/components/autocompleter/user-autocompleter/user-autocompleter.component';
+import {
+ CallableHalLink,
+ HalLink,
+} from 'core-app/features/hal/hal-link/hal-link';
@Component({
templateUrl: './user-edit-field.component.html',
@@ -91,13 +95,10 @@ export class UserEditFieldComponent extends EditFieldComponent implements OnInit
);
}
- ngOnInit():void {
- super.ngOnInit();
-
- if (this.schema.allowedValues) {
- this.setUrl();
- } else {
- this.loadFormAndSetUrl();
+ initialize():void {
+ const link = this.schema.allowedValues as CallableHalLink|undefined;
+ if (link) {
+ this.url = link.$link.href as string;
}
}
@@ -114,17 +115,4 @@ export class UserEditFieldComponent extends EditFieldComponent implements OnInit
return this.handler.handleUserSubmit();
}
-
- private loadFormAndSetUrl():void {
- from(this.change.getForm())
- .pipe(
- tap(() => this.setUrl()),
- take(1),
- ).subscribe();
- }
-
- private setUrl():void {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- this.url = this.schema.allowedValues.$link.href as string;
- }
}