From c4b25653733323812b4531952d0fd98acb906208 Mon Sep 17 00:00:00 2001 From: Yury Bondarenko Date: Fri, 9 Jun 2023 13:39:28 +0200 Subject: [PATCH] Workaround: don't use form-global data for check Note: we're balancing multiple bugs against eachother here, not ideal! - the diff doesn't catch removed Relationship fields; instead, form reload is triggered by a dspace.entity.type change - if we add the original `this.sectionMetadata.includes(key)` check, we filter out this change and the form fails to update - if we add `relation.*` fields to `this.sectionMetadata`, newly added Relationship entries are duplicated As of this commit, the form _seems_ to work in a stable way, but these issues shoud really investigated in more detail. --- src/app/submission/sections/form/section-form.component.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/submission/sections/form/section-form.component.ts b/src/app/submission/sections/form/section-form.component.ts index 9612db523c..3fa9000039 100644 --- a/src/app/submission/sections/form/section-form.component.ts +++ b/src/app/submission/sections/form/section-form.component.ts @@ -229,8 +229,10 @@ export class SubmissionSectionFormComponent extends SectionModelComponent { const sectionDataToCheck = {}; Object.keys(sectionData).forEach((key) => { - if (this.sectionData.data && hasValue(this.sectionData.data[key]) && this.inCurrentSubmissionScope(key)) { - sectionDataToCheck[key] = this.sectionData.data[key]; + // todo: removing Relationships works due to a bug -- dspace.entity.type is included in sectionData, which is what triggers the update; + // if we use this.sectionMetadata.includes(key), this field is filtered out and removed Relationships won't disappear from the form. + if (this.inCurrentSubmissionScope(key)) { + sectionDataToCheck[key] = sectionData[key]; } });