"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/app/submission/import-external/import-external-searchbar/submission-import-external-searchbar.component.ts" between
dspace-angular-dspace-7.0.tar.gz and dspace-angular-dspace-7.1.tar.gz

About: dspace-angular is the Angular-based frontend of DSpace, a digital repository system to capture, store, index, preserve and redistribute an organization’s research material in digital formats.

submission-import-external-searchbar.component.ts  (dspace-angular-dspace-7.0):submission-import-external-searchbar.component.ts  (dspace-angular-dspace-7.1)
import { import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, O
ChangeDetectorRef, utput } from '@angular/core';
Component,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output
} from '@angular/core';
import { Observable, of as observableOf, Subscription } from 'rxjs'; import { Observable, of as observableOf, Subscription } from 'rxjs';
import { catchError, tap } from 'rxjs/operators'; import { catchError, tap } from 'rxjs/operators';
import { RequestParam } from '../../../core/cache/models/request-param.model';
import { ExternalSourceService } from '../../../core/data/external-source.servic e'; import { ExternalSourceService } from '../../../core/data/external-source.servic e';
import { ExternalSource } from '../../../core/shared/external-source.model'; import { ExternalSource } from '../../../core/shared/external-source.model';
import { PaginatedList, buildPaginatedList } from '../../../core/data/paginated- list.model'; import { buildPaginatedList, PaginatedList } from '../../../core/data/paginated- list.model';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PageInfo } from '../../../core/shared/page-info.model'; import { PageInfo } from '../../../core/shared/page-info.model';
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.ut ils'; import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.ut ils';
import { FindListOptions } from '../../../core/data/request.models'; import { FindListOptions } from '../../../core/data/request.models';
import { getFirstSucceededRemoteData, getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators'; import { getFirstSucceededRemoteData, getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { HostWindowService } from '../../../shared/host-window.service'; import { HostWindowService } from '../../../shared/host-window.service';
import { hasValue } from '../../../shared/empty.util'; import { hasValue } from '../../../shared/empty.util';
/** /**
* Interface for the selected external source element. * Interface for the selected external source element.
*/ */
export interface SourceElement { export interface SourceElement {
id: string; id: string;
name: string; name: string;
} }
/** /**
* Interface for the external source data to export. * Interface for the external source data to export.
*/ */
export interface ExternalSourceData { export interface ExternalSourceData {
entity: string;
query: string; query: string;
sourceId: string; sourceId: string;
} }
/** /**
* This component builds the searchbar for the submission external import. * This component builds the searchbar for the submission external import.
*/ */
@Component({ @Component({
selector: 'ds-submission-import-external-searchbar', selector: 'ds-submission-import-external-searchbar',
styleUrls: ['./submission-import-external-searchbar.component.scss'], styleUrls: ['./submission-import-external-searchbar.component.scss'],
skipping to change at line 119 skipping to change at line 113
ngOnInit() { ngOnInit() {
this.selectedElement = { this.selectedElement = {
id: '', id: '',
name: 'loading' name: 'loading'
}; };
this.searchString = ''; this.searchString = '';
this.sourceList = []; this.sourceList = [];
this.findListOptions = Object.assign({}, new FindListOptions(), { this.findListOptions = Object.assign({}, new FindListOptions(), {
elementsPerPage: 5, elementsPerPage: 5,
currentPage: 1, currentPage: 1,
searchParams: [
new RequestParam('entityType', this.initExternalSourceData.entity)
]
}); });
this.externalService.findAll(this.findListOptions).pipe( this.externalService.searchBy('findByEntityType', this.findListOptions).pipe (
catchError(() => { catchError(() => {
const pageInfo = new PageInfo(); const pageInfo = new PageInfo();
const paginatedList = buildPaginatedList(pageInfo, []); const paginatedList = buildPaginatedList(pageInfo, []);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList); const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
return observableOf(paginatedListRD); return observableOf(paginatedListRD);
}), }),
getFirstSucceededRemoteDataPayload(), getFirstSucceededRemoteDataPayload(),
).subscribe((externalSource: PaginatedList<ExternalSource>) => { ).subscribe((externalSource: PaginatedList<ExternalSource>) => {
externalSource.page.forEach((element) => { externalSource.page.forEach((element) => {
this.sourceList.push({ id: element.id, name: element.name }); this.sourceList.push({ id: element.id, name: element.name });
skipping to change at line 161 skipping to change at line 158
/** /**
* Load the next pages of external sources. * Load the next pages of external sources.
*/ */
public onScroll(): void { public onScroll(): void {
if (!this.sourceListLoading && ((this.pageInfo.currentPage + 1) <= this.page Info.totalPages)) { if (!this.sourceListLoading && ((this.pageInfo.currentPage + 1) <= this.page Info.totalPages)) {
this.sourceListLoading = true; this.sourceListLoading = true;
this.findListOptions = Object.assign({}, new FindListOptions(), { this.findListOptions = Object.assign({}, new FindListOptions(), {
elementsPerPage: 5, elementsPerPage: 5,
currentPage: this.findListOptions.currentPage + 1, currentPage: this.findListOptions.currentPage + 1,
searchParams: [
new RequestParam('entityType', this.initExternalSourceData.entity)
]
}); });
this.sub = this.externalService.findAll(this.findListOptions).pipe( this.externalService.searchBy('findByEntityType', this.findListOptions).pi pe(
catchError(() => { catchError(() => {
const pageInfo = new PageInfo(); const pageInfo = new PageInfo();
const paginatedList = buildPaginatedList(pageInfo, []); const paginatedList = buildPaginatedList(pageInfo, []);
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList ); const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList );
return observableOf(paginatedListRD); return observableOf(paginatedListRD);
}), }),
getFirstSucceededRemoteData(), getFirstSucceededRemoteData(),
tap(() => this.sourceListLoading = false) tap(() => this.sourceListLoading = false)
).subscribe((externalSource: RemoteData<PaginatedList<ExternalSource>>) => { ).subscribe((externalSource: RemoteData<PaginatedList<ExternalSource>>) => {
externalSource.payload.page.forEach((element) => { externalSource.payload.page.forEach((element) => {
skipping to change at line 185 skipping to change at line 185
this.pageInfo = externalSource.payload.pageInfo; this.pageInfo = externalSource.payload.pageInfo;
this.cdr.detectChanges(); this.cdr.detectChanges();
}); });
} }
} }
/** /**
* Passes the search parameters to the parent component. * Passes the search parameters to the parent component.
*/ */
public search(): void { public search(): void {
this.externalSourceData.emit({ sourceId: this.selectedElement.id, query: thi this.externalSourceData.emit(
s.searchString }); {
entity: this.initExternalSourceData.entity,
sourceId: this.selectedElement.id,
query: this.searchString
}
);
} }
/** /**
* Unsubscribe from all subscriptions * Unsubscribe from all subscriptions
*/ */
ngOnDestroy(): void { ngOnDestroy(): void {
if (hasValue(this.sub)) { if (hasValue(this.sub)) {
this.sub.unsubscribe(); this.sub.unsubscribe();
} }
} }
} }
 End of changes. 10 change blocks. 
14 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)