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

Return promise to allow error handling

Oliver Günther166edbe479a1
diff --git a/frontend/src/app/modules/fields/changeset/resource-changeset.ts b/frontend/src/app/modules/fields/changeset/resource-changeset.ts
index c953ffa2b80..3a25fde5079 100644
--- a/frontend/src/app/modules/fields/changeset/resource-changeset.ts
+++ b/frontend/src/app/modules/fields/changeset/resource-changeset.ts
@@ -73,7 +73,19 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =
* This may be different from the base form when project or type is changed.
*/
public getForm():Promise<FormResource> {
- this.form$.putFromPromiseIfPristine(() => this.updateForm());
+ if (this.form$.isPristine() && !this.form$.hasActivePromiseRequest()) {
+ const promise = this
+ .updateForm()
+ .then((form) => {
+ this.form$.putValue(form);
+ this.setNewDefaults(form);
+ this.push();
+ return form;
+ });
+
+ this.form$.putFromPromiseIfPristine(() => promise);
+ return promise;
+ }
return this
.form$
@@ -96,13 +108,9 @@ export class ResourceChangeset<T extends HalResource|{ [key:string]:unknown; } =
protected updateForm():Promise<FormResource> {
let payload = this.buildPayloadFromChanges();
- return this.pristineResource.$links
- .update(payload)
- .then((form:FormResource) => {
- this.setNewDefaults(form);
- this.push();
- return form;
- });
+ return this.pristineResource
+ .$links
+ .update(payload);
}
/**