From a95bf63ad0d2643a12f92c128aea458f50249d1a Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Thu, 20 Jan 2022 18:14:29 +0100 Subject: [PATCH] [CST-4633] Fix issue with already selected relationship in the dynamic-lookup-relation-search-tab.component --- .../dynamic-lookup-relation-search-tab.component.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts index 5a6b07fd44..f70f073743 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts @@ -234,7 +234,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest * @param idOfItems the uuid of items that are being checked * @param resultListOfItems the list of results of the items */ - setSelectedIds(idOfItems, resultListOfItems) { + setSelectedIds(idOfItems: string[], resultListOfItems: SearchResult[]) { let relationType = this.relationshipType.rightwardType; if ( this.isLeft ) { relationType = this.relationshipType.leftwardType; @@ -254,7 +254,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest } const uuid = arrUrl[ arrUrl.length - 1 ]; - return this.getRelatedItem(uuid,resultListOfItems); + return this.getRelatedItem(uuid, resultListOfItems); }); selectableObject = selectableObject.filter( (selObject) => { @@ -274,11 +274,11 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest this.allSelected = false; this.selection$ .pipe(take(1)) - .subscribe((selection: SearchResult[]) => this.deselectObject.emit(...selection)); + .subscribe((selection: SearchResult[]) => this.deselectObject.emit(...selection)); this.selectableListService.deselectAll(this.listId); } - getRelatedItem(uuid: string, resultList: SearchResult[]) { + getRelatedItem(uuid: string, resultList: SearchResult[]) { return resultList.find( (resultItem) => { return resultItem.indexableObject.uuid === uuid; }); @@ -295,14 +295,13 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest } onResultFound($event: SearchObjects) { - console.log($event); this.resultsRD$.next($event); this.resultFound.emit($event); if (this.isEditRelationship ) { const idOfItems = $event.page.map( itemSearchResult => { return itemSearchResult.indexableObject.uuid; }); - this.setSelectedIds(idOfItems, $event); + this.setSelectedIds(idOfItems, $event.page); } } }