mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Implement feedback
This commit is contained in:
@@ -25,10 +25,8 @@ import { NotificationsServiceStub } from '../../shared/testing/notifications-ser
|
|||||||
import { RouterStub } from '../../shared/testing/router.stub';
|
import { RouterStub } from '../../shared/testing/router.stub';
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { RequestService } from '../../core/data/request.service';
|
import { RequestService } from '../../core/data/request.service';
|
||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
|
||||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
|
||||||
|
|
||||||
describe('EPeopleRegistryComponent', () => {
|
describe('EPeopleRegistryComponent', () => {
|
||||||
let component: EPeopleRegistryComponent;
|
let component: EPeopleRegistryComponent;
|
||||||
|
@@ -20,7 +20,7 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|||||||
import { RequestService } from '../../core/data/request.service';
|
import { RequestService } from '../../core/data/request.service';
|
||||||
import { PageInfo } from '../../core/shared/page-info.model';
|
import { PageInfo } from '../../core/shared/page-info.model';
|
||||||
import { NoContent } from '../../core/shared/NoContent.model';
|
import { NoContent } from '../../core/shared/NoContent.model';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-epeople-registry',
|
selector: 'ds-epeople-registry',
|
||||||
@@ -157,14 +157,14 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
|||||||
const query: string = data.query;
|
const query: string = data.query;
|
||||||
const scope: string = data.scope;
|
const scope: string = data.scope;
|
||||||
if (query != null && this.currentSearchQuery !== query) {
|
if (query != null && this.currentSearchQuery !== query) {
|
||||||
this.router.navigate(this.epersonService.getEPeoplePageRouterLink(), {
|
this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge'
|
||||||
});
|
});
|
||||||
this.currentSearchQuery = query;
|
this.currentSearchQuery = query;
|
||||||
this.paginationService.resetPage(this.config.id);
|
this.paginationService.resetPage(this.config.id);
|
||||||
}
|
}
|
||||||
if (scope != null && this.currentSearchScope !== scope) {
|
if (scope != null && this.currentSearchScope !== scope) {
|
||||||
this.router.navigate(this.epersonService.getEPeoplePageRouterLink(), {
|
this.router.navigate([this.epersonService.getEPeoplePageRouterLink()], {
|
||||||
queryParamsHandling: 'merge'
|
queryParamsHandling: 'merge'
|
||||||
});
|
});
|
||||||
this.currentSearchScope = scope;
|
this.currentSearchScope = scope;
|
||||||
|
@@ -26,10 +26,8 @@ import { AuthorizationDataService } from '../../../core/data/feature-authorizati
|
|||||||
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
import { GroupDataService } from '../../../core/eperson/group-data.service';
|
||||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
|
||||||
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
|
||||||
|
|
||||||
describe('EPersonFormComponent', () => {
|
describe('EPersonFormComponent', () => {
|
||||||
let component: EPersonFormComponent;
|
let component: EPersonFormComponent;
|
||||||
|
@@ -31,7 +31,7 @@ import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/c
|
|||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { RequestService } from '../../../core/data/request.service';
|
import { RequestService } from '../../../core/data/request.service';
|
||||||
import { NoContent } from '../../../core/shared/NoContent.model';
|
import { NoContent } from '../../../core/shared/NoContent.model';
|
||||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-eperson-form',
|
selector: 'ds-eperson-form',
|
||||||
|
@@ -26,11 +26,8 @@ import { getMockFormBuilderService } from '../../../../shared/mocks/form-builder
|
|||||||
import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock';
|
||||||
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
|
||||||
import { RouterMock } from '../../../../shared/mocks/router.mock';
|
import { RouterMock } from '../../../../shared/mocks/router.mock';
|
||||||
import { PaginationComponentOptions } from '../../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { SortDirection, SortOptions } from '../../../../../core/cache/models/sort-options.model';
|
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../../../../core/data/request.models';
|
|
||||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
|
||||||
import { PaginationServiceStub } from '../../../../../shared/testing/pagination-service.stub';
|
|
||||||
|
|
||||||
describe('MembersListComponent', () => {
|
describe('MembersListComponent', () => {
|
||||||
let component: MembersListComponent;
|
let component: MembersListComponent;
|
||||||
|
@@ -23,8 +23,8 @@ import {
|
|||||||
} from '../../../../core/shared/operators';
|
} from '../../../../core/shared/operators';
|
||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
|
||||||
import {EpersonDtoModel} from '../../../../core/eperson/models/eperson-dto.model';
|
import {EpersonDtoModel} from '../../../../core/eperson/models/eperson-dto.model';
|
||||||
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys to keep track of specific subscriptions
|
* Keys to keep track of specific subscriptions
|
||||||
|
@@ -35,11 +35,8 @@ import { getMockTranslateService } from '../../../../shared/mocks/translate.serv
|
|||||||
import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock';
|
import { TranslateLoaderMock } from '../../../../shared/testing/translate-loader.mock';
|
||||||
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../../../shared/testing/notifications-service.stub';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { PaginationComponentOptions } from '../../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
import { SortDirection, SortOptions } from '../../../../../core/cache/models/sort-options.model';
|
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../../../../core/data/request.models';
|
|
||||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
|
||||||
import { PaginationServiceStub } from '../../../../../shared/testing/pagination-service.stub';
|
|
||||||
|
|
||||||
describe('SubgroupsListComponent', () => {
|
describe('SubgroupsListComponent', () => {
|
||||||
let component: SubgroupsListComponent;
|
let component: SubgroupsListComponent;
|
||||||
|
@@ -16,7 +16,7 @@ import {
|
|||||||
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
|
||||||
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||||
import { NoContent } from '../../../../core/shared/NoContent.model';
|
import { NoContent } from '../../../../core/shared/NoContent.model';
|
||||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys to keep track of specific subscriptions
|
* Keys to keep track of specific subscriptions
|
||||||
|
@@ -28,11 +28,8 @@ import { TranslateLoaderMock } from '../../shared/testing/translate-loader.mock'
|
|||||||
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub';
|
||||||
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
import { routeServiceStub } from '../../shared/testing/route-service.stub';
|
||||||
import { RouterMock } from '../../shared/mocks/router.mock';
|
import { RouterMock } from '../../shared/mocks/router.mock';
|
||||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||||
import { FindListOptions } from '../../../core/data/request.models';
|
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
|
||||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
|
||||||
|
|
||||||
describe('GroupRegistryComponent', () => {
|
describe('GroupRegistryComponent', () => {
|
||||||
let component: GroupsRegistryComponent;
|
let component: GroupsRegistryComponent;
|
||||||
|
@@ -34,7 +34,7 @@ import { hasValue } from '../../shared/empty.util';
|
|||||||
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
import { NotificationsService } from '../../shared/notifications/notifications.service';
|
||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { NoContent } from '../../core/shared/NoContent.model';
|
import { NoContent } from '../../core/shared/NoContent.model';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-groups-registry',
|
selector: 'ds-groups-registry',
|
||||||
|
@@ -18,10 +18,10 @@ import { isNumeric } from 'rxjs/internal-compatibility';
|
|||||||
* Service to manage the pagination of different components
|
* Service to manage the pagination of different components
|
||||||
* The pagination information will be stored in the route based on a paginationID.
|
* The pagination information will be stored in the route based on a paginationID.
|
||||||
* The following params are used for the different kind of pagination information:
|
* The following params are used for the different kind of pagination information:
|
||||||
* - For the page: p.{paginationID}
|
* - For the page: {paginationID}.p
|
||||||
* - For the page size: rpp.{paginationID}
|
* - For the page size: {paginationID}.rpp
|
||||||
* - For the sort direction: sd.{paginationID}
|
* - For the sort direction: {paginationID}.sd
|
||||||
* - For the sort field: sf.{paginationID}
|
* - For the sort field: {paginationID}.sf
|
||||||
*/
|
*/
|
||||||
export class PaginationService {
|
export class PaginationService {
|
||||||
|
|
||||||
@@ -145,7 +145,6 @@ export class PaginationService {
|
|||||||
if (isNotEmpty(difference(parametersWithIdName, currentParametersWithIdName)) || isNotEmpty(extraParams) || isNotEmpty(this.clearParams)) {
|
if (isNotEmpty(difference(parametersWithIdName, currentParametersWithIdName)) || isNotEmpty(extraParams) || isNotEmpty(this.clearParams)) {
|
||||||
const queryParams = Object.assign({}, this.clearParams, currentParametersWithIdName,
|
const queryParams = Object.assign({}, this.clearParams, currentParametersWithIdName,
|
||||||
parametersWithIdName, extraParams);
|
parametersWithIdName, extraParams);
|
||||||
console.log(queryParams, this.clearParams);
|
|
||||||
if (retainScrollPosition) {
|
if (retainScrollPosition) {
|
||||||
this.router.navigate(url, {
|
this.router.navigate(url, {
|
||||||
queryParams: queryParams,
|
queryParams: queryParams,
|
||||||
@@ -159,7 +158,6 @@ export class PaginationService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.clearParams = {};
|
this.clearParams = {};
|
||||||
console.log('postcear', this.clearParams);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -127,7 +127,8 @@ describe('Pagination component', () => {
|
|||||||
// waitForAsync beforeEach
|
// waitForAsync beforeEach
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
activatedRouteStub = new MockActivatedRoute();
|
activatedRouteStub = new MockActivatedRoute();
|
||||||
routerStub = new RouterMock(); hostWindowServiceStub = new HostWindowServiceMock(_initialState.width);
|
routerStub = new RouterMock();
|
||||||
|
hostWindowServiceStub = new HostWindowServiceMock(_initialState.width);
|
||||||
|
|
||||||
currentPagination = new BehaviorSubject<PaginationComponentOptions>(pagination);
|
currentPagination = new BehaviorSubject<PaginationComponentOptions>(pagination);
|
||||||
currentSort = new BehaviorSubject<SortOptions>(sort);
|
currentSort = new BehaviorSubject<SortOptions>(sort);
|
||||||
|
@@ -186,7 +186,9 @@ export class EpersonGroupListComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.subs.push(search$.pipe(getFirstCompletedRemoteData())
|
this.subs.push(search$.pipe(getFirstCompletedRemoteData())
|
||||||
.subscribe((list: RemoteData<PaginatedList<DSpaceObject>>) => {
|
.subscribe((list: RemoteData<PaginatedList<DSpaceObject>>) => {
|
||||||
|
if (hasValue(this.list$)) {
|
||||||
this.list$.next(list);
|
this.list$.next(list);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@@ -95,7 +95,8 @@ export class SearchFormComponent {
|
|||||||
*/
|
*/
|
||||||
updateSearch(data: any) {
|
updateSearch(data: any) {
|
||||||
const queryParams = Object.assign({}, data);
|
const queryParams = Object.assign({}, data);
|
||||||
queryParams[`page.${this.searchConfig.paginationID}`] = 1;
|
const pageParam = this.paginationService.getPageParam(this.searchConfig.paginationID);
|
||||||
|
queryParams[pageParam] = 1;
|
||||||
|
|
||||||
this.router.navigate(this.getSearchLinkParts(), {
|
this.router.navigate(this.getSearchLinkParts(), {
|
||||||
queryParams: queryParams,
|
queryParams: queryParams,
|
||||||
|
@@ -140,7 +140,7 @@ describe('SearchFacetOptionComponent', () => {
|
|||||||
(comp as any).updateAddParams(selectedValues);
|
(comp as any).updateAddParams(selectedValues);
|
||||||
expect(comp.addQueryParams).toEqual({
|
expect(comp.addQueryParams).toEqual({
|
||||||
[mockFilterConfig.paramName]: [`${value1},${operator}`, value.value + ',equals'],
|
[mockFilterConfig.paramName]: [`${value1},${operator}`, value.value + ',equals'],
|
||||||
['page.page-id']: 1
|
['page-id.page']: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -155,7 +155,7 @@ describe('SearchFacetOptionComponent', () => {
|
|||||||
(comp as any).updateAddParams(selectedValues);
|
(comp as any).updateAddParams(selectedValues);
|
||||||
expect(comp.addQueryParams).toEqual({
|
expect(comp.addQueryParams).toEqual({
|
||||||
[mockAuthorityFilterConfig.paramName]: [value1 + ',equals', `${value2},${operator}`],
|
[mockAuthorityFilterConfig.paramName]: [value1 + ',equals', `${value2},${operator}`],
|
||||||
['page.page-id']: 1
|
['page-id.page']: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -126,7 +126,7 @@ describe('SearchFacetRangeOptionComponent', () => {
|
|||||||
expect(comp.changeQueryParams).toEqual({
|
expect(comp.changeQueryParams).toEqual({
|
||||||
[mockFilterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: ['50'],
|
[mockFilterConfig.paramName + RANGE_FILTER_MIN_SUFFIX]: ['50'],
|
||||||
[mockFilterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: ['60'],
|
[mockFilterConfig.paramName + RANGE_FILTER_MAX_SUFFIX]: ['60'],
|
||||||
['page.page-id']: 1
|
['page-id.page']: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -165,7 +165,7 @@ describe('SearchFacetSelectedOptionComponent', () => {
|
|||||||
(comp as any).updateRemoveParams(selectedValues);
|
(comp as any).updateRemoveParams(selectedValues);
|
||||||
expect(comp.removeQueryParams).toEqual({
|
expect(comp.removeQueryParams).toEqual({
|
||||||
[mockFilterConfig.paramName]: [value1],
|
[mockFilterConfig.paramName]: [value1],
|
||||||
['page.page-id']: 1
|
['page-id.page']: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -181,7 +181,7 @@ describe('SearchFacetSelectedOptionComponent', () => {
|
|||||||
(comp as any).updateRemoveParams(selectedAuthorityValues);
|
(comp as any).updateRemoveParams(selectedAuthorityValues);
|
||||||
expect(comp.removeQueryParams).toEqual({
|
expect(comp.removeQueryParams).toEqual({
|
||||||
[mockAuthorityFilterConfig.paramName]: [`${value1},${operator}`],
|
[mockAuthorityFilterConfig.paramName]: [`${value1},${operator}`],
|
||||||
['page.page-id']: 1
|
['page-id.page']: 1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -20,6 +20,6 @@ export class PaginationServiceStub {
|
|||||||
updateRouteWithUrl = jasmine.createSpy('updateRouteWithUrl');
|
updateRouteWithUrl = jasmine.createSpy('updateRouteWithUrl');
|
||||||
clearPagination = jasmine.createSpy('clearPagination');
|
clearPagination = jasmine.createSpy('clearPagination');
|
||||||
getRouteParameterValue = jasmine.createSpy('getRouteParameterValue').and.returnValue(observableOf(''));
|
getRouteParameterValue = jasmine.createSpy('getRouteParameterValue').and.returnValue(observableOf(''));
|
||||||
getPageParam = jasmine.createSpy('getPageParam').and.returnValue(`page.${this.pagination.id}`);
|
getPageParam = jasmine.createSpy('getPageParam').and.returnValue(`${this.pagination.id}.page`);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,7 @@ 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.utils';
|
import { createSuccessfulRemoteDataObject } from '../../../shared/remote-data.utils';
|
||||||
import { FindListOptions } from '../../../core/data/request.models';
|
import { FindListOptions } from '../../../core/data/request.models';
|
||||||
import { 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';
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ export class SubmissionImportExternalSearchbarComponent implements OnInit, OnDes
|
|||||||
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 });
|
||||||
@@ -166,6 +166,7 @@ export class SubmissionImportExternalSearchbarComponent implements OnInit, OnDes
|
|||||||
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
const paginatedListRD = createSuccessfulRemoteDataObject(paginatedList);
|
||||||
return observableOf(paginatedListRD);
|
return observableOf(paginatedListRD);
|
||||||
}),
|
}),
|
||||||
|
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) => {
|
||||||
|
@@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest, Subscription } from 'rxjs';
|
import { BehaviorSubject, combineLatest, Subscription } from 'rxjs';
|
||||||
import { filter, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { filter, mergeMap, switchMap, take, tap } from 'rxjs/operators';
|
||||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||||
|
|
||||||
import { ExternalSourceService } from '../../core/data/external-source.service';
|
import { ExternalSourceService } from '../../core/data/external-source.service';
|
||||||
@@ -45,7 +45,10 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public isLoading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
public isLoading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
public reload$: BehaviorSubject<{query: string, source: string}> = new BehaviorSubject<{query: string; source: string}>({query: '', source: ''});
|
public reload$: BehaviorSubject<{ query: string, source: string }> = new BehaviorSubject<{ query: string; source: string }>({
|
||||||
|
query: '',
|
||||||
|
source: ''
|
||||||
|
});
|
||||||
/**
|
/**
|
||||||
* Configuration to use for the import buttons
|
* Configuration to use for the import buttons
|
||||||
*/
|
*/
|
||||||
@@ -83,6 +86,8 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
protected subs: Subscription[] = [];
|
protected subs: Subscription[] = [];
|
||||||
|
|
||||||
|
private retrieveExternalSourcesSub: Subscription;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the component variables.
|
* Initialize the component variables.
|
||||||
* @param {SearchConfigurationService} searchConfigService
|
* @param {SearchConfigurationService} searchConfigService
|
||||||
@@ -108,7 +113,7 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
this.listId = 'list-submission-external-sources';
|
this.listId = 'list-submission-external-sources';
|
||||||
this.context = Context.EntitySearchModalWithNameVariants;
|
this.context = Context.EntitySearchModalWithNameVariants;
|
||||||
this.repeatable = false;
|
this.repeatable = false;
|
||||||
this.routeData = { sourceId: '', query: '' };
|
this.routeData = {sourceId: '', query: ''};
|
||||||
this.importConfig = {
|
this.importConfig = {
|
||||||
buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label
|
buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label
|
||||||
};
|
};
|
||||||
@@ -133,10 +138,13 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
this.router.navigate(
|
this.router.navigate(
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
queryParams: { source: event.sourceId, query: event.query },
|
queryParams: {source: event.sourceId, query: event.query},
|
||||||
replaceUrl: true
|
replaceUrl: true
|
||||||
}
|
}
|
||||||
).then(() => this.reload$.next({source: event.sourceId, query: event.query}));
|
).then(() => {
|
||||||
|
this.reload$.next({source: event.sourceId, query: event.query});
|
||||||
|
this.retrieveExternalSources();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,6 +166,10 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
this.subs
|
this.subs
|
||||||
.filter((sub) => hasValue(sub))
|
.filter((sub) => hasValue(sub))
|
||||||
.forEach((sub) => sub.unsubscribe());
|
.forEach((sub) => sub.unsubscribe());
|
||||||
|
if (hasValue(this.retrieveExternalSourcesSub)) {
|
||||||
|
this.retrieveExternalSourcesSub.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -167,23 +179,24 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
|||||||
* @param query The query string to search
|
* @param query The query string to search
|
||||||
*/
|
*/
|
||||||
private retrieveExternalSources(): void {
|
private retrieveExternalSources(): void {
|
||||||
this.reload$.pipe(
|
if (hasValue(this.retrieveExternalSourcesSub)) {
|
||||||
switchMap(
|
this.retrieveExternalSourcesSub.unsubscribe();
|
||||||
(sourceQueryObject: { source: string, query: string }) => {
|
}
|
||||||
|
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;
|
const source = sourceQueryObject.source;
|
||||||
const query = sourceQueryObject.query;
|
const query = sourceQueryObject.query;
|
||||||
if (isNotEmpty(source) && isNotEmpty(query)) {
|
|
||||||
this.routeData.sourceId = source;
|
this.routeData.sourceId = source;
|
||||||
this.routeData.query = query;
|
this.routeData.query = query;
|
||||||
this.isLoading$.next(true);
|
|
||||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
return this.searchConfigService.paginatedSearchOptions.pipe(
|
||||||
|
tap((v) => this.isLoading$.next(true)),
|
||||||
filter((searchOptions) => searchOptions.query === query),
|
filter((searchOptions) => searchOptions.query === query),
|
||||||
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
|
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
|
||||||
getFinishedRemoteData(),
|
getFinishedRemoteData(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
),
|
),
|
||||||
).subscribe((rdData) => {
|
).subscribe((rdData) => {
|
||||||
this.entriesRD$.next(rdData);
|
this.entriesRD$.next(rdData);
|
||||||
|
Reference in New Issue
Block a user