100302: Fix issues with live import

This commit is contained in:
Yana De Pauw
2023-03-27 16:31:26 +02:00
parent ca864379c8
commit 153a53f118
4 changed files with 12 additions and 4 deletions

View File

@@ -9,7 +9,6 @@
<ds-collection-dropdown [ngClass]="{'d-none': isLoading()}"
(selectionChange)="selectObject($event)"
(searchComplete)="searchComplete()"
(theOnlySelectable)="theOnlySelectable($event)"
[entityType]="entityType">
</ds-collection-dropdown>
</div>

View File

@@ -64,7 +64,7 @@ describe('SubmissionImportExternalCollectionComponent test suite', () => {
compAsAny = null;
});
it('should emit from selectedEvent on selectObject', () => {
it('should emit from selectedEvent on selectObject and set loading to true', () => {
spyOn(comp.selectedEvent, 'emit').and.callThrough();
const entry = {
@@ -79,6 +79,7 @@ describe('SubmissionImportExternalCollectionComponent test suite', () => {
comp.selectObject(entry);
expect(comp.selectedEvent.emit).toHaveBeenCalledWith(entry);
expect(comp.loading).toBeTrue();
});
it('should dismiss modal on closeCollectionModal', () => {

View File

@@ -38,6 +38,7 @@ export class SubmissionImportExternalCollectionComponent {
* This method emits the selected Collection from the 'selectedEvent' variable.
*/
public selectObject(object: CollectionListEntry): void {
this.loading = true;
this.selectedEvent.emit(object);
}

View File

@@ -15,7 +15,9 @@ import { Context } from '../../core/shared/context.model';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { RouteService } from '../../core/services/route.service';
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
import { SubmissionImportExternalPreviewComponent } from './import-external-preview/submission-import-external-preview.component';
import {
SubmissionImportExternalPreviewComponent
} from './import-external-preview/submission-import-external-preview.component';
import { fadeIn } from '../../shared/animations/fade';
import { PageInfo } from '../../core/shared/page-info.model';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
@@ -186,12 +188,17 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
this.retrieveExternalSourcesSub = this.reload$.pipe(
filter((sourceQueryObject: ExternalSourceData) => isNotEmpty(sourceQueryObject.sourceId) && isNotEmpty(sourceQueryObject.query)),
switchMap((sourceQueryObject: ExternalSourceData) => {
const currentEntry = this.entriesRD$.getValue();
let useCache = true;
if (hasValue(currentEntry) && currentEntry.isError) {
useCache = false;
}
const query = sourceQueryObject.query;
this.routeData = sourceQueryObject;
return this.searchConfigService.paginatedSearchOptions.pipe(
tap(() => this.isLoading$.next(true)),
filter((searchOptions) => searchOptions.query === query),
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions, useCache).pipe(
getFinishedRemoteData(),
))
);