diff --git a/src/app/core/dspace-rest-v2/mocks/mock-submission-response.json b/src/app/core/dspace-rest-v2/mocks/mock-submission-response.json
index 200438d3a0..49f8713df8 100644
--- a/src/app/core/dspace-rest-v2/mocks/mock-submission-response.json
+++ b/src/app/core/dspace-rest-v2/mocks/mock-submission-response.json
@@ -10,7 +10,7 @@
},
"label": "Journal Issue",
"mandatory": true,
- "repeatable": false,
+ "repeatable": true,
"mandatoryMessage": "Required field!",
"hints": "Select a journal issue for this publication.",
"selectableMetadata": [
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.html
index 433501504c..c532cd9575 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.html
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.html
@@ -6,8 +6,9 @@
@@ -69,6 +67,7 @@
[name]="'checkbox' + i"
[id]="'object'+i"
[checked]="isSelected(result.indexableObject)"
+ [disabled]="isDisabled(result.indexableObject)"
(change)="selectCheckbox($event.currentTarget.checked, result.indexableObject)">
selected.uuid === dso.uuid));
+ const completeSelection = [...this.selection, ...this.previousSelection];
+ return hasValue(completeSelection.find((selected) => selected.uuid === dso.uuid));
+ }
+
+ isDisabled(dso: DSpaceObject): boolean {
+ return hasValue(this.previousSelection.find((selected) => selected.uuid === dso.uuid));
}
selectCheckbox(value: boolean, dso: DSpaceObject) {
@@ -98,7 +104,8 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
selectPage(page: SearchResult[]) {
const newObjects: DSpaceObject[] = page
.map((searchResult) => searchResult.indexableObject)
- .filter((dso) => hasNoValue(this.selection.find((selected) => selected.uuid === dso.uuid)));
+ .filter((dso) => hasNoValue(this.selection.find((selected) => selected.uuid === dso.uuid)))
+ .filter((dso) => hasNoValue(this.previousSelection.find((object) => object.uuid === dso.uuid)));
this.selection = [...this.selection, ...newObjects]
}
@@ -119,11 +126,13 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
const fullSearchConfig = Object.assign(this.searchConfig, { pagination: fullPagination });
const results = this.searchService.search(fullSearchConfig);
results.pipe(
- getSucceededRemoteData(),
- map((resultsRD) => resultsRD.payload.page)
- )
+ getSucceededRemoteData(),
+ map((resultsRD) => resultsRD.payload.page)
+ )
.subscribe((results) =>
- this.selection = [...this.selection, ...results.map((searchResult) => searchResult.indexableObject)]
+ this.selection = results
+ .map((searchResult) => searchResult.indexableObject)
+ .filter((dso) => hasNoValue(this.previousSelection.find((object) => object.uuid === dso.uuid)))
);
}
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation.component.ts
index f1d70ee453..88e1e974eb 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation.component.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation.component.ts
@@ -47,6 +47,8 @@ export class DsDynamicLookupRelationComponent extends DynamicFormControlComponen
openLookup() {
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent);
this.modalRef.componentInstance.repeatable = this.model.repeatable;
+ this.modalRef.componentInstance.selection = this.selectedResults || [];
+ this.modalRef.componentInstance.previousSelection = this.model.value || [];
this.modalRef.componentInstance.relationKey = this.model.name;
this.modalRef.result.then((resultList) => {
this.selectedResults = resultList;