From cc23e232f88bc6f30777cdcc76b540d47a161ce9 Mon Sep 17 00:00:00 2001 From: "Gantner, Florian Klaus" Date: Mon, 8 May 2023 10:03:05 +0200 Subject: [PATCH] entity-dropdown loading authorized import searchlist fixes https://github.com/4Science/dspace-angular/issues/14 and removed unused references/imports --- .../my-dspace-new-bulk-import.component.html | 2 +- ...space-new-external-dropdown.component.html | 2 +- .../entity-dropdown.component.ts | 26 +++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-bulk-import/my-dspace-new-bulk-import.component.html b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-bulk-import/my-dspace-new-bulk-import.component.html index a2888e96280..399f350dba2 100644 --- a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-bulk-import/my-dspace-new-bulk-import.component.html +++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-bulk-import/my-dspace-new-bulk-import.component.html @@ -22,6 +22,6 @@ class="dropdown-menu" id="entityControlsDropdownMenu" aria-labelledby="dropdownSubmission"> - + diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html index 7db6db9a8da..417f50bfca6 100644 --- a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html +++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html @@ -20,6 +20,6 @@ class="dropdown-menu" id="importControlsDropdownMenu" aria-labelledby="dropdownImport"> - + diff --git a/src/app/shared/entity-dropdown/entity-dropdown.component.ts b/src/app/shared/entity-dropdown/entity-dropdown.component.ts index 9a30e74f97b..5a986df9616 100644 --- a/src/app/shared/entity-dropdown/entity-dropdown.component.ts +++ b/src/app/shared/entity-dropdown/entity-dropdown.component.ts @@ -1,7 +1,6 @@ import { ChangeDetectorRef, Component, - ElementRef, EventEmitter, HostListener, Input, @@ -23,7 +22,6 @@ import { } from '../../core/itemexportformat/item-export-format.service'; import { createSuccessfulRemoteDataObject } from '../remote-data.utils'; import { FindListOptions } from '../../core/data/find-list-options.model'; -import { ItemExportFormatMap } from '../../core/itemexportformat/model/item-export-format.model'; @Component({ selector: 'ds-entity-dropdown', @@ -59,6 +57,12 @@ export class EntityDropdownComponent implements OnInit, OnDestroy { */ @Input() isSubmission: boolean; + /** + * TRUE if the parent operation is a 'Import metadata from an external source' operation, FALSE otherwise (eg.: is an 'Export Item' operation). + */ + @Input() isExternalImport = false; + + /** * The entity to output to the parent component */ @@ -91,13 +95,11 @@ export class EntityDropdownComponent implements OnInit, OnDestroy { * @param {ChangeDetectorRef} changeDetectorRef * @param {EntityTypeDataService} entityTypeService * @param {ItemExportFormatService} itemExportFormatService - * @param {ElementRef} el */ constructor( private changeDetectorRef: ChangeDetectorRef, private entityTypeService: EntityTypeDataService, private itemExportFormatService: ItemExportFormatService, - private el: ElementRef ) { } /** @@ -176,7 +178,21 @@ export class EntityDropdownComponent implements OnInit, OnDestroy { } }) ); - } else { + } else if (this.isExternalImport) { + const findOptions: FindListOptions = { + elementsPerPage: 10, + currentPage: page + }; + searchListEntity$ = this.entityTypeService.getAllAuthorizedRelationshipTypeImport(findOptions) + .pipe( + getFirstSucceededRemoteWithNotEmptyData(), + tap(entityType => { + if ((this.searchListEntity.length + findOptions.elementsPerPage) >= entityType.payload.totalElements) { + this.hasNextPage = false; + } + }) + ); + } else { searchListEntity$ = this.itemExportFormatService.byEntityTypeAndMolteplicity(null, ItemExportFormatMolteplicity.MULTIPLE) .pipe(