mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
[CST-4591] Change import from external source page in order to work with entity type
This commit is contained in:
@@ -45,9 +45,10 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
public isLoading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||
|
||||
public reload$: BehaviorSubject<{ query: string, source: string }> = new BehaviorSubject<{ query: string; source: string }>({
|
||||
public reload$: BehaviorSubject<ExternalSourceData> = new BehaviorSubject<ExternalSourceData>({
|
||||
entity: '',
|
||||
query: '',
|
||||
source: ''
|
||||
sourceId: ''
|
||||
});
|
||||
/**
|
||||
* Configuration to use for the import buttons
|
||||
@@ -109,11 +110,10 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
* Get the entries for the selected external source and set initial configuration.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.label = 'Journal';
|
||||
this.listId = 'list-submission-external-sources';
|
||||
this.context = Context.EntitySearchModalWithNameVariants;
|
||||
this.repeatable = false;
|
||||
this.routeData = {sourceId: '', query: ''};
|
||||
this.routeData = {entity: '', sourceId: '', query: ''};
|
||||
this.importConfig = {
|
||||
buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label
|
||||
};
|
||||
@@ -121,12 +121,14 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
this.isLoading$ = new BehaviorSubject(false);
|
||||
this.subs.push(combineLatest(
|
||||
[
|
||||
this.routeService.getQueryParameterValue('source'),
|
||||
this.routeService.getQueryParameterValue('entity'),
|
||||
this.routeService.getQueryParameterValue('sourceId'),
|
||||
this.routeService.getQueryParameterValue('query')
|
||||
]).pipe(
|
||||
take(1)
|
||||
).subscribe(([source, query]: [string, string]) => {
|
||||
this.reload$.next({query: query, source: source});
|
||||
).subscribe(([entity, sourceId, query]: [string, string, string]) => {
|
||||
this.reload$.next({entity: entity, query: query, sourceId: sourceId});
|
||||
this.selectLabel(entity);
|
||||
this.retrieveExternalSources();
|
||||
}));
|
||||
}
|
||||
@@ -138,11 +140,11 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
this.router.navigate(
|
||||
[],
|
||||
{
|
||||
queryParams: {source: event.sourceId, query: event.query},
|
||||
queryParams: event,
|
||||
replaceUrl: true
|
||||
}
|
||||
).then(() => {
|
||||
this.reload$.next({source: event.sourceId, query: event.query});
|
||||
this.reload$.next(event);
|
||||
this.retrieveExternalSources();
|
||||
});
|
||||
}
|
||||
@@ -157,6 +159,7 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
const modalComp = this.modalRef.componentInstance;
|
||||
modalComp.externalSourceEntry = entry;
|
||||
modalComp.labelPrefix = this.label;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,22 +176,17 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve external source entries
|
||||
*
|
||||
* @param source The source tupe
|
||||
* @param query The query string to search
|
||||
* Retrieve external source entries.
|
||||
*/
|
||||
private retrieveExternalSources(): void {
|
||||
if (hasValue(this.retrieveExternalSourcesSub)) {
|
||||
/* if (hasValue(this.retrieveExternalSourcesSub)) {
|
||||
this.retrieveExternalSourcesSub.unsubscribe();
|
||||
}
|
||||
}*/
|
||||
this.retrieveExternalSourcesSub = this.reload$.pipe(
|
||||
filter((sourceQueryObject: { source: string, query: string }) => isNotEmpty(sourceQueryObject.source) && isNotEmpty(sourceQueryObject.query)),
|
||||
switchMap((sourceQueryObject: { source: string, query: string }) => {
|
||||
const source = sourceQueryObject.source;
|
||||
filter((sourceQueryObject: ExternalSourceData) => isNotEmpty(sourceQueryObject.sourceId) && isNotEmpty(sourceQueryObject.query)),
|
||||
switchMap((sourceQueryObject: ExternalSourceData) => {
|
||||
const query = sourceQueryObject.query;
|
||||
this.routeData.sourceId = source;
|
||||
this.routeData.query = query;
|
||||
this.routeData = sourceQueryObject;
|
||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
||||
tap((v) => this.isLoading$.next(true)),
|
||||
filter((searchOptions) => searchOptions.query === query),
|
||||
@@ -204,4 +202,16 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the correct button label, depending on the entity.
|
||||
*
|
||||
* @param entity The entity name
|
||||
*/
|
||||
private selectLabel(entity: string): void {
|
||||
this.label = entity;
|
||||
this.importConfig = {
|
||||
buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user