Skip to content

Commit e4a464d

Browse files
YanaDePauwgithub-actions[bot]
authored andcommitted
115284: Add repeatable based on relationship max cardinality
(cherry picked from commit 1055475)
1 parent 2d58de8 commit e4a464d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,22 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
264264
return update && update.field ? update.field.uuid : undefined;
265265
}
266266

267+
/**
268+
* Check whether the current entity can have multiple relationships of this type
269+
* This is based on the max cardinality of the relationship
270+
* @private
271+
*/
272+
private isRepeatable(): boolean {
273+
const isLeft = this.currentItemIsLeftItem$.getValue();
274+
if (isLeft) {
275+
const leftMaxCardinality = this.relationshipType.leftMaxCardinality;
276+
return hasNoValue(leftMaxCardinality) || leftMaxCardinality > 1;
277+
} else {
278+
const rightMaxCardinality = this.relationshipType.rightMaxCardinality;
279+
return hasNoValue(rightMaxCardinality) || rightMaxCardinality > 1;
280+
}
281+
}
282+
267283
/**
268284
* Open the dynamic lookup modal to search for items to add as relationships
269285
*/
@@ -281,6 +297,7 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy {
281297
modalComp.toAdd = [];
282298
modalComp.toRemove = [];
283299
modalComp.isPending = false;
300+
modalComp.repeatable = this.isRepeatable();
284301
modalComp.hiddenQuery = '-search.resourceid:' + this.item.uuid;
285302

286303
this.item.owningCollection.pipe(

0 commit comments

Comments
 (0)