[30787] Never persist an unsaved form schema to the schema cache

The form schema got accidentally committed to the schema cache which
resulted in `null` schema hrefs in the cache, breaking all schemas
temporary and resulting to the same schema being used, causing #30787

Instead of committing an unsaved schema, we can use the
`temporaryEditResource` to access the temporary resource while it is not
yet saved, which is what the status button is now doing.

cc0145daf6

https://community.openproject.com/wp/30787
pull/7575/head
Oliver Günther 5 years ago
parent f95c82467f
commit 78f7bc9299
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 19
      frontend/src/app/components/wp-buttons/wp-status-button/wp-status-button.component.ts
  2. 4
      frontend/src/app/components/wp-edit-form/work-package-changeset.ts

@ -60,26 +60,19 @@ export class WorkPackageStatusButtonComponent implements OnInit, OnDestroy {
} }
ngOnInit() { ngOnInit() {
this.wpCacheService this.wpEditing
.observe(this.workPackage.id!) .temporaryEditResource(this.workPackage.id!)
.values$()
.pipe( .pipe(
untilComponentDestroyed(this) untilComponentDestroyed(this)
) )
.subscribe((wp) => { .subscribe((wp) => {
this.workPackage = wp; this.workPackage = wp;
this.cdRef.detectChanges(); this.cdRef.detectChanges();
this.workPackage.status.$load();
});
this.schemaCacheService if (this.workPackage.status) {
.state(this.workPackage) this.workPackage.status.$load();
.changes$() }
.pipe(
untilComponentDestroyed(this)
)
.subscribe(() => {
// we have to explicitly force the component to update
this.cdRef.detectChanges();
}); });
} }

@ -124,10 +124,6 @@ export class WorkPackageChangeset extends EditChangeset<WorkPackageResource> {
.update(payload) .update(payload)
.then((form:FormResource) => { .then((form:FormResource) => {
this.form = form; this.form = form;
if (!this.resource.isNew) {
this.schemaCacheService.state(this.resource).putValue(form.schema);
}
this.rebuildDefaults(form.payload); this.rebuildDefaults(form.payload);
this.buildResource(); this.buildResource();

Loading…
Cancel
Save