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.
This commit is contained in:
Yury Bondarenko
2023-06-09 13:39:28 +02:00
parent d4efd85cc5
commit c4b2565373

View File

@@ -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];
}
});