diff --git a/src/app/core/data/item-data.service.ts b/src/app/core/data/item-data.service.ts index 13f74cba9b6..aef5e90f37c 100644 --- a/src/app/core/data/item-data.service.ts +++ b/src/app/core/data/item-data.service.ts @@ -426,7 +426,8 @@ export abstract class BaseItemDataService extends IdentifiableDataService * @param linksToFollow List of {@link FollowLinkConfig} that indicate which * {@link HALLink}s should be automatically resolved */ - public findItemsWithEdit(options: FindListOptions, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { + public findItemsWithEdit(query: string, options: FindListOptions, useCachedVersionIfAvailable = true, reRequestOnStale = true, ...linksToFollow: FollowLinkConfig[]): Observable>> { + options = { ...options, searchParams: [new RequestParam('query', query)] }; return this.searchBy('findItemsWithEdit', options, useCachedVersionIfAvailable, reRequestOnStale ); } } diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 0c799369efd..c47931d4da1 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -171,9 +171,10 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { if (rd.hasSucceeded) { // If it's the first page and no query is entered, add the current DSO to the start of the list // If no query is entered, filter out the current DSO from the results, as it'll be displayed at the start of the list already + const part1 = ((isEmpty(query) && page === 1) ? currentDSOResult.page : []); + const part2 = rd.payload.page.filter((result) => isNotEmpty(query) || result.indexableObject.id !== this.currentDSOId); rd.payload.page = [ - ...((isEmpty(query) && page === 1) ? currentDSOResult.page : []), - ...rd.payload.page.filter((result) => isNotEmpty(query) || result.indexableObject.id !== this.currentDSOId) + ...part1, ...part2 ]; } else if (rd.hasFailed) { this.notifcationsService.error(this.translate.instant('dso-selector.error.title', { type: this.typesString }), rd.errorMessage); diff --git a/src/app/shared/dso-selector/dso-selector/editable-item-selector/editable-item-selector.component.ts b/src/app/shared/dso-selector/dso-selector/editable-item-selector/editable-item-selector.component.ts index e8cdea6de4b..25ed722c9e5 100644 --- a/src/app/shared/dso-selector/dso-selector/editable-item-selector/editable-item-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/editable-item-selector/editable-item-selector.component.ts @@ -46,7 +46,7 @@ export class EditableItemSelectorComponent extends DSOSelectorComponent { currentPage: page, elementsPerPage: this.defaultPagination.pageSize }; - return this.itemDataService.findItemsWithEdit(findOptions, false, false, followLink('owningCollection')).pipe( + return this.itemDataService.findItemsWithEdit(query, findOptions, true, true, followLink('owningCollection')).pipe( getFirstCompletedRemoteData(), tap((rdata) => console.log('TAPPEDITAP:', rdata)), // XXX mapRemoteDataPayload((payload) => hasValue(payload)