dynamic-lookup-relation-external-source-tab.component.ts (dspace-angular-dspace-7.0) | : | dynamic-lookup-relation-external-source-tab.component.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu lar/core'; | import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angu lar/core'; | |||
import { SEARCH_CONFIG_SERVICE } from '../../../../../../my-dspace-page/my-dspac e-page.component'; | import { SEARCH_CONFIG_SERVICE } from '../../../../../../my-dspace-page/my-dspac e-page.component'; | |||
import { SearchConfigurationService } from '../../../../../../core/shared/search /search-configuration.service'; | import { SearchConfigurationService } from '../../../../../../core/shared/search /search-configuration.service'; | |||
import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | |||
import { ExternalSourceService } from '../../../../../../core/data/external-sour ce.service'; | import { ExternalSourceService } from '../../../../../../core/data/external-sour ce.service'; | |||
import { RemoteData } from '../../../../../../core/data/remote-data'; | import { RemoteData } from '../../../../../../core/data/remote-data'; | |||
import { PaginatedList } from '../../../../../../core/data/paginated-list.model' ; | import { PaginatedList } from '../../../../../../core/data/paginated-list.model' ; | |||
import { ExternalSourceEntry } from '../../../../../../core/shared/external-sour ce-entry.model'; | import { ExternalSourceEntry } from '../../../../../../core/shared/external-sour ce-entry.model'; | |||
import { ExternalSource } from '../../../../../../core/shared/external-source.mo del'; | import { ExternalSource } from '../../../../../../core/shared/external-source.mo del'; | |||
import { startWith, switchMap } from 'rxjs/operators'; | import { map, startWith, switchMap } from 'rxjs/operators'; | |||
import { PaginatedSearchOptions } from '../../../../../search/paginated-search-o ptions.model'; | import { PaginatedSearchOptions } from '../../../../../search/paginated-search-o ptions.model'; | |||
import { Context } from '../../../../../../core/shared/context.model'; | import { Context } from '../../../../../../core/shared/context.model'; | |||
import { ListableObject } from '../../../../../object-collection/shared/listable -object.model'; | import { ListableObject } from '../../../../../object-collection/shared/listable -object.model'; | |||
import { fadeIn, fadeInOut } from '../../../../../animations/fade'; | import { fadeIn, fadeInOut } from '../../../../../animations/fade'; | |||
import { PaginationComponentOptions } from '../../../../../pagination/pagination -component-options.model'; | import { PaginationComponentOptions } from '../../../../../pagination/pagination -component-options.model'; | |||
import { RelationshipOptions } from '../../../models/relationship-options.model' ; | import { RelationshipOptions } from '../../../models/relationship-options.model' ; | |||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; | |||
import { ExternalSourceEntryImportModalComponent } from './external-source-entry -import-modal/external-source-entry-import-modal.component'; | import { ExternalSourceEntryImportModalComponent } from './external-source-entry -import-modal/external-source-entry-import-modal.component'; | |||
import { hasValue } from '../../../../../empty.util'; | import { hasValue } from '../../../../../empty.util'; | |||
import { SelectableListService } from '../../../../../object-list/selectable-lis t/selectable-list.service'; | import { SelectableListService } from '../../../../../object-list/selectable-lis t/selectable-list.service'; | |||
import { Item } from '../../../../../../core/shared/item.model'; | import { Item } from '../../../../../../core/shared/item.model'; | |||
import { Collection } from '../../../../../../core/shared/collection.model'; | import { Collection } from '../../../../../../core/shared/collection.model'; | |||
import { PaginationService } from '../../../../../../core/pagination/pagination. service'; | import { PaginationService } from '../../../../../../core/pagination/pagination. service'; | |||
import { Observable, Subscription } from 'rxjs'; | import { Observable, Subscription } from 'rxjs'; | |||
import { ItemType } from '../../../../../../core/shared/item-relationships/item- | ||||
type.model'; | ||||
import { getFirstCompletedRemoteData } from '../../../../../../core/shared/opera | ||||
tors'; | ||||
@Component({ | @Component({ | |||
selector: 'ds-dynamic-lookup-relation-external-source-tab', | selector: 'ds-dynamic-lookup-relation-external-source-tab', | |||
styleUrls: ['./dynamic-lookup-relation-external-source-tab.component.scss'], | styleUrls: ['./dynamic-lookup-relation-external-source-tab.component.scss'], | |||
templateUrl: './dynamic-lookup-relation-external-source-tab.component.html', | templateUrl: './dynamic-lookup-relation-external-source-tab.component.html', | |||
providers: [ | providers: [ | |||
{ | { | |||
provide: SEARCH_CONFIG_SERVICE, | provide: SEARCH_CONFIG_SERVICE, | |||
useClass: SearchConfigurationService | useClass: SearchConfigurationService | |||
} | } | |||
skipping to change at line 119 | skipping to change at line 121 | |||
/** | /** | |||
* The modal for importing the entry | * The modal for importing the entry | |||
*/ | */ | |||
modalRef: NgbModalRef; | modalRef: NgbModalRef; | |||
/** | /** | |||
* Subscription to the modal's importedObject event-emitter | * Subscription to the modal's importedObject event-emitter | |||
*/ | */ | |||
importObjectSub: Subscription; | importObjectSub: Subscription; | |||
/** | ||||
* The entity types compatible with the given external source | ||||
*/ | ||||
relatedEntityType: ItemType; | ||||
constructor(private router: Router, | constructor(private router: Router, | |||
public searchConfigService: SearchConfigurationService, | public searchConfigService: SearchConfigurationService, | |||
private externalSourceService: ExternalSourceService, | private externalSourceService: ExternalSourceService, | |||
private modalService: NgbModal, | private modalService: NgbModal, | |||
private selectableListService: SelectableListService, | private selectableListService: SelectableListService, | |||
private paginationService: PaginationService | private paginationService: PaginationService | |||
) { | ) { | |||
} | } | |||
/** | /** | |||
* Get the entries for the selected external source | * Get the entries for the selected external source | |||
*/ | */ | |||
ngOnInit(): void { | ngOnInit(): void { | |||
this.externalSource.entityTypes.pipe( | ||||
getFirstCompletedRemoteData(), | ||||
map((entityTypesRD: RemoteData<PaginatedList<ItemType>>) => { | ||||
return (entityTypesRD.hasSucceeded && entityTypesRD.payload.totalElement | ||||
s > 0) ? entityTypesRD.payload.page[0] : null; | ||||
}) | ||||
).subscribe((entityType: ItemType) => { | ||||
this.relatedEntityType = entityType; | ||||
}); | ||||
this.resetRoute(); | this.resetRoute(); | |||
this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe( | this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe( | |||
switchMap((searchOptions: PaginatedSearchOptions) => | switchMap((searchOptions: PaginatedSearchOptions) => | |||
this.externalSourceService.getExternalSourceEntries(this.externalSource. id, searchOptions).pipe(startWith(undefined))) | this.externalSourceService.getExternalSourceEntries(this.externalSource. id, searchOptions).pipe(startWith(undefined))) | |||
); | ); | |||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.s earchConfigService.paginationID, this.initialPagination); | this.currentPagination$ = this.paginationService.getCurrentPagination(this.s earchConfigService.paginationID, this.initialPagination); | |||
this.importConfig = { | this.importConfig = { | |||
buttonLabel: 'submission.sections.describe.relationship-lookup.external-so urce.import-button-title.' + this.label | buttonLabel: 'submission.sections.describe.relationship-lookup.external-so urce.import-button-title.' + this.label | |||
}; | }; | |||
} | } | |||
skipping to change at line 158 | skipping to change at line 174 | |||
this.modalRef = this.modalService.open(ExternalSourceEntryImportModalCompone nt, { | this.modalRef = this.modalService.open(ExternalSourceEntryImportModalCompone nt, { | |||
size: 'lg', | size: 'lg', | |||
container: 'ds-dynamic-lookup-relation-modal' | container: 'ds-dynamic-lookup-relation-modal' | |||
}); | }); | |||
const modalComp = this.modalRef.componentInstance; | const modalComp = this.modalRef.componentInstance; | |||
modalComp.externalSourceEntry = entry; | modalComp.externalSourceEntry = entry; | |||
modalComp.item = this.item; | modalComp.item = this.item; | |||
modalComp.collection = this.collection; | modalComp.collection = this.collection; | |||
modalComp.relationship = this.relationship; | modalComp.relationship = this.relationship; | |||
modalComp.label = this.label; | modalComp.label = this.label; | |||
modalComp.relatedEntityType = this.relatedEntityType; | ||||
this.importObjectSub = modalComp.importedObject.subscribe((object) => { | this.importObjectSub = modalComp.importedObject.subscribe((object) => { | |||
this.selectableListService.selectSingle(this.listId, object); | this.selectableListService.selectSingle(this.listId, object); | |||
this.importedObject.emit(object); | this.importedObject.emit(object); | |||
}); | }); | |||
} | } | |||
/** | /** | |||
* Unsubscribe from open subscriptions | * Unsubscribe from open subscriptions | |||
*/ | */ | |||
ngOnDestroy(): void { | ngOnDestroy(): void { | |||
End of changes. 5 change blocks. | ||||
1 lines changed or deleted | 21 lines changed or added |