[DURACOM-304] removed unneeded selectAll method (dynamic-lookup-relation-search-tab.component)

This commit is contained in:
Alisa Ismailati
2024-11-21 10:15:00 +01:00
committed by FrancescoMolinaro
parent 3922130434
commit 8453b667cb
2 changed files with 1 additions and 43 deletions

View File

@@ -155,18 +155,6 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
});
});
describe('selectAll', () => {
beforeEach(() => {
spyOn(component.selectObject, 'emit');
component.selectAll();
});
it('should emit the page filtered from already selected objects and call select on the service for all objects', () => {
expect(component.selectObject.emit).toHaveBeenCalledWith(searchResult3);
expect(selectableListService.select).toHaveBeenCalledWith(listID, [searchResult1, searchResult2, searchResult3]);
});
});
describe('deselectAll', () => {
beforeEach(() => {
spyOn(component.deselectObject, 'emit');

View File

@@ -6,12 +6,11 @@ import { SearchResult } from '../../../../../search/models/search-result.model';
import { PaginatedList } from '../../../../../../core/data/paginated-list.model';
import { Observable, BehaviorSubject } from 'rxjs';
import { RelationshipOptions } from '../../../models/relationship-options.model';
import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model';
import { ListableObject } from '../../../../../object-collection/shared/listable-object.model';
import { SearchService } from '../../../../../../core/shared/search/search.service';
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
import { hasValue } from '../../../../../empty.util';
import { map, mapTo, switchMap, take, tap } from 'rxjs/operators';
import { take} from 'rxjs/operators';
import { getFirstSucceededRemoteData, getRemoteDataPayload } from '../../../../../../core/shared/operators';
import { CollectionElementLinkType } from '../../../../../object-collection/collection-element-link.type';
import { Context } from '../../../../../../core/shared/context.model';
@@ -204,35 +203,6 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
this.selectableListService.deselect(this.listId, page);
}
/**
* Select all items that were found using the current search query
*/
selectAll() {
this.allSelected = true;
this.selectAllLoading = true;
const fullPagination = Object.assign(new PaginationComponentOptions(), {
currentPage: 1,
pageSize: 9999
});
const fullSearchConfig = Object.assign(this.lookupRelationService.searchConfig, { pagination: fullPagination });
const results$ = this.searchService.search<Item>(fullSearchConfig);
results$.pipe(
getFirstSucceededRemoteData(),
map((resultsRD) => resultsRD.payload.page),
tap(() => this.selectAllLoading = false),
switchMap((results) => this.selection$.pipe(
take(1),
tap((selection: SearchResult<Item>[]) => {
const filteredResults = results.filter((pageItem) => selection.findIndex((selected) => selected.equals(pageItem)) < 0);
this.selectObject.emit(...filteredResults);
}),
mapTo(results)
))
).subscribe((results) => {
this.selectableListService.select(this.listId, results);
});
}
/**
* setSelectedIds select all the items from the results that have relationship
* @param idOfItems the uuid of items that are being checked