updated angular/rxjs to v6 successfully

This commit is contained in:
lotte
2018-08-31 15:40:39 +02:00
parent 777facf5cd
commit f11d486d14
78 changed files with 968 additions and 1361 deletions

View File

@@ -25,7 +25,7 @@
"prebuild:prod": "yarn run prebuild", "prebuild:prod": "yarn run prebuild",
"build": "webpack --progress --mode development", "build": "webpack --progress --mode development",
"build:aot": "webpack --env.aot --env.server --mode development && webpack --env.aot --env.client --mode development", "build:aot": "webpack --env.aot --env.server --mode development && webpack --env.aot --env.client --mode development",
"build:prod": "webpack --env.aot --env.server --mode production && webpack --env.aot --env.client --mode production", "build:prod": "webpack --env.aot --env.server --env.production && webpack --env.aot --env.client --env.production",
"postbuild:prod": "yarn run rollup", "postbuild:prod": "yarn run rollup",
"rollup": "rollup -c rollup.config.js", "rollup": "rollup -c rollup.config.js",
"prestart": "yarn run build:prod", "prestart": "yarn run build:prod",
@@ -120,6 +120,7 @@
"ts-md5": "^1.2.4", "ts-md5": "^1.2.4",
"uuid": "^3.2.1", "uuid": "^3.2.1",
"webfontloader": "1.6.28", "webfontloader": "1.6.28",
"webpack-cli": "^3.1.0",
"zone.js": "^0.8.26" "zone.js": "^0.8.26"
}, },
"devDependencies": { "devDependencies": {
@@ -131,37 +132,36 @@
"@types/cookie-parser": "1.4.1", "@types/cookie-parser": "1.4.1",
"@types/deep-freeze": "0.1.1", "@types/deep-freeze": "0.1.1",
"@types/express": "^4.11.1", "@types/express": "^4.11.1",
"@types/express-serve-static-core": "4.11.1", "@types/express-serve-static-core": "4.16.0",
"@types/hammerjs": "2.0.35", "@types/hammerjs": "2.0.35",
"@types/jasmine": "^2.8.6", "@types/jasmine": "^2.8.6",
"@types/js-cookie": "2.1.0", "@types/js-cookie": "2.1.0",
"@types/lodash": "^4.14.110", "@types/lodash": "^4.14.110",
"@types/memory-cache": "0.2.0", "@types/memory-cache": "0.2.0",
"@types/mime": "2.0.0", "@types/mime": "2.0.0",
"@types/node": "^9.4.6", "@types/node": "^10.9.4",
"@types/serve-static": "1.13.1", "@types/serve-static": "1.13.2",
"@types/uuid": "^3.4.3", "@types/uuid": "^3.4.3",
"@types/webfontloader": "1.6.29", "@types/webfontloader": "1.6.29",
"ajv": "^6.1.1", "ajv": "^6.1.1",
"ajv-keywords": "^3.1.0", "ajv-keywords": "^3.1.0",
"angular2-template-loader": "0.6.2", "angular2-template-loader": "0.6.2",
"autoprefixer": "^8.0.0", "autoprefixer": "^9.1.3",
"awesome-typescript-loader": "3.4.1", "awesome-typescript-loader": "5.2.0",
"caniuse-lite": "^1.0.30000697", "caniuse-lite": "^1.0.30000697",
"codelyzer": "^4.4.4", "codelyzer": "^4.4.4",
"compression-webpack-plugin": "^1.1.6", "compression-webpack-plugin": "^1.1.6",
"copy-webpack-plugin": "^4.4.1", "copy-webpack-plugin": "^4.4.1",
"coveralls": "3.0.0", "coveralls": "3.0.0",
"css-loader": "0.28.9", "css-loader": "1.0.0",
"deep-freeze": "0.0.1", "deep-freeze": "0.0.1",
"exports-loader": "^0.7.0", "exports-loader": "^0.7.0",
"html-webpack-plugin": "^4.0.0-alpha", "html-webpack-plugin": "^4.0.0-alpha",
"imports-loader": "0.7.1", "imports-loader": "0.8.0",
"istanbul-instrumenter-loader": "3.0.1", "istanbul-instrumenter-loader": "3.0.1",
"jasmine-core": "^3.2.1", "jasmine-core": "^3.2.1",
"jasmine-marbles": "0.3.0", "jasmine-marbles": "0.3.0",
"jasmine-spec-reporter": "4.2.1", "jasmine-spec-reporter": "4.2.1",
"json-loader": "0.5.7",
"karma": "2.0.0", "karma": "2.0.0",
"karma-chrome-launcher": "2.2.0", "karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1", "karma-cli": "1.0.1",
@@ -191,25 +191,24 @@
"raw-loader": "0.5.1", "raw-loader": "0.5.1",
"resolve-url-loader": "^2.3.0", "resolve-url-loader": "^2.3.0",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"rollup": "^0.56.0", "rollup": "^0.65.0",
"rollup-plugin-commonjs": "^8.3.0", "rollup-plugin-commonjs": "^9.1.6",
"rollup-plugin-node-globals": "1.1.0", "rollup-plugin-node-globals": "1.2.1",
"rollup-plugin-node-resolve": "^3.0.3", "rollup-plugin-node-resolve": "^3.0.3",
"rollup-plugin-uglify": "3.0.0", "rollup-plugin-terser": "^2.0.2",
"sass-loader": "6.0.6", "sass-loader": "6.0.6",
"script-ext-html-webpack-plugin": "2.0.1", "script-ext-html-webpack-plugin": "2.0.1",
"source-map": "0.6.1", "source-map": "0.7.3",
"source-map-loader": "0.2.3", "source-map-loader": "0.2.4",
"string-replace-loader": "2.1.1", "string-replace-loader": "2.1.1",
"to-string-loader": "1.1.5", "to-string-loader": "1.1.5",
"ts-helpers": "1.1.2", "ts-helpers": "1.1.2",
"ts-node": "4.1.0", "ts-node": "4.1.0",
"tslint": "5.9.1", "tslint": "5.11.0",
"typedoc": "^0.9.0", "typedoc": "^0.9.0",
"typescript": "^2.9.1", "typescript": "^2.9.1",
"webpack": "^4.17.1", "webpack": "^4.17.1",
"webpack-bundle-analyzer": "^2.13.1", "webpack-bundle-analyzer": "^2.13.1",
"webpack-command": "^0.4.1",
"webpack-dev-middleware": "3.2.0", "webpack-dev-middleware": "3.2.0",
"webpack-dev-server": "^3.1.5", "webpack-dev-server": "^3.1.5",
"webpack-merge": "4.1.4", "webpack-merge": "4.1.4",

View File

@@ -1,6 +1,6 @@
import nodeResolve from 'rollup-plugin-node-resolve' import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'; import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify' import terser from 'rollup-plugin-terser'
export default { export default {
input: 'dist/client.js', input: 'dist/client.js',
@@ -8,7 +8,6 @@ export default {
file: 'dist/client.js', file: 'dist/client.js',
format: 'iife', format: 'iife',
}, },
sourcemap: false,
plugins: [ plugins: [
nodeResolve({ nodeResolve({
jsnext: true, jsnext: true,
@@ -17,6 +16,6 @@ export default {
commonjs({ commonjs({
include: 'node_modules/rxjs/**' include: 'node_modules/rxjs/**'
}), }),
uglify() terser.terser()
] ]
} }

View File

@@ -1,14 +1,13 @@
import { BitstreamFormatsComponent } from './bitstream-formats.component'; import { BitstreamFormatsComponent } from './bitstream-formats.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RegistryService } from '../../../core/registry/registry.service'; import { RegistryService } from '../../../core/registry/registry.service';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { SharedModule } from '../../../shared/shared.module';
import { PaginationComponent } from '../../../shared/pagination/pagination.component'; import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe'; import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
@@ -53,7 +52,7 @@ describe('BitstreamFormatsComponent', () => {
extensions: null extensions: null
} }
]; ];
const mockFormats = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList))); const mockFormats = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFormatsList)));
const registryServiceStub = { const registryServiceStub = {
getBitstreamFormats: () => mockFormats getBitstreamFormats: () => mockFormats
}; };

View File

@@ -1,6 +1,6 @@
import { MetadataRegistryComponent } from './metadata-registry.component'; import { MetadataRegistryComponent } from './metadata-registry.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -8,13 +8,13 @@ import { By } from '@angular/platform-browser';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { RegistryService } from '../../../core/registry/registry.service'; import { RegistryService } from '../../../core/registry/registry.service';
import { SharedModule } from '../../../shared/shared.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe'; import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
import { PaginationComponent } from '../../../shared/pagination/pagination.component'; import { PaginationComponent } from '../../../shared/pagination/pagination.component';
import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub'; import { HostWindowServiceStub } from '../../../shared/testing/host-window-service-stub';
import { HostWindowService } from '../../../shared/host-window.service'; import { HostWindowService } from '../../../shared/host-window.service';
describe('MetadataRegistryComponent', () => { describe('MetadataRegistryComponent', () => {
let comp: MetadataRegistryComponent; let comp: MetadataRegistryComponent;
let fixture: ComponentFixture<MetadataRegistryComponent>; let fixture: ComponentFixture<MetadataRegistryComponent>;
@@ -33,7 +33,7 @@ describe('MetadataRegistryComponent', () => {
namespace: 'http://dspace.org/mockschema' namespace: 'http://dspace.org/mockschema'
} }
]; ];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList))); const mockSchemas = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const registryServiceStub = { const registryServiceStub = {
getMetadataSchemas: () => mockSchemas getMetadataSchemas: () => mockSchemas
}; };

View File

@@ -1,16 +1,14 @@
import { MetadataSchemaComponent } from './metadata-schema.component'; import { MetadataSchemaComponent } from './metadata-schema.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { MetadataSchema } from '../../../core/metadata/metadataschema.model'; import { MetadataSchema } from '../../../core/metadata/metadataschema.model';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { MockTranslateLoader } from '../../../shared/testing/mock-translate-loader';
import { RegistryService } from '../../../core/registry/registry.service'; import { RegistryService } from '../../../core/registry/registry.service';
import { SharedModule } from '../../../shared/shared.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe'; import { EnumKeysPipe } from '../../../shared/utils/enum-keys-pipe';
import { PaginationComponent } from '../../../shared/pagination/pagination.component'; import { PaginationComponent } from '../../../shared/pagination/pagination.component';
@@ -68,15 +66,15 @@ describe('MetadataSchemaComponent', () => {
schema: mockSchemasList[1] schema: mockSchemasList[1]
} }
]; ];
const mockSchemas = Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList))); const mockSchemas = observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockSchemasList)));
const registryServiceStub = { const registryServiceStub = {
getMetadataSchemas: () => mockSchemas, getMetadataSchemas: () => mockSchemas,
getMetadataFieldsBySchema: (schema: MetadataSchema) => Observable.of(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFieldsList.filter((value) => value.schema === schema)))), getMetadataFieldsBySchema: (schema: MetadataSchema) => observableOf(new RemoteData(false, false, true, undefined, new PaginatedList(null, mockFieldsList.filter((value) => value.schema === schema)))),
getMetadataSchemaByName: (schemaName: string) => Observable.of(new RemoteData(false, false, true, undefined, mockSchemasList.filter((value) => value.prefix === schemaName)[0])) getMetadataSchemaByName: (schemaName: string) => observableOf(new RemoteData(false, false, true, undefined, mockSchemasList.filter((value) => value.prefix === schemaName)[0]))
}; };
const schemaNameParam = 'mock'; const schemaNameParam = 'mock';
const activatedRouteStub = Object.assign(new ActivatedRouteStub(), { const activatedRouteStub = Object.assign(new ActivatedRouteStub(), {
params: Observable.of({ params: observableOf({
schemaName: schemaNameParam schemaName: schemaNameParam
}) })
}); });

View File

@@ -6,7 +6,7 @@ import { Collection } from '../../../core/shared/collection.model';
import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../core/cache/builders/remote-data-build.service';
import { getMockRemoteDataBuildService } from '../../../shared/mocks/mock-remote-data-build.service'; import { getMockRemoteDataBuildService } from '../../../shared/mocks/mock-remote-data-build.service';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data'; import { RemoteData } from '../../../core/data/remote-data';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -22,8 +22,8 @@ const mockCollection1: Collection = Object.assign(new Collection(), {
}] }]
}); });
const succeededMockItem: Item = Object.assign(new Item(), {owningCollection: Observable.of(new RemoteData(false, false, true, null, mockCollection1))}); const succeededMockItem: Item = Object.assign(new Item(), {owningCollection: observableOf(new RemoteData(false, false, true, null, mockCollection1))});
const failedMockItem: Item = Object.assign(new Item(), {owningCollection: Observable.of(new RemoteData(false, false, false, null, mockCollection1))}); const failedMockItem: Item = Object.assign(new Item(), {owningCollection: observableOf(new RemoteData(false, false, false, null, mockCollection1))});
describe('CollectionsComponent', () => { describe('CollectionsComponent', () => {
beforeEach(async(() => { beforeEach(async(() => {

View File

@@ -1,11 +1,10 @@
import { combineLatest as observableCombineLatest, Observable } from 'rxjs'; import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { Bitstream } from '../../../../core/shared/bitstream.model'; import { Bitstream } from '../../../../core/shared/bitstream.model';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
import { FileSectionComponent } from '../../../simple/field-components/file-section/file-section.component'; import { FileSectionComponent } from '../../../simple/field-components/file-section/file-section.component';
import { hasValue } from '../../../../shared/empty.util'; import { map } from 'rxjs/operators';
/** /**
* This component renders the file section of the item * This component renders the file section of the item
@@ -34,7 +33,7 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
initialize(): void { initialize(): void {
const originals = this.item.getFiles(); const originals = this.item.getFiles();
const licenses = this.item.getBitstreamsByBundleName('LICENSE'); const licenses = this.item.getBitstreamsByBundleName('LICENSE');
this.bitstreamsObs = observableCombineLatest(originals, licenses, (o, l) => [...o, ...l]); this.bitstreamsObs = observableCombineLatest(originals, licenses).pipe(map(([o, l]) => [...o, ...l]));
this.bitstreamsObs.subscribe( this.bitstreamsObs.subscribe(
(files) => (files) =>
files.forEach( files.forEach(

View File

@@ -3,7 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import { LoginPageComponent } from './login-page.component'; import { LoginPageComponent } from './login-page.component';
@@ -16,7 +16,7 @@ describe('LoginPageComponent', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
beforeEach(async(() => { beforeEach(async(() => {

View File

@@ -1,4 +1,3 @@
import 'rxjs/add/observable/of';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { PaginatedSearchOptions } from './paginated-search-options.model'; import { PaginatedSearchOptions } from './paginated-search-options.model';

View File

@@ -7,7 +7,7 @@ import { SearchFilterConfig } from '../../../search-service/search-filter-config
import { FilterType } from '../../../search-service/filter-type.model'; import { FilterType } from '../../../search-service/filter-type.model';
import { FacetValue } from '../../../search-service/facet-value.model'; import { FacetValue } from '../../../search-service/facet-value.model';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { SearchService } from '../../../search-service/search.service'; import { SearchService } from '../../../search-service/search.service';
import { SearchServiceStub } from '../../../../shared/testing/search-service-stub'; import { SearchServiceStub } from '../../../../shared/testing/search-service-stub';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
@@ -54,9 +54,9 @@ describe('SearchFacetFilterComponent', () => {
let filterService; let filterService;
let searchService; let searchService;
let router; let router;
const page = Observable.of(0); const page = observableOf(0);
const mockValues = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values))); const mockValues = observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule], imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
@@ -65,11 +65,11 @@ describe('SearchFacetFilterComponent', () => {
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) }, { provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: Router, useValue: new RouterStub() }, { provide: Router, useValue: new RouterStub() },
{ provide: FILTER_CONFIG, useValue: new SearchFilterConfig() }, { provide: FILTER_CONFIG, useValue: new SearchFilterConfig() },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => Observable.of({})} }, { provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} },
{ provide: SearchConfigurationService, useValue: {searchOptions: Observable.of({})} }, { provide: SearchConfigurationService, useValue: {searchOptions: observableOf({})} },
{ {
provide: SearchFilterService, useValue: { provide: SearchFilterService, useValue: {
getSelectedValuesForFilter: () => Observable.of(selectedValues), getSelectedValuesForFilter: () => observableOf(selectedValues),
isFilterActiveWithValue: (paramName: string, filterValue: string) => true, isFilterActiveWithValue: (paramName: string, filterValue: string) => true,
getPage: (paramName: string) => page, getPage: (paramName: string) => page,
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */

View File

@@ -1,4 +1,11 @@
import {combineLatest as observableCombineLatest, of as observableOf, BehaviorSubject , Observable , Subject , Subscription } from 'rxjs'; import {
combineLatest as observableCombineLatest,
of as observableOf,
BehaviorSubject,
Observable,
Subject,
Subscription
} from 'rxjs';
import { switchMap, distinctUntilChanged, first, map } from 'rxjs/operators'; import { switchMap, distinctUntilChanged, first, map } from 'rxjs/operators';
import { animate, state, style, transition, trigger } from '@angular/animations'; import { animate, state, style, transition, trigger } from '@angular/animations';
import { Component, Inject, OnDestroy, OnInit } from '@angular/core'; import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
@@ -82,9 +89,11 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
this.selectedValues = this.filterService.getSelectedValuesForFilter(this.filterConfig); this.selectedValues = this.filterService.getSelectedValuesForFilter(this.filterConfig);
const searchOptions = this.searchConfigService.searchOptions; const searchOptions = this.searchConfigService.searchOptions;
this.subs.push(this.searchConfigService.searchOptions.subscribe(() => this.updateFilterValueList())); this.subs.push(this.searchConfigService.searchOptions.subscribe(() => this.updateFilterValueList()));
const facetValues = observableCombineLatest(searchOptions, this.currentPage, (options, page) => { const facetValues = observableCombineLatest(searchOptions, this.currentPage).pipe(
map(([options, page]) => {
return { options, page } return { options, page }
}).pipe(switchMap(({ options, page }) => { }),
switchMap(({ options, page }) => {
return this.searchService.getFacetValuesFor(this.filterConfig, page, options) return this.searchService.getFacetValuesFor(this.filterConfig, page, options)
.pipe( .pipe(
getSucceededRemoteData(), getSucceededRemoteData(),
@@ -96,7 +105,8 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
} }
) )
) )
})); })
);
let filterValues = []; let filterValues = [];
this.subs.push(facetValues.subscribe((facetOutcome) => { this.subs.push(facetValues.subscribe((facetOutcome) => {
const newValues$ = facetOutcome.values; const newValues$ = facetOutcome.values;

View File

@@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { Observable, of as observableOf } from 'rxjs';
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { SearchFilterService } from './search-filter.service'; import { SearchFilterService } from './search-filter.service';
import { SearchService } from '../../search-service/search.service'; import { SearchService } from '../../search-service/search.service';
@@ -38,19 +38,19 @@ describe('SearchFilterComponent', () => {
initialExpand: (filter) => { initialExpand: (filter) => {
}, },
getSelectedValuesForFilter: (filter) => { getSelectedValuesForFilter: (filter) => {
return Observable.of([filterName1, filterName2, filterName3]) return observableOf([filterName1, filterName2, filterName3])
}, },
isFilterActive: (filter) => { isFilterActive: (filter) => {
return Observable.of([filterName1, filterName2, filterName3].indexOf(filter) >= 0); return observableOf([filterName1, filterName2, filterName3].indexOf(filter) >= 0);
}, },
isCollapsed: (filter) => { isCollapsed: (filter) => {
return Observable.of(true) return observableOf(true)
} }
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
}; };
let filterService; let filterService;
const mockResults = Observable.of(['test', 'data']); const mockResults = observableOf(['test', 'data']);
const searchServiceStub = { const searchServiceStub = {
getFacetValuesFor: (filter) => mockResults getFacetValuesFor: (filter) => mockResults
}; };
@@ -140,7 +140,7 @@ describe('SearchFilterComponent', () => {
describe('when isCollapsed is called and the filter is collapsed', () => { describe('when isCollapsed is called and the filter is collapsed', () => {
let isActive: Observable<boolean>; let isActive: Observable<boolean>;
beforeEach(() => { beforeEach(() => {
filterService.isCollapsed = () => Observable.of(true); filterService.isCollapsed = () => observableOf(true);
isActive = comp.isCollapsed(); isActive = comp.isCollapsed();
}); });
@@ -155,7 +155,7 @@ describe('SearchFilterComponent', () => {
describe('when isCollapsed is called and the filter is not collapsed', () => { describe('when isCollapsed is called and the filter is not collapsed', () => {
let isActive: Observable<boolean>; let isActive: Observable<boolean>;
beforeEach(() => { beforeEach(() => {
filterService.isCollapsed = () => Observable.of(false); filterService.isCollapsed = () => observableOf(false);
isActive = comp.isCollapsed(); isActive = comp.isCollapsed();
}); });

View File

@@ -1,16 +1,20 @@
import { Observable } from 'rxjs';
import { SearchFilterService } from './search-filter.service'; import { SearchFilterService } from './search-filter.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { import {
SearchFilterCollapseAction, SearchFilterDecrementPageAction, SearchFilterExpandAction, SearchFilterCollapseAction,
SearchFilterDecrementPageAction,
SearchFilterExpandAction,
SearchFilterIncrementPageAction, SearchFilterIncrementPageAction,
SearchFilterInitialCollapseAction, SearchFilterInitialExpandAction, SearchFilterResetPageAction, SearchFilterInitialCollapseAction,
SearchFilterInitialExpandAction,
SearchFilterResetPageAction,
SearchFilterToggleAction SearchFilterToggleAction
} from './search-filter.actions'; } from './search-filter.actions';
import { SearchFiltersState } from './search-filter.reducer'; import { SearchFiltersState } from './search-filter.reducer';
import { SearchFilterConfig } from '../../search-service/search-filter-config.model'; import { SearchFilterConfig } from '../../search-service/search-filter-config.model';
import { FilterType } from '../../search-service/filter-type.model'; import { FilterType } from '../../search-service/filter-type.model';
import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub'; import { ActivatedRouteStub } from '../../../shared/testing/active-router-stub';
import { of as observableOf } from 'rxjs';
describe('SearchFilterService', () => { describe('SearchFilterService', () => {
let service: SearchFilterService; let service: SearchFilterService;
@@ -28,7 +32,7 @@ describe('SearchFilterService', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
const routeServiceStub: any = { const routeServiceStub: any = {
@@ -42,10 +46,10 @@ describe('SearchFilterService', () => {
addQueryParameterValue: (param: string, value: string) => { addQueryParameterValue: (param: string, value: string) => {
}, },
getQueryParameterValues: (param: string) => { getQueryParameterValues: (param: string) => {
return Observable.of({}); return observableOf({});
}, },
getQueryParamsWithPrefix: (param: string) => { getQueryParamsWithPrefix: (param: string) => {
return Observable.of({}); return observableOf({});
} }
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
}; };

View File

@@ -1,6 +1,6 @@
import { combineLatest as observableCombineLatest, Observable } from 'rxjs'; import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Injectable, InjectionToken } from '@angular/core'; import { Injectable, InjectionToken } from '@angular/core';
import { distinctUntilChanged, map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { SearchFiltersState, SearchFilterState } from './search-filter.reducer'; import { SearchFiltersState, SearchFilterState } from './search-filter.reducer';
import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store'; import { createSelector, MemoizedSelector, select, Store } from '@ngrx/store';
import { import {
@@ -13,14 +13,10 @@ import {
SearchFilterResetPageAction, SearchFilterResetPageAction,
SearchFilterToggleAction SearchFilterToggleAction
} from './search-filter.actions'; } from './search-filter.actions';
import { hasValue, isEmpty, isNotEmpty, } from '../../../shared/empty.util'; import { hasValue, isNotEmpty, } from '../../../shared/empty.util';
import { SearchFilterConfig } from '../../search-service/search-filter-config.model'; import { SearchFilterConfig } from '../../search-service/search-filter-config.model';
import { RouteService } from '../../../shared/services/route.service'; import { RouteService } from '../../../shared/services/route.service';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model'; import { Params } from '@angular/router';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { SearchOptions } from '../../search-options.model';
import { PaginatedSearchOptions } from '../../paginated-search-options.model';
import { ActivatedRoute, Params } from '@angular/router';
const filterStateSelector = (state: SearchFiltersState) => state.searchFilter; const filterStateSelector = (state: SearchFiltersState) => state.searchFilter;
@@ -63,13 +59,19 @@ export class SearchFilterService {
*/ */
getSelectedValuesForFilter(filterConfig: SearchFilterConfig): Observable<string[]> { getSelectedValuesForFilter(filterConfig: SearchFilterConfig): Observable<string[]> {
const values$ = this.routeService.getQueryParameterValues(filterConfig.paramName); const values$ = this.routeService.getQueryParameterValues(filterConfig.paramName);
const prefixValues$ = this.routeService.getQueryParamsWithPrefix(filterConfig.paramName + '.').pipe(map((params: Params) => [].concat(...Object.values(params)))); const prefixValues$ = this.routeService.getQueryParamsWithPrefix(filterConfig.paramName + '.').pipe(
return observableCombineLatest(values$, prefixValues$, (values, prefixValues) => { map((params: Params) => [].concat(...Object.values(params)))
);
return observableCombineLatest(values$, prefixValues$).pipe(
map(([values, prefixValues]) => {
if (isNotEmpty(values)) { if (isNotEmpty(values)) {
return values; return values;
} }
return prefixValues; return prefixValues;
}) }
)
)
} }
/** /**

View File

@@ -7,7 +7,7 @@ import { SearchFilterConfig } from '../../../search-service/search-filter-config
import { FilterType } from '../../../search-service/filter-type.model'; import { FilterType } from '../../../search-service/filter-type.model';
import { FacetValue } from '../../../search-service/facet-value.model'; import { FacetValue } from '../../../search-service/facet-value.model';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs'
import { SearchService } from '../../../search-service/search.service'; import { SearchService } from '../../../search-service/search.service';
import { SearchServiceStub } from '../../../../shared/testing/search-service-stub'; import { SearchServiceStub } from '../../../../shared/testing/search-service-stub';
import { RemoteData } from '../../../../core/data/remote-data'; import { RemoteData } from '../../../../core/data/remote-data';
@@ -56,13 +56,13 @@ describe('SearchRangeFilterComponent', () => {
]; ];
const searchLink = '/search'; const searchLink = '/search';
const selectedValues = Observable.of([value1]); const selectedValues = observableOf([value1]);
let filterService; let filterService;
let searchService; let searchService;
let router; let router;
const page = Observable.of(0); const page = observableOf(0);
const mockValues = Observable.of(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values))); const mockValues = observableOf(new RemoteData(false, false, true, null, new PaginatedList(new PageInfo(), values)));
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule], imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
@@ -71,10 +71,10 @@ describe('SearchRangeFilterComponent', () => {
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) }, { provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: Router, useValue: new RouterStub() }, { provide: Router, useValue: new RouterStub() },
{ provide: FILTER_CONFIG, useValue: mockFilterConfig }, { provide: FILTER_CONFIG, useValue: mockFilterConfig },
{ provide: RemoteDataBuildService, useValue: {aggregate: () => Observable.of({})} }, { provide: RemoteDataBuildService, useValue: {aggregate: () => observableOf({})} },
{ provide: RouteService, useValue: {getQueryParameterValue: () => Observable.of({})} }, { provide: RouteService, useValue: {getQueryParameterValue: () => observableOf({})} },
{ provide: SearchConfigurationService, useValue: { { provide: SearchConfigurationService, useValue: {
searchOptions: Observable.of({}) } searchOptions: observableOf({}) }
}, },
{ {
provide: SearchFilterService, useValue: { provide: SearchFilterService, useValue: {

View File

@@ -1,5 +1,10 @@
import {of as observableOf, combineLatest as observableCombineLatest, Observable , Subscription } from 'rxjs'; import {
import {startWith} from 'rxjs/operators'; of as observableOf,
combineLatest as observableCombineLatest,
Observable,
Subscription
} from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { isPlatformBrowser } from '@angular/common'; import { isPlatformBrowser } from '@angular/common';
import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core'; import { Component, Inject, OnDestroy, OnInit, PLATFORM_ID } from '@angular/core';
import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../../core/cache/builders/remote-data-build.service';
@@ -82,11 +87,13 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
this.max = moment(this.filterConfig.maxValue, dateFormats).year() || this.max; this.max = moment(this.filterConfig.maxValue, dateFormats).year() || this.max;
const iniMin = this.route.getQueryParameterValue(this.filterConfig.paramName + minSuffix).pipe(startWith(undefined)); const iniMin = this.route.getQueryParameterValue(this.filterConfig.paramName + minSuffix).pipe(startWith(undefined));
const iniMax = this.route.getQueryParameterValue(this.filterConfig.paramName + maxSuffix).pipe(startWith(undefined)); const iniMax = this.route.getQueryParameterValue(this.filterConfig.paramName + maxSuffix).pipe(startWith(undefined));
this.sub = observableCombineLatest(iniMin, iniMax, (min, max) => { this.sub = observableCombineLatest(iniMin, iniMax).pipe(
map(([min, max]) => {
const minimum = hasValue(min) ? min : this.min; const minimum = hasValue(min) ? min : this.min;
const maximum = hasValue(max) ? max : this.max; const maximum = hasValue(max) ? max : this.max;
return [minimum, maximum] return [minimum, maximum]
}).subscribe((minmax) => this.range = minmax); })
).subscribe((minmax) => this.range = minmax);
} }
/** /**

View File

@@ -7,8 +7,8 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { SearchFilterService } from './search-filter/search-filter.service'; import { SearchFilterService } from './search-filter/search-filter.service';
import { SearchFiltersComponent } from './search-filters.component'; import { SearchFiltersComponent } from './search-filters.component';
import { SearchService } from '../search-service/search.service'; import { SearchService } from '../search-service/search.service';
import { Observable } from 'rxjs';
import { SearchConfigurationService } from '../search-service/search-configuration.service'; import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { of as observableOf } from 'rxjs';
describe('SearchFiltersComponent', () => { describe('SearchFiltersComponent', () => {
let comp: SearchFiltersComponent; let comp: SearchFiltersComponent;
@@ -17,7 +17,7 @@ describe('SearchFiltersComponent', () => {
const searchServiceStub = { const searchServiceStub = {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
getConfig: () => getConfig: () =>
Observable.of({ hasSucceeded: true, payload: [] }), observableOf({ hasSucceeded: true, payload: [] }),
getClearFiltersQueryParams: () => { getClearFiltersQueryParams: () => {
}, },
getSearchLink: () => { getSearchLink: () => {
@@ -31,7 +31,7 @@ describe('SearchFiltersComponent', () => {
}; };
const searchConfigServiceStub = jasmine.createSpyObj('SearchConfigurationService', { const searchConfigServiceStub = jasmine.createSpyObj('SearchConfigurationService', {
getCurrentFrontendFilters: Observable.of({}) getCurrentFrontendFilters: observableOf({})
}); });
beforeEach(async(() => { beforeEach(async(() => {

View File

@@ -6,7 +6,7 @@ import { SearchService } from '../search-service/search.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { SearchServiceStub } from '../../shared/testing/search-service-stub'; import { SearchServiceStub } from '../../shared/testing/search-service-stub';
import { Observable } from 'rxjs'; import { Observable, of as observableOf } from 'rxjs';
import { Params } from '@angular/router'; import { Params } from '@angular/router';
import { ObjectKeysPipe } from '../../shared/utils/object-keys-pipe'; import { ObjectKeysPipe } from '../../shared/utils/object-keys-pipe';
import { SearchConfigurationService } from '../search-service/search-configuration.service'; import { SearchConfigurationService } from '../search-service/search-configuration.service';
@@ -35,7 +35,7 @@ describe('SearchLabelsComponent', () => {
declarations: [SearchLabelsComponent, ObjectKeysPipe], declarations: [SearchLabelsComponent, ObjectKeysPipe],
providers: [ providers: [
{ provide: SearchService, useValue: new SearchServiceStub(searchLink) }, { provide: SearchService, useValue: new SearchServiceStub(searchLink) },
{ provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => Observable.of({})} } { provide: SearchConfigurationService, useValue: {getCurrentFrontendFilters : () => observableOf({})} }
], ],
schemas: [NO_ERRORS_SCHEMA] schemas: [NO_ERRORS_SCHEMA]
}).overrideComponent(SearchLabelsComponent, { }).overrideComponent(SearchLabelsComponent, {
@@ -47,7 +47,7 @@ describe('SearchLabelsComponent', () => {
fixture = TestBed.createComponent(SearchLabelsComponent); fixture = TestBed.createComponent(SearchLabelsComponent);
comp = fixture.componentInstance; comp = fixture.componentInstance;
searchService = (comp as any).searchService; searchService = (comp as any).searchService;
(comp as any).appliedFilters = Observable.of(mockFilters); (comp as any).appliedFilters = observableOf(mockFilters);
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -5,8 +5,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { cold, hot } from 'jasmine-marbles'; import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { CommunityDataService } from '../core/data/community-data.service'; import { CommunityDataService } from '../core/data/community-data.service';
import { HostWindowService } from '../shared/host-window.service'; import { HostWindowService } from '../shared/host-window.service';
@@ -30,18 +29,18 @@ describe('SearchPageComponent', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
const pagination: PaginationComponentOptions = new PaginationComponentOptions(); const pagination: PaginationComponentOptions = new PaginationComponentOptions();
pagination.id = 'search-results-pagination'; pagination.id = 'search-results-pagination';
pagination.currentPage = 1; pagination.currentPage = 1;
pagination.pageSize = 10; pagination.pageSize = 10;
const sort: SortOptions = new SortOptions('score', SortDirection.DESC); const sort: SortOptions = new SortOptions('score', SortDirection.DESC);
const mockResults = Observable.of(new RemoteData(false, false, true, null, ['test', 'data'])); const mockResults = observableOf(new RemoteData(false, false, true, null, ['test', 'data']));
const searchServiceStub = jasmine.createSpyObj('SearchService', { const searchServiceStub = jasmine.createSpyObj('SearchService', {
search: mockResults, search: mockResults,
getSearchLink: '/search', getSearchLink: '/search',
getScopes: Observable.of(['test-scope']) getScopes: observableOf(['test-scope'])
}); });
const queryParam = 'test query'; const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
@@ -52,15 +51,15 @@ describe('SearchPageComponent', () => {
sort sort
}; };
const activatedRouteStub = { const activatedRouteStub = {
queryParams: Observable.of({ queryParams: observableOf({
query: queryParam, query: queryParam,
scope: scopeParam scope: scopeParam
}) })
}; };
const sidebarService = { const sidebarService = {
isCollapsed: Observable.of(true), isCollapsed: observableOf(true),
collapse: () => this.isCollapsed = Observable.of(true), collapse: () => this.isCollapsed = observableOf(true),
expand: () => this.isCollapsed = Observable.of(false) expand: () => this.isCollapsed = observableOf(false)
}; };
beforeEach(async(() => { beforeEach(async(() => {
@@ -80,9 +79,9 @@ describe('SearchPageComponent', () => {
{ {
provide: HostWindowService, useValue: jasmine.createSpyObj('hostWindowService', provide: HostWindowService, useValue: jasmine.createSpyObj('hostWindowService',
{ {
isXs: Observable.of(true), isXs: observableOf(true),
isSm: Observable.of(false), isSm: observableOf(false),
isXsOrSm: Observable.of(true) isXsOrSm: observableOf(true)
}) })
}, },
{ {
@@ -98,7 +97,7 @@ describe('SearchPageComponent', () => {
paginatedSearchOptions: hot('a', { paginatedSearchOptions: hot('a', {
a: paginatedSearchOptions a: paginatedSearchOptions
}), }),
getCurrentScope: (a) => Observable.of('test-id') getCurrentScope: (a) => observableOf('test-id')
} }
}, },
], ],
@@ -154,7 +153,7 @@ describe('SearchPageComponent', () => {
beforeEach(() => { beforeEach(() => {
menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement; menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement;
comp.isSidebarCollapsed = () => Observable.of(true); comp.isSidebarCollapsed = () => observableOf(true);
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -169,7 +168,7 @@ describe('SearchPageComponent', () => {
beforeEach(() => { beforeEach(() => {
menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement; menu = fixture.debugElement.query(By.css('#search-sidebar-sm')).nativeElement;
comp.isSidebarCollapsed = () => Observable.of(false); comp.isSidebarCollapsed = () => observableOf(false);
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -3,8 +3,8 @@ import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginatedSearchOptions } from '../paginated-search-options.model'; import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Observable } from 'rxjs';
import { SearchFilter } from '../search-filter.model'; import { SearchFilter } from '../search-filter.model';
import { of as observableOf } from 'rxjs';
describe('SearchConfigurationService', () => { describe('SearchConfigurationService', () => {
let service: SearchConfigurationService; let service: SearchConfigurationService;
@@ -24,8 +24,8 @@ describe('SearchConfigurationService', () => {
const backendFilters = [new SearchFilter('f.author', ['another value']), new SearchFilter('f.date', ['[2013 TO 2018]'])]; const backendFilters = [new SearchFilter('f.author', ['another value']), new SearchFilter('f.date', ['[2013 TO 2018]'])];
const spy = jasmine.createSpyObj('RouteService', { const spy = jasmine.createSpyObj('RouteService', {
getQueryParameterValue: Observable.of(value1), getQueryParameterValue: observableOf(value1),
getQueryParamsWithPrefix: Observable.of(prefixFilter) getQueryParamsWithPrefix: observableOf(prefixFilter)
}); });
const activatedRoute: any = new ActivatedRouteStub(); const activatedRoute: any = new ActivatedRouteStub();

View File

@@ -1,4 +1,11 @@
import {of as observableOf, merge as observableMerge, combineLatest as observableCombineLatest, Observable , BehaviorSubject , Subscription } from 'rxjs'; import {
BehaviorSubject,
combineLatest as observableCombineLatest,
merge as observableMerge,
Observable,
of as observableOf,
Subscription
} from 'rxjs';
import { filter, map } from 'rxjs/operators'; import { filter, map } from 'rxjs/operators';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
@@ -7,7 +14,7 @@ import { ActivatedRoute, Params } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model'; import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Injectable, OnDestroy } from '@angular/core'; import { Injectable, OnDestroy } from '@angular/core';
import { RouteService } from '../../shared/services/route.service'; import { RouteService } from '../../shared/services/route.service';
import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util'; import { hasNoValue, hasValue, isNotEmpty } from '../../shared/empty.util';
import { RemoteData } from '../../core/data/remote-data'; import { RemoteData } from '../../core/data/remote-data';
import { getSucceededRemoteData } from '../../core/shared/operators'; import { getSucceededRemoteData } from '../../core/shared/operators';
import { SearchFilter } from '../search-filter.model'; import { SearchFilter } from '../search-filter.model';
@@ -115,12 +122,13 @@ export class SearchConfigurationService implements OnDestroy {
getCurrentPagination(defaultPagination: PaginationComponentOptions): Observable<PaginationComponentOptions> { getCurrentPagination(defaultPagination: PaginationComponentOptions): Observable<PaginationComponentOptions> {
const page$ = this.routeService.getQueryParameterValue('page'); const page$ = this.routeService.getQueryParameterValue('page');
const size$ = this.routeService.getQueryParameterValue('pageSize'); const size$ = this.routeService.getQueryParameterValue('pageSize');
return observableCombineLatest(page$, size$, (page, size) => { return observableCombineLatest(page$, size$).pipe(map(([page, size]) => {
return Object.assign(new PaginationComponentOptions(), defaultPagination, { return Object.assign(new PaginationComponentOptions(), defaultPagination, {
currentPage: page || defaultPagination.currentPage, currentPage: page || defaultPagination.currentPage,
pageSize: size || defaultPagination.pageSize pageSize: size || defaultPagination.pageSize
}); });
}); })
);
} }
/** /**
@@ -129,7 +137,7 @@ export class SearchConfigurationService implements OnDestroy {
getCurrentSort(defaultSort: SortOptions): Observable<SortOptions> { getCurrentSort(defaultSort: SortOptions): Observable<SortOptions> {
const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection'); const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection');
const sortField$ = this.routeService.getQueryParameterValue('sortField'); const sortField$ = this.routeService.getQueryParameterValue('sortField');
return observableCombineLatest(sortDirection$, sortField$, (sortDirection, sortField) => { return observableCombineLatest(sortDirection$, sortField$).pipe(map(([sortDirection, sortField]) => {
// Dirty fix because sometimes the observable value is null somehow // Dirty fix because sometimes the observable value is null somehow
sortField = this.route.snapshot.queryParamMap.get('sortField'); sortField = this.route.snapshot.queryParamMap.get('sortField');
@@ -138,6 +146,7 @@ export class SearchConfigurationService implements OnDestroy {
return new SortOptions(field, direction) return new SortOptions(field, direction)
} }
) )
);
} }
/** /**

View File

@@ -12,7 +12,7 @@ import { ResponseCacheService } from '../../core/cache/response-cache.service';
import { ActivatedRouteStub } from '../../shared/testing/active-router-stub'; import { ActivatedRouteStub } from '../../shared/testing/active-router-stub';
import { RouterStub } from '../../shared/testing/router-stub'; import { RouterStub } from '../../shared/testing/router-stub';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service'; import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
import { Observable } from 'rxjs'; import { Observable, combineLatest as observableCombineLatest } from 'rxjs';
import { PaginatedSearchOptions } from '../paginated-search-options.model'; import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { RemoteData } from '../../core/data/remote-data'; import { RemoteData } from '../../core/data/remote-data';
import { ResponseCacheEntry } from '../../core/cache/response-cache.reducer'; import { ResponseCacheEntry } from '../../core/cache/response-cache.reducer';
@@ -28,6 +28,8 @@ import { SearchFilterConfig } from './search-filter-config.model';
import { CommunityDataService } from '../../core/data/community-data.service'; import { CommunityDataService } from '../../core/data/community-data.service';
import { ViewMode } from '../../core/shared/view-mode.model'; import { ViewMode } from '../../core/shared/view-mode.model';
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service'; import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
import { of as observableOf } from 'rxjs';
import { map } from 'rxjs/operators';
@Component({ template: '' }) @Component({ template: '' })
class DummyComponent { class DummyComponent {
@@ -85,13 +87,15 @@ describe('SearchService', () => {
const remoteDataBuildService = { const remoteDataBuildService = {
toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => { toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => {
return Observable.combineLatest(requestEntryObs, return observableCombineLatest(requestEntryObs,
responseCacheObs, payloadObs, (req, res, pay) => { responseCacheObs, payloadObs).pipe(
map(([req, res, pay]) => {
return { req, res, pay }; return { req, res, pay };
}); })
);
}, },
aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => { aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => {
return Observable.of(new RemoteData(false, false, true, null, [])); return observableOf(new RemoteData(false, false, true, null, []));
} }
}; };
@@ -160,8 +164,8 @@ describe('SearchService', () => {
const response = new SearchSuccessResponse(queryResponse, '200'); const response = new SearchSuccessResponse(queryResponse, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint)); spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
searchService.search(searchOptions).subscribe((t) => { searchService.search(searchOptions).subscribe((t) => {
}); // subscribe to make sure all methods are called }); // subscribe to make sure all methods are called
@@ -190,8 +194,8 @@ describe('SearchService', () => {
const response = new FacetConfigSuccessResponse(filterConfig, '200'); const response = new FacetConfigSuccessResponse(filterConfig, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint)); spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
searchService.getConfig(null).subscribe((t) => { searchService.getConfig(null).subscribe((t) => {
}); // subscribe to make sure all methods are called }); // subscribe to make sure all methods are called
@@ -222,8 +226,8 @@ describe('SearchService', () => {
const response = new FacetConfigSuccessResponse(filterConfig, '200'); const response = new FacetConfigSuccessResponse(filterConfig, '200');
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endPoint)); spyOn((searchService as any).halService, 'getEndpoint').and.returnValue(observableOf(endPoint));
(searchService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (searchService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
searchService.getConfig(scope).subscribe((t) => { searchService.getConfig(scope).subscribe((t) => {
}); // subscribe to make sure all methods are called }); // subscribe to make sure all methods are called

View File

@@ -122,8 +122,8 @@ export class SearchService implements OnDestroy {
); );
// Create search results again with the correct dso objects linked to each result // Create search results again with the correct dso objects linked to each result
const tDomainListObs = observableCombineLatest(sqrObs, dsoObs, (sqr: SearchQueryResponse, dsos: RemoteData<DSpaceObject[]>) => { const tDomainListObs = observableCombineLatest(sqrObs, dsoObs).pipe(
map(([sqr, dsos]) => {
return sqr.objects.map((object: NormalizedSearchResult, index: number) => { return sqr.objects.map((object: NormalizedSearchResult, index: number) => {
let co = DSpaceObject; let co = DSpaceObject;
if (dsos.payload[index]) { if (dsos.payload[index]) {
@@ -136,16 +136,19 @@ export class SearchService implements OnDestroy {
return undefined; return undefined;
} }
}); });
}); })
);
const pageInfoObs: Observable<PageInfo> = responseCacheObs.pipe( const pageInfoObs: Observable<PageInfo> = responseCacheObs.pipe(
map((entry: ResponseCacheEntry) => entry.response), map((entry: ResponseCacheEntry) => entry.response),
map((response: FacetValueSuccessResponse) => response.pageInfo) map((response: FacetValueSuccessResponse) => response.pageInfo)
); );
const payloadObs = observableCombineLatest(tDomainListObs, pageInfoObs, (tDomainList, pageInfo) => { const payloadObs = observableCombineLatest(tDomainListObs, pageInfoObs).pipe(
map(([tDomainList, pageInfo]) => {
return new PaginatedList(pageInfo, tDomainList); return new PaginatedList(pageInfo, tDomainList);
}); })
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
} }
@@ -244,9 +247,11 @@ export class SearchService implements OnDestroy {
map((response: FacetValueSuccessResponse) => response.pageInfo) map((response: FacetValueSuccessResponse) => response.pageInfo)
); );
const payloadObs = observableCombineLatest(facetValueObs, pageInfoObs, (facetValue, pageInfo) => { const payloadObs = observableCombineLatest(facetValueObs, pageInfoObs).pipe(
map(([facetValue, pageInfo]) => {
return new PaginatedList(pageInfo, facetValue); return new PaginatedList(pageInfo, facetValue);
}); })
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
} }
@@ -272,10 +277,12 @@ export class SearchService implements OnDestroy {
switchMap((dsoRD: RemoteData<DSpaceObject>) => { switchMap((dsoRD: RemoteData<DSpaceObject>) => {
if (dsoRD.payload.type === ResourceType.Community) { if (dsoRD.payload.type === ResourceType.Community) {
const community: Community = dsoRD.payload as Community; const community: Community = dsoRD.payload as Community;
return observableCombineLatest(community.subcommunities, community.collections, (subCommunities, collections) => { return observableCombineLatest(community.subcommunities, community.collections).pipe(
map(([subCommunities, collections]) => {
/*if this is a community, we also need to show the direct children*/ /*if this is a community, we also need to show the direct children*/
return [community, ...subCommunities.payload.page, ...collections.payload.page] return [community, ...subCommunities.payload.page, ...collections.payload.page]
}) })
);
} else { } else {
return observableOf([dsoRD.payload]); return observableOf([dsoRD.payload]);
} }

View File

@@ -1,7 +1,7 @@
import { SearchService } from '../search-service/search.service'; import { SearchService } from '../search-service/search.service';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SearchSettingsComponent } from './search-settings.component'; import { SearchSettingsComponent } from './search-settings.component';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
@@ -15,6 +15,7 @@ import { SearchFilterService } from '../search-filters/search-filter/search-filt
import { hot } from 'jasmine-marbles'; import { hot } from 'jasmine-marbles';
import { VarDirective } from '../../shared/utils/var.directive'; import { VarDirective } from '../../shared/utils/var.directive';
import { SearchConfigurationService } from '../search-service/search-configuration.service'; import { SearchConfigurationService } from '../search-service/search-configuration.service';
import { first } from 'rxjs/operators';
describe('SearchSettingsComponent', () => { describe('SearchSettingsComponent', () => {
@@ -43,16 +44,16 @@ describe('SearchSettingsComponent', () => {
}; };
const activatedRouteStub = { const activatedRouteStub = {
queryParams: Observable.of({ queryParams: observableOf({
query: queryParam, query: queryParam,
scope: scopeParam scope: scopeParam
}) })
}; };
const sidebarService = { const sidebarService = {
isCollapsed: Observable.of(true), isCollapsed: observableOf(true),
collapse: () => this.isCollapsed = Observable.of(true), collapse: () => this.isCollapsed = observableOf(true),
expand: () => this.isCollapsed = Observable.of(false) expand: () => this.isCollapsed = observableOf(false)
}; };
beforeEach(async(() => { beforeEach(async(() => {
@@ -101,7 +102,7 @@ describe('SearchSettingsComponent', () => {
}); });
it('it should show the order settings with the respective selectable options', () => { it('it should show the order settings with the respective selectable options', () => {
(comp as any).searchOptions$.first().subscribe((options) => { (comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges(); fixture.detectChanges();
const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings')); const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings'));
expect(orderSetting).toBeDefined(); expect(orderSetting).toBeDefined();
@@ -111,7 +112,7 @@ describe('SearchSettingsComponent', () => {
}); });
it('it should show the size settings with the respective selectable options', () => { it('it should show the size settings with the respective selectable options', () => {
(comp as any).searchOptions$.first().subscribe((options) => { (comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges(); fixture.detectChanges();
const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings')); const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings'));
expect(pageSizeSetting).toBeDefined(); expect(pageSizeSetting).toBeDefined();
@@ -122,7 +123,7 @@ describe('SearchSettingsComponent', () => {
}); });
it('should have the proper order value selected by default', () => { it('should have the proper order value selected by default', () => {
(comp as any).searchOptions$.first().subscribe((options) => { (comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges(); fixture.detectChanges();
const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings')); const orderSetting = fixture.debugElement.query(By.css('div.result-order-settings'));
const childElementToBeSelected = orderSetting.query(By.css('.form-control option[value="0"][selected="selected"]')); const childElementToBeSelected = orderSetting.query(By.css('.form-control option[value="0"][selected="selected"]'));
@@ -131,7 +132,7 @@ describe('SearchSettingsComponent', () => {
}); });
it('should have the proper rpp value selected by default', () => { it('should have the proper rpp value selected by default', () => {
(comp as any).searchOptions$.first().subscribe((options) => { (comp as any).searchOptions$.pipe(first()).subscribe((options) => {
fixture.detectChanges(); fixture.detectChanges();
const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings')); const pageSizeSetting = fixture.debugElement.query(By.css('div.page-size-settings'));
const childElementToBeSelected = pageSizeSetting.query(By.css('.form-control option[value="10"][selected="selected"]')); const childElementToBeSelected = pageSizeSetting.query(By.css('.form-control option[value="10"][selected="selected"]'));

View File

@@ -3,7 +3,6 @@ import { SearchService } from '../search-service/search.service';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router'; import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model'; import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { SearchFilterService } from '../search-filters/search-filter/search-filter.service';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { SearchConfigurationService } from '../search-service/search-configuration.service'; import { SearchConfigurationService } from '../search-service/search-configuration.service';

View File

@@ -1,8 +1,8 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { SearchSidebarService } from './search-sidebar.service'; import { SearchSidebarService } from './search-sidebar.service';
import { AppState } from '../../app.reducer'; import { AppState } from '../../app.reducer';
import { async, inject, TestBed } from '@angular/core/testing'; import { async, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions'; import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions';
import { HostWindowService } from '../../shared/host-window.service'; import { HostWindowService } from '../../shared/host-window.service';
@@ -13,13 +13,13 @@ describe('SearchSidebarService', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
const windowService = jasmine.createSpyObj('hostWindowService', const windowService = jasmine.createSpyObj('hostWindowService',
{ {
isXs: Observable.of(true), isXs: observableOf(true),
isSm: Observable.of(false), isSm: observableOf(false),
isXsOrSm: Observable.of(true) isXsOrSm: observableOf(true)
}); });
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({

View File

@@ -5,6 +5,7 @@ import { createSelector, select, Store } from '@ngrx/store';
import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions'; import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from './search-sidebar.actions';
import { AppState } from '../../app.reducer'; import { AppState } from '../../app.reducer';
import { HostWindowService } from '../../shared/host-window.service'; import { HostWindowService } from '../../shared/host-window.service';
import { map } from 'rxjs/operators';
const sidebarStateSelector = (state: AppState) => state.searchSidebar; const sidebarStateSelector = (state: AppState) => state.searchSidebar;
const sidebarCollapsedSelector = createSelector(sidebarStateSelector, (sidebar: SearchSidebarState) => sidebar.sidebarCollapsed); const sidebarCollapsedSelector = createSelector(sidebarStateSelector, (sidebar: SearchSidebarState) => sidebar.sidebarCollapsed);
@@ -36,8 +37,10 @@ export class SearchSidebarService {
get isCollapsed(): Observable<boolean> { get isCollapsed(): Observable<boolean> {
return observableCombineLatest( return observableCombineLatest(
this.isXsOrSm$, this.isXsOrSm$,
this.isCollapsedInStore, this.isCollapsedInStore
(mobile, store) => mobile ? store : true); ).pipe(
map(([mobile, store]) => mobile ? store : true)
);
} }
/** /**

View File

@@ -92,7 +92,7 @@ describe('App component', () => {
let store: Store<HostWindowState>; let store: Store<HostWindowState>;
beforeEach(() => { beforeEach(() => {
store = fixture.debugElement.injector.get(Store); store = fixture.debugElement.injector.get(Store) as Store<HostWindowState>;
spyOn(store, 'dispatch'); spyOn(store, 'dispatch');
window.dispatchEvent(new Event('resize')); window.dispatchEvent(new Event('resize'));

View File

@@ -5,7 +5,7 @@ import { Store } from '@ngrx/store';
import { cold, hot } from 'jasmine-marbles'; import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import 'rxjs/add/observable/of' import { of as observableOf } from 'rxjs';
import { AuthEffects } from './auth.effects'; import { AuthEffects } from './auth.effects';
import { import {
@@ -36,7 +36,7 @@ describe('AuthEffects', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
const token = authServiceStub.getToken(); const token = authServiceStub.getToken();

View File

@@ -4,7 +4,7 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { AuthInterceptor } from './auth.interceptor'; import { AuthInterceptor } from './auth.interceptor';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
@@ -23,7 +23,7 @@ describe(`AuthInterceptor`, () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
beforeEach(() => { beforeEach(() => {

View File

@@ -3,9 +3,9 @@ import { CommonModule } from '@angular/common';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Store, StoreModule } from '@ngrx/store'; import { Store, StoreModule } from '@ngrx/store';
import { Observable } from 'rxjs';
import { REQUEST } from '@nguniversal/express-engine/tokens'; import { REQUEST } from '@nguniversal/express-engine/tokens';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import { of as observableOf } from 'rxjs';
import { authReducer, AuthState } from './auth.reducer'; import { authReducer, AuthState } from './auth.reducer';
import { NativeWindowRef, NativeWindowService } from '../../shared/services/window.service'; import { NativeWindowRef, NativeWindowService } from '../../shared/services/window.service';
@@ -27,7 +27,7 @@ describe('AuthService test', () => {
const mockStore: Store<AuthState> = jasmine.createSpyObj('store', { const mockStore: Store<AuthState> = jasmine.createSpyObj('store', {
dispatch: {}, dispatch: {},
select: Observable.of(true) select: observableOf(true)
}); });
let authService: AuthService; let authService: AuthService;
const authRequest = new AuthRequestServiceStub(); const authRequest = new AuthRequestServiceStub();

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing';
import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service'; import { getMockRemoteDataBuildService } from '../../shared/mocks/mock-remote-data-build.service';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service'; import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';

View File

@@ -1,5 +1,9 @@
import {
import {combineLatest as observableCombineLatest, of as observableOf, Observable, race as observableRace } from 'rxjs'; combineLatest as observableCombineLatest,
of as observableOf,
Observable,
race as observableRace
} from 'rxjs';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { distinctUntilChanged, flatMap, map, startWith } from 'rxjs/operators'; import { distinctUntilChanged, flatMap, map, startWith } from 'rxjs/operators';
import { hasValue, hasValueOperator, isEmpty, isNotEmpty } from '../../../shared/empty.util'; import { hasValue, hasValueOperator, isEmpty, isNotEmpty } from '../../../shared/empty.util';
@@ -66,15 +70,15 @@ export class RemoteDataBuildService {
}), }),
distinctUntilChanged(), distinctUntilChanged(),
startWith(undefined) startWith(undefined)
), )
(fromSelfLink, fromResponse) => { ).pipe(
map(([fromSelfLink, fromResponse]) => {
if (hasValue(fromSelfLink)) { if (hasValue(fromSelfLink)) {
return fromSelfLink; return fromSelfLink;
} else { } else {
return fromResponse; return fromResponse;
} }
} }),
).pipe(
hasValueOperator(), hasValueOperator(),
map((normalized: TNormalized) => { map((normalized: TNormalized) => {
return this.build<TNormalized, TDomain>(normalized); return this.build<TNormalized, TDomain>(normalized);
@@ -86,8 +90,8 @@ export class RemoteDataBuildService {
} }
toRemoteDataObservable<T>(requestEntry$: Observable<RequestEntry>, responseCache$: Observable<ResponseCacheEntry>, payload$: Observable<T>) { toRemoteDataObservable<T>(requestEntry$: Observable<RequestEntry>, responseCache$: Observable<ResponseCacheEntry>, payload$: Observable<T>) {
return observableCombineLatest(requestEntry$, responseCache$.pipe(startWith(undefined)), payload$, return observableCombineLatest(requestEntry$, responseCache$.pipe(startWith(undefined)), payload$).pipe(
(reqEntry: RequestEntry, resEntry: ResponseCacheEntry, payload: T) => { map(([reqEntry, resEntry, payload]) => {
const requestPending = hasValue(reqEntry.requestPending) ? reqEntry.requestPending : true; const requestPending = hasValue(reqEntry.requestPending) ? reqEntry.requestPending : true;
const responsePending = hasValue(reqEntry.responsePending) ? reqEntry.responsePending : false; const responsePending = hasValue(reqEntry.responsePending) ? reqEntry.responsePending : false;
let isSuccessful: boolean; let isSuccessful: boolean;
@@ -106,7 +110,8 @@ export class RemoteDataBuildService {
error, error,
payload payload
); );
}); })
);
} }
buildList<TNormalized extends NormalizedObject, TDomain>(href$: string | Observable<string>): Observable<RemoteData<PaginatedList<TDomain>>> { buildList<TNormalized extends NormalizedObject, TDomain>(href$: string | Observable<string>): Observable<RemoteData<PaginatedList<TDomain>>> {
@@ -145,9 +150,11 @@ export class RemoteDataBuildService {
}) })
); );
const payload$ = observableCombineLatest(tDomainList$, pageInfo$, (tDomainList, pageInfo) => { const payload$ = observableCombineLatest(tDomainList$, pageInfo$).pipe(
map(([tDomainList, pageInfo]) => {
return new PaginatedList(pageInfo, tDomainList); return new PaginatedList(pageInfo, tDomainList);
}); })
);
return this.toRemoteDataObservable(requestEntry$, responseCache$, payload$); return this.toRemoteDataObservable(requestEntry$, responseCache$, payload$);
} }
@@ -208,9 +215,8 @@ export class RemoteDataBuildService {
return observableOf(new RemoteData(false, false, true, null, [])); return observableOf(new RemoteData(false, false, true, null, []));
} }
return observableCombineLatest( return observableCombineLatest(...input).pipe(
...input, map((arr) => {
(...arr: Array<RemoteData<T>>) => {
const requestPending: boolean = arr const requestPending: boolean = arr
.map((d: RemoteData<T>) => d.isRequestPending) .map((d: RemoteData<T>) => d.isRequestPending)
.every((b: boolean) => b === true); .every((b: boolean) => b === true);
@@ -252,7 +258,7 @@ export class RemoteDataBuildService {
error, error,
payload payload
); );
}) }))
} }
aggregatePaginatedList<T>(input: Observable<RemoteData<T[]>>, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<T>>> { aggregatePaginatedList<T>(input: Observable<RemoteData<T[]>>, pageInfo: PageInfo): Observable<RemoteData<PaginatedList<T>>> {

View File

@@ -1,11 +1,12 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ObjectCacheService } from './object-cache.service'; import { ObjectCacheService } from './object-cache.service';
import { AddToObjectCacheAction, RemoveFromObjectCacheAction } from './object-cache.actions'; import { AddToObjectCacheAction, RemoveFromObjectCacheAction } from './object-cache.actions';
import { CoreState } from '../core.reducers'; import { CoreState } from '../core.reducers';
import { ResourceType } from '../shared/resource-type'; import { ResourceType } from '../shared/resource-type';
import { NormalizedItem } from './models/normalized-item.model'; import { NormalizedItem } from './models/normalized-item.model';
import { first } from 'rxjs/operators';
describe('ObjectCacheService', () => { describe('ObjectCacheService', () => {
let service: ObjectCacheService; let service: ObjectCacheService;
@@ -51,10 +52,10 @@ describe('ObjectCacheService', () => {
describe('getBySelfLink', () => { describe('getBySelfLink', () => {
it('should return an observable of the cached object with the specified self link and type', () => { it('should return an observable of the cached object with the specified self link and type', () => {
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry)); spyOn(store, 'select').and.returnValue(observableOf(cacheEntry));
// due to the implementation of spyOn above, this subscribe will be synchronous // due to the implementation of spyOn above, this subscribe will be synchronous
service.getBySelfLink(selfLink).take(1).subscribe((o) => { service.getBySelfLink(selfLink).pipe(first()).subscribe((o) => {
expect(o.self).toBe(selfLink); expect(o.self).toBe(selfLink);
// this only works if testObj is an instance of TestClass // this only works if testObj is an instance of TestClass
expect(o instanceof NormalizedItem).toBeTruthy(); expect(o instanceof NormalizedItem).toBeTruthy();
@@ -63,7 +64,7 @@ describe('ObjectCacheService', () => {
}); });
it('should not return a cached object that has exceeded its time to live', () => { it('should not return a cached object that has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry)); spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry));
let getObsHasFired = false; let getObsHasFired = false;
const subscription = service.getBySelfLink(selfLink).subscribe((o) => getObsHasFired = true); const subscription = service.getBySelfLink(selfLink).subscribe((o) => getObsHasFired = true);
@@ -76,9 +77,9 @@ describe('ObjectCacheService', () => {
it('should return an observable of the array of cached objects with the specified self link and type', () => { it('should return an observable of the array of cached objects with the specified self link and type', () => {
const item = new NormalizedItem(); const item = new NormalizedItem();
item.self = selfLink; item.self = selfLink;
spyOn(service, 'getBySelfLink').and.returnValue(Observable.of(item)); spyOn(service, 'getBySelfLink').and.returnValue(observableOf(item));
service.getList([selfLink, selfLink]).take(1).subscribe((arr) => { service.getList([selfLink, selfLink]).pipe(first()).subscribe((arr) => {
expect(arr[0].self).toBe(selfLink); expect(arr[0].self).toBe(selfLink);
expect(arr[0] instanceof NormalizedItem).toBeTruthy(); expect(arr[0] instanceof NormalizedItem).toBeTruthy();
}); });
@@ -87,19 +88,19 @@ describe('ObjectCacheService', () => {
describe('has', () => { describe('has', () => {
it('should return true if the object with the supplied self link is cached and still valid', () => { it('should return true if the object with the supplied self link is cached and still valid', () => {
spyOn(store, 'select').and.returnValue(Observable.of(cacheEntry)); spyOn(store, 'select').and.returnValue(observableOf(cacheEntry));
expect(service.hasBySelfLink(selfLink)).toBe(true); expect(service.hasBySelfLink(selfLink)).toBe(true);
}); });
it("should return false if the object with the supplied self link isn't cached", () => { it("should return false if the object with the supplied self link isn't cached", () => {
spyOn(store, 'select').and.returnValue(Observable.of(undefined)); spyOn(store, 'select').and.returnValue(observableOf(undefined));
expect(service.hasBySelfLink(selfLink)).toBe(false); expect(service.hasBySelfLink(selfLink)).toBe(false);
}); });
it('should return false if the object with the supplied self link is cached but has exceeded its time to live', () => { it('should return false if the object with the supplied self link is cached but has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry)); spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry));
expect(service.hasBySelfLink(selfLink)).toBe(false); expect(service.hasBySelfLink(selfLink)).toBe(false);
}); });

View File

@@ -1,10 +1,11 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { ResponseCacheService } from './response-cache.service'; import { ResponseCacheService } from './response-cache.service';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { CoreState } from '../core.reducers'; import { CoreState } from '../core.reducers';
import { RestResponse } from './response-cache.models'; import { RestResponse } from './response-cache.models';
import { ResponseCacheEntry } from './response-cache.reducer'; import { ResponseCacheEntry } from './response-cache.reducer';
import { first } from 'rxjs/operators';
describe('ResponseCacheService', () => { describe('ResponseCacheService', () => {
let service: ResponseCacheService; let service: ResponseCacheService;
@@ -41,11 +42,11 @@ describe('ResponseCacheService', () => {
describe('get', () => { describe('get', () => {
it('should return an observable of the cached request with the specified key', () => { it('should return an observable of the cached request with the specified key', () => {
spyOn(store, 'select').and.callFake((...args: any[]) => { spyOn(store, 'select').and.callFake((...args: any[]) => {
return Observable.of(validCacheEntry(keys[1])); return observableOf(validCacheEntry(keys[1]));
}); });
let testObj: ResponseCacheEntry; let testObj: ResponseCacheEntry;
service.get(keys[1]).first().subscribe((entry) => { service.get(keys[1]).pipe(first()).subscribe((entry) => {
testObj = entry; testObj = entry;
}); });
expect(testObj.key).toEqual(keys[1]); expect(testObj.key).toEqual(keys[1]);
@@ -53,7 +54,7 @@ describe('ResponseCacheService', () => {
it('should not return a cached request that has exceeded its time to live', () => { it('should not return a cached request that has exceeded its time to live', () => {
spyOn(store, 'select').and.callFake((...args: any[]) => { spyOn(store, 'select').and.callFake((...args: any[]) => {
return Observable.of(invalidCacheEntry(keys[1])); return observableOf(invalidCacheEntry(keys[1]));
}); });
let getObsHasFired = false; let getObsHasFired = false;
@@ -65,17 +66,17 @@ describe('ResponseCacheService', () => {
describe('has', () => { describe('has', () => {
it('should return true if the request with the supplied key is cached and still valid', () => { it('should return true if the request with the supplied key is cached and still valid', () => {
spyOn(store, 'select').and.returnValue(Observable.of(validCacheEntry(keys[1]))); spyOn(store, 'select').and.returnValue(observableOf(validCacheEntry(keys[1])));
expect(service.has(keys[1])).toBe(true); expect(service.has(keys[1])).toBe(true);
}); });
it('should return false if the request with the supplied key isn\'t cached', () => { it('should return false if the request with the supplied key isn\'t cached', () => {
spyOn(store, 'select').and.returnValue(Observable.of(undefined)); spyOn(store, 'select').and.returnValue(observableOf(undefined));
expect(service.has(keys[1])).toBe(false); expect(service.has(keys[1])).toBe(false);
}); });
it('should return false if the request with the supplied key is cached but has exceeded its time to live', () => { it('should return false if the request with the supplied key is cached but has exceeded its time to live', () => {
spyOn(store, 'select').and.returnValue(Observable.of(invalidCacheEntry(keys[1]))); spyOn(store, 'select').and.returnValue(observableOf(invalidCacheEntry(keys[1])));
expect(service.has(keys[1])).toBe(false); expect(service.has(keys[1])).toBe(false);
}); });
}); });

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { ResponseCacheService } from '../cache/response-cache.service'; import { ResponseCacheService } from '../cache/response-cache.service';
import { ConfigService } from './config.service'; import { ConfigService } from './config.service';

View File

@@ -1,10 +1,9 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing';
import { GlobalConfig } from '../../../config'; import { GlobalConfig } from '../../../config';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { NormalizedCommunity } from '../cache/models/normalized-community.model';
import { ObjectCacheService } from '../cache/object-cache.service'; import { ObjectCacheService } from '../cache/object-cache.service';
import { ResponseCacheService } from '../cache/response-cache.service'; import { ResponseCacheService } from '../cache/response-cache.service';
import { CoreState } from '../core.reducers'; import { CoreState } from '../core.reducers';

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler } from 'jasmine-marbles'; import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from '../../../../node_modules/rxjs'; import { TestScheduler } from 'rxjs/testing';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { DSpaceObject } from '../shared/dspace-object.model'; import { DSpaceObject } from '../shared/dspace-object.model';
import { HALEndpointService } from '../shared/hal-endpoint.service'; import { HALEndpointService } from '../shared/hal-endpoint.service';

View File

@@ -1,6 +1,6 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { cold, getTestScheduler } from 'jasmine-marbles'; import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing';
import { BrowseService } from '../browse/browse.service'; import { BrowseService } from '../browse/browse.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { ResponseCacheService } from '../cache/response-cache.service'; import { ResponseCacheService } from '../cache/response-cache.service';

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler } from 'jasmine-marbles'; import { cold, getTestScheduler } from 'jasmine-marbles';
import { TestScheduler } from 'rxjs'; import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { ResponseCacheService } from '../cache/response-cache.service'; import { ResponseCacheService } from '../cache/response-cache.service';

View File

@@ -1,17 +1,15 @@
import { ComponentFixture, TestBed, async, fakeAsync, inject, tick } from '@angular/core/testing'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing'; import { RouterTestingModule } from '@angular/router/testing';
import { Location, CommonModule } from '@angular/common'; import { CommonModule, Location } from '@angular/common';
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { By, Meta, MetaDefinition, Title } from '@angular/platform-browser'; import { Meta, MetaDefinition, Title } from '@angular/platform-browser';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { Store, StoreModule } from '@ngrx/store'; import { Store, StoreModule } from '@ngrx/store';
import { Observable, of as observableOf } from 'rxjs';
import { Observable } from 'rxjs';
import { RemoteDataError } from '../data/remote-data-error';
import { UUIDService } from '../shared/uuid.service'; import { UUIDService } from '../shared/uuid.service';
import { MetadataService } from './metadata.service'; import { MetadataService } from './metadata.service';
@@ -182,7 +180,7 @@ describe('MetadataService', () => {
})); }));
const mockRemoteData = (mockItem: Item): Observable<RemoteData<Item>> => { const mockRemoteData = (mockItem: Item): Observable<RemoteData<Item>> => {
return Observable.of(new RemoteData<Item>( return observableOf(new RemoteData<Item>(
false, false,
false, false,
true, true,

View File

@@ -1,4 +1,4 @@
import { async, TestBed } from '@angular/core/testing'; import { TestBed } from '@angular/core/testing';
import { RegistryService } from './registry.service'; import { RegistryService } from './registry.service';
import { CommonModule } from '@angular/common'; import { CommonModule } from '@angular/common';
import { ResponseCacheService } from '../cache/response-cache.service'; import { ResponseCacheService } from '../cache/response-cache.service';
@@ -6,26 +6,24 @@ import { RequestService } from '../data/request.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { HALEndpointService } from '../shared/hal-endpoint.service'; import { HALEndpointService } from '../shared/hal-endpoint.service';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { Observable } from 'rxjs'; import { Observable, of as observableOf, combineLatest as observableCombineLatest } from 'rxjs';
import { ResponseCacheEntry } from '../cache/response-cache.reducer'; import { ResponseCacheEntry } from '../cache/response-cache.reducer';
import { RequestEntry } from '../data/request.reducer'; import { RequestEntry } from '../data/request.reducer';
import { RemoteData } from '../data/remote-data'; import { RemoteData } from '../data/remote-data';
import { PaginatedList } from '../data/paginated-list';
import { PageInfo } from '../shared/page-info.model'; import { PageInfo } from '../shared/page-info.model';
import { GetRequest } from '../data/request.models';
import { URLCombiner } from '../url-combiner/url-combiner';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service'; import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';
import { import {
RegistryBitstreamformatsSuccessResponse, RegistryBitstreamformatsSuccessResponse,
RegistryMetadatafieldsSuccessResponse, RegistryMetadataschemasSuccessResponse, RegistryMetadatafieldsSuccessResponse,
SearchSuccessResponse RegistryMetadataschemasSuccessResponse
} from '../cache/response-cache.models'; } from '../cache/response-cache.models';
import { SearchQueryResponse } from '../../+search-page/search-service/search-query-response.model';
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model'; import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model'; import { RegistryMetadatafieldsResponse } from './registry-metadatafields-response.model';
import { RegistryBitstreamformatsResponse } from './registry-bitstreamformats-response.model'; import { RegistryBitstreamformatsResponse } from './registry-bitstreamformats-response.model';
import { map } from 'rxjs/operators';
@Component({ template: '' }) @Component({ template: '' })
class DummyComponent { class DummyComponent {
@@ -125,18 +123,19 @@ describe('RegistryService', () => {
const endpointWithParams = `${endpoint}?size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`; const endpointWithParams = `${endpoint}?size=${pageInfo.elementsPerPage}&page=${pageInfo.currentPage - 1}`;
const halServiceStub = { const halServiceStub = {
getEndpoint: (link: string) => Observable.of(endpoint) getEndpoint: (link: string) => observableOf(endpoint)
}; };
const rdbStub = { const rdbStub = {
toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => { toRemoteDataObservable: (requestEntryObs: Observable<RequestEntry>, responseCacheObs: Observable<ResponseCacheEntry>, payloadObs: Observable<any>) => {
return Observable.combineLatest(requestEntryObs, return observableCombineLatest(requestEntryObs,
responseCacheObs, payloadObs, (req, res, pay) => { responseCacheObs, payloadObs).pipe(map(([req, res, pay]) => {
return { req, res, pay }; return { req, res, pay };
}); })
);
}, },
aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => { aggregate: (input: Array<Observable<RemoteData<any>>>): Observable<RemoteData<any[]>> => {
return Observable.of(new RemoteData(false, false, true, null, [])); return observableOf(new RemoteData(false, false, true, null, []));
} }
}; };
@@ -156,16 +155,19 @@ describe('RegistryService', () => {
}); });
registryService = TestBed.get(RegistryService); registryService = TestBed.get(RegistryService);
spyOn((registryService as any).halService, 'getEndpoint').and.returnValue(Observable.of(endpoint)); spyOn((registryService as any).halService, 'getEndpoint').and.returnValue(observableOf(endpoint));
}); });
describe('when requesting metadataschemas', () => { describe('when requesting metadataschemas', () => {
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), { metadataschemas: mockSchemasList, page: pageInfo }); const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), {
metadataschemas: mockSchemasList,
page: pageInfo
});
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo); const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
registryService.getMetadataSchemas(pagination).subscribe((value) => { registryService.getMetadataSchemas(pagination).subscribe((value) => {
}); });
@@ -190,12 +192,15 @@ describe('RegistryService', () => {
}); });
describe('when requesting metadataschema by name', () => { describe('when requesting metadataschema by name', () => {
const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), { metadataschemas: mockSchemasList, page: pageInfo }); const queryResponse = Object.assign(new RegistryMetadataschemasResponse(), {
metadataschemas: mockSchemasList,
page: pageInfo
});
const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo); const response = new RegistryMetadataschemasSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
registryService.getMetadataSchemaByName(mockSchemasList[0].prefix).subscribe((value) => { registryService.getMetadataSchemaByName(mockSchemasList[0].prefix).subscribe((value) => {
}); });
@@ -220,12 +225,15 @@ describe('RegistryService', () => {
}); });
describe('when requesting metadatafields', () => { describe('when requesting metadatafields', () => {
const queryResponse = Object.assign(new RegistryMetadatafieldsResponse(), { metadatafields: mockFieldsList, page: pageInfo }); const queryResponse = Object.assign(new RegistryMetadatafieldsResponse(), {
metadatafields: mockFieldsList,
page: pageInfo
});
const response = new RegistryMetadatafieldsSuccessResponse(queryResponse, '200', pageInfo); const response = new RegistryMetadatafieldsSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
registryService.getMetadataFieldsBySchema(mockSchemasList[0], pagination).subscribe((value) => { registryService.getMetadataFieldsBySchema(mockSchemasList[0], pagination).subscribe((value) => {
}); });
@@ -250,12 +258,15 @@ describe('RegistryService', () => {
}); });
describe('when requesting bitstreamformats', () => { describe('when requesting bitstreamformats', () => {
const queryResponse = Object.assign(new RegistryBitstreamformatsResponse(), { bitstreamformats: mockFieldsList, page: pageInfo }); const queryResponse = Object.assign(new RegistryBitstreamformatsResponse(), {
bitstreamformats: mockFieldsList,
page: pageInfo
});
const response = new RegistryBitstreamformatsSuccessResponse(queryResponse, '200', pageInfo); const response = new RegistryBitstreamformatsSuccessResponse(queryResponse, '200', pageInfo);
const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response }); const responseEntry = Object.assign(new ResponseCacheEntry(), { response: response });
beforeEach(() => { beforeEach(() => {
(registryService as any).responseCache.get.and.returnValue(Observable.of(responseEntry)); (registryService as any).responseCache.get.and.returnValue(observableOf(responseEntry));
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
registryService.getBitstreamFormats(pagination).subscribe((value) => { registryService.getBitstreamFormats(pagination).subscribe((value) => {
}); });

View File

@@ -1,4 +1,3 @@
import { combineLatest as observableCombineLatest, Observable } from 'rxjs'; import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { RemoteData } from '../data/remote-data'; import { RemoteData } from '../data/remote-data';
@@ -18,7 +17,9 @@ import { ResponseCacheService } from '../cache/response-cache.service';
import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model'; import { RegistryMetadataschemasResponse } from './registry-metadataschemas-response.model';
import { ResponseCacheEntry } from '../cache/response-cache.reducer'; import { ResponseCacheEntry } from '../cache/response-cache.reducer';
import { import {
MetadataschemaSuccessResponse, RegistryBitstreamformatsSuccessResponse, RegistryMetadatafieldsSuccessResponse, MetadataschemaSuccessResponse,
RegistryBitstreamformatsSuccessResponse,
RegistryMetadatafieldsSuccessResponse,
RegistryMetadataschemasSuccessResponse RegistryMetadataschemasSuccessResponse
} from '../cache/response-cache.models'; } from '../cache/response-cache.models';
import { HALEndpointService } from '../shared/hal-endpoint.service'; import { HALEndpointService } from '../shared/hal-endpoint.service';
@@ -71,9 +72,11 @@ export class RegistryService {
map((response: RegistryMetadataschemasSuccessResponse) => response.pageInfo) map((response: RegistryMetadataschemasSuccessResponse) => response.pageInfo)
); );
const payloadObs = observableCombineLatest(metadataschemasObs, pageInfoObs, (metadataschemas, pageInfo) => { const payloadObs = observableCombineLatest(metadataschemasObs, pageInfoObs).pipe(
map(([metadataschemas, pageInfo]) => {
return new PaginatedList(pageInfo, metadataschemas); return new PaginatedList(pageInfo, metadataschemas);
}); })
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
} }
@@ -133,9 +136,11 @@ export class RegistryService {
map((response: RegistryMetadatafieldsSuccessResponse) => response.pageInfo) map((response: RegistryMetadatafieldsSuccessResponse) => response.pageInfo)
); );
const payloadObs = observableCombineLatest(metadatafieldsObs, pageInfoObs, (metadatafields, pageInfo) => { const payloadObs = observableCombineLatest(metadatafieldsObs, pageInfoObs).pipe(
map(([metadatafields, pageInfo]) => {
return new PaginatedList(pageInfo, metadatafields); return new PaginatedList(pageInfo, metadatafields);
}); })
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
} }
@@ -165,9 +170,11 @@ export class RegistryService {
map((response: RegistryBitstreamformatsSuccessResponse) => response.pageInfo) map((response: RegistryBitstreamformatsSuccessResponse) => response.pageInfo)
); );
const payloadObs = observableCombineLatest(bitstreamformatsObs, pageInfoObs, (bitstreamformats, pageInfo) => { const payloadObs = observableCombineLatest(bitstreamformatsObs, pageInfoObs).pipe(
map(([bitstreamformats, pageInfo]) => {
return new PaginatedList(pageInfo, bitstreamformats); return new PaginatedList(pageInfo, bitstreamformats);
}); })
);
return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs); return this.rdb.toRemoteDataObservable(requestEntryObs, responseCacheObs, payloadObs);
} }

View File

@@ -1,10 +1,10 @@
import { Observable } from 'rxjs'; import { Observable, of as observableOf } from 'rxjs';
import { Item } from './item.model'; import { Item } from './item.model';
import { RemoteData } from '../data/remote-data'; import { RemoteData } from '../data/remote-data';
import { Bitstream } from './bitstream.model'; import { Bitstream } from './bitstream.model';
import { isEmpty } from '../../shared/empty.util'; import { isEmpty } from '../../shared/empty.util';
import { PageInfo } from './page-info.model'; import { first, map } from 'rxjs/operators';
describe('Item', () => { describe('Item', () => {
@@ -56,30 +56,30 @@ describe('Item', () => {
it('should return the bitstreams related to this item with the specified bundle name', () => { it('should return the bitstreams related to this item with the specified bundle name', () => {
const bitObs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(thumbnailBundleName); const bitObs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(thumbnailBundleName);
bitObs.take(1).subscribe((bs) => bitObs.pipe(first()).subscribe((bs) =>
expect(bs.every((b) => b.name === thumbnailBundleName)).toBeTruthy()); expect(bs.every((b) => b.name === thumbnailBundleName)).toBeTruthy());
}); });
it('should return an empty array when no bitstreams with this bundleName exist for this item', () => { it('should return an empty array when no bitstreams with this bundleName exist for this item', () => {
const bs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(nonExistingBundleName); const bs: Observable<Bitstream[]> = item.getBitstreamsByBundleName(nonExistingBundleName);
bs.take(1).subscribe((b) => expect(isEmpty(b)).toBeTruthy()); bs.pipe(first()).subscribe((b) => expect(isEmpty(b)).toBeTruthy());
}); });
describe('get thumbnail', () => { describe('get thumbnail', () => {
beforeEach(() => { beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of([remoteDataThumbnail])); spyOn(item, 'getBitstreamsByBundleName').and.returnValue(observableOf([remoteDataThumbnail]));
}); });
it('should return the thumbnail of this item', () => { it('should return the thumbnail of this item', () => {
const path: string = thumbnailPath; const path: string = thumbnailPath;
const bitstream: Observable<Bitstream> = item.getThumbnail(); const bitstream: Observable<Bitstream> = item.getThumbnail();
bitstream.map((b) => expect(b.content).toBe(path)); bitstream.pipe(map((b) => expect(b.content).toBe(path)));
}); });
}); });
describe('get files', () => { describe('get files', () => {
beforeEach(() => { beforeEach(() => {
spyOn(item, 'getBitstreamsByBundleName').and.returnValue(Observable.of(bitstreams)); spyOn(item, 'getBitstreamsByBundleName').and.returnValue(observableOf(bitstreams));
}); });
it("should return all bitstreams with 'ORIGINAL' as bundleName", () => { it("should return all bitstreams with 'ORIGINAL' as bundleName", () => {
@@ -87,7 +87,7 @@ describe('Item', () => {
const files: Observable<Bitstream[]> = item.getFiles(); const files: Observable<Bitstream[]> = item.getFiles();
let index = 0; let index = 0;
files.map((f) => expect(f.length).toBe(2)); files.pipe(map((f) => expect(f.length).toBe(2)));
files.subscribe( files.subscribe(
(array) => array.forEach( (array) => array.forEach(
(file) => { (file) => {
@@ -103,7 +103,7 @@ describe('Item', () => {
}); });
function createRemoteDataObject(object: any) { function createRemoteDataObject(object: any) {
return Observable.of(new RemoteData( return observableOf(new RemoteData(
false, false,
false, false,
true, true,

View File

@@ -1,5 +1,5 @@
import { cold, getTestScheduler, hot } from 'jasmine-marbles'; import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { TestScheduler } from '../../../../node_modules/rxjs'; import { TestScheduler } from 'rxjs/testing';
import { getMockRequestService } from '../../shared/mocks/mock-request.service'; import { getMockRequestService } from '../../shared/mocks/mock-request.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service'; import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';
import { ResponseCacheEntry } from '../cache/response-cache.reducer'; import { ResponseCacheEntry } from '../cache/response-cache.reducer';

View File

@@ -1,10 +1,10 @@
import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { Store, StoreModule } from '@ngrx/store'; import { Store, StoreModule } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbCollapseModule } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { HeaderComponent } from './header.component'; import { HeaderComponent } from './header.component';
import { HeaderState } from './header.reducer'; import { HeaderState } from './header.reducer';
@@ -50,7 +50,7 @@ describe('HeaderComponent', () => {
comp = fixture.componentInstance; comp = fixture.componentInstance;
store = fixture.debugElement.injector.get(Store); store = fixture.debugElement.injector.get(Store) as Store<HeaderState>;
spyOn(store, 'dispatch'); spyOn(store, 'dispatch');
}); });
@@ -72,7 +72,7 @@ describe('HeaderComponent', () => {
beforeEach(() => { beforeEach(() => {
menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement; menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement;
spyOn(store, 'select').and.returnValue(Observable.of({ navCollapsed: true })); spyOn(store, 'select').and.returnValue(observableOf({ navCollapsed: true }));
fixture.detectChanges(); fixture.detectChanges();
}); });
@@ -87,7 +87,7 @@ describe('HeaderComponent', () => {
beforeEach(() => { beforeEach(() => {
menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement; menu = fixture.debugElement.query(By.css('#collapsingNav')).nativeElement;
spyOn(store, 'select').and.returnValue(Observable.of(false)); spyOn(store, 'select').and.returnValue(observableOf(false));
fixture.detectChanges(); fixture.detectChanges();
}); });

View File

@@ -149,7 +149,7 @@ describe('DsDynamicFormControlComponent test suite', () => {
expect(component.change).toBeDefined(); expect(component.change).toBeDefined();
expect(component.focus).toBeDefined(); expect(component.focus).toBeDefined();
expect(component.onValueChange).toBeDefined(); expect(component.onChange).toBeDefined();
expect(component.onBlur).toBeDefined(); expect(component.onBlur).toBeDefined();
expect(component.onFocus).toBeDefined(); expect(component.onFocus).toBeDefined();
@@ -185,11 +185,11 @@ describe('DsDynamicFormControlComponent test suite', () => {
it('should listen to native change event', () => { it('should listen to native change event', () => {
spyOn(component, 'onValueChange'); spyOn(component, 'onChange');
testElement.triggerEventHandler('change', null); testElement.triggerEventHandler('change', null);
expect(component.onValueChange).toHaveBeenCalled(); expect(component.onChange).toHaveBeenCalled();
}); });
it('should update model value when control value changes', () => { it('should update model value when control value changes', () => {

View File

@@ -1,6 +1,5 @@
import { import {
Component, Component, ComponentFactoryResolver,
ComponentFactoryResolver,
ContentChildren, ContentChildren,
EventEmitter, EventEmitter,
Input, Input,
@@ -21,7 +20,7 @@ import {
DYNAMIC_FORM_CONTROL_TYPE_SELECT, DYNAMIC_FORM_CONTROL_TYPE_SELECT,
DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA, DYNAMIC_FORM_CONTROL_TYPE_TEXTAREA,
DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER, DYNAMIC_FORM_CONTROL_TYPE_TIMEPICKER,
DynamicDatePickerModel, DynamicFormControl, DynamicDatePickerModel, DynamicFormControl, DynamicFormControlComponent,
DynamicFormControlContainerComponent, DynamicFormControlContainerComponent,
DynamicFormControlEvent, DynamicFormControlEvent,
DynamicFormControlModel, DynamicFormControlModel,
@@ -38,6 +37,7 @@ import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/dat
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model'; import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model';
import { DynamicListCheckboxGroupModel } from './models/list/dynamic-list-checkbox-group.model'; import { DynamicListCheckboxGroupModel } from './models/list/dynamic-list-checkbox-group.model';
import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-group.model'; import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-group.model';
import { isNotEmpty } from '../../../empty.util';
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP_NAME } from './models/lookup/dynamic-lookup-name.model'; import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP_NAME } from './models/lookup/dynamic-lookup-name.model';
export const enum NGBootstrapFormControlType { export const enum NGBootstrapFormControlType {
@@ -89,9 +89,10 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
@Output('dfFocus') focus: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>(); @Output('dfFocus') focus: EventEmitter<DynamicFormControlEvent> = new EventEmitter<DynamicFormControlEvent>();
/* tslint:enable:no-output-rename */ /* tslint:enable:no-output-rename */
componentType: Type<DynamicFormControl> | null;
type: NGBootstrapFormControlType | null; type: NGBootstrapFormControlType | null;
readonly componentType: Type<DynamicFormControl> | null;
static getFormControlType(model: DynamicFormControlModel): NGBootstrapFormControlType | null { static getFormControlType(model: DynamicFormControlModel): NGBootstrapFormControlType | null {
switch (model.type) { switch (model.type) {
@@ -162,7 +163,7 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if (changes) { if (changes) {
super.ngOnChanges(changes); // super.ngOnChanges(changes);
} }
if (changes.model) { if (changes.model) {
@@ -170,4 +171,9 @@ export class DsDynamicFormControlComponent extends DynamicFormControlContainerCo
} }
} }
onChangeLanguage(event) {
if (isNotEmpty((this.model as any).value)) {
this.onChange(event);
}
}
} }

View File

@@ -6,13 +6,15 @@ import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angul
import { DynamicFormValidationService } from '@ng-dynamic-forms/core'; import { DynamicFormValidationService } from '@ng-dynamic-forms/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { DsDynamicGroupComponent } from './dynamic-group.components'; import { DsDynamicGroupComponent } from './dynamic-group.components';
import { DynamicGroupModel, DynamicGroupModelConfig } from './dynamic-group.model'; import { DynamicGroupModel, DynamicGroupModelConfig } from './dynamic-group.model';
import { FormRowModel, SubmissionFormsModel } from '../../../../../../core/shared/config/config-submission-forms.model'; import {
FormRowModel,
SubmissionFormsModel
} from '../../../../../../core/shared/config/config-submission-forms.model';
import { FormFieldModel } from '../../../models/form-field.model'; import { FormFieldModel } from '../../../models/form-field.model';
import { FormBuilderService } from '../../../form-builder.service'; import { FormBuilderService } from '../../../form-builder.service';
import { FormService } from '../../../../form.service'; import { FormService } from '../../../../form.service';
@@ -97,7 +99,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const store: Store<AppState> = jasmine.createSpyObj('store', { const store: Store<AppState> = jasmine.createSpyObj('store', {
dispatch: {}, dispatch: {},
select: Observable.of(true) select: observableOf(true)
}); });
// async beforeEach // async beforeEach
@@ -182,7 +184,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly); const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
const chips = new Chips([], 'value', 'dc.contributor.author'); const chips = new Chips([], 'value', 'dc.contributor.author');
expect(groupComp.formCollapsed).toEqual(Observable.of(false)); expect(groupComp.formCollapsed).toEqual(observableOf(false));
expect(groupComp.formModel.length).toEqual(formModel.length); expect(groupComp.formModel.length).toEqual(formModel.length);
expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems()); expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems());
})); }));
@@ -203,7 +205,7 @@ describe('DsDynamicGroupComponent test suite', () => {
btnEl.click(); btnEl.click();
expect(groupComp.chips.getChipsItems()).toEqual(modelValue); expect(groupComp.chips.getChipsItems()).toEqual(modelValue);
expect(groupComp.formCollapsed).toEqual(Observable.of(true)); expect(groupComp.formCollapsed).toEqual(observableOf(true));
}); });
it('should clear form inputs', () => { it('should clear form inputs', () => {
@@ -220,7 +222,7 @@ describe('DsDynamicGroupComponent test suite', () => {
expect(control1.value).toBeNull(); expect(control1.value).toBeNull();
expect(control2.value).toBeNull(); expect(control2.value).toBeNull();
expect(groupComp.formCollapsed).toEqual(Observable.of(false)); expect(groupComp.formCollapsed).toEqual(observableOf(false));
}); });
}); });
@@ -252,7 +254,7 @@ describe('DsDynamicGroupComponent test suite', () => {
const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly); const formModel = service.modelFromConfiguration(formConfig, groupComp.model.scopeUUID, {}, groupComp.model.submissionScope, groupComp.model.readOnly);
const chips = new Chips(modelValue, 'value', 'dc.contributor.author'); const chips = new Chips(modelValue, 'value', 'dc.contributor.author');
expect(groupComp.formCollapsed).toEqual(Observable.of(true)); expect(groupComp.formCollapsed).toEqual(observableOf(true));
expect(groupComp.formModel.length).toEqual(formModel.length); expect(groupComp.formModel.length).toEqual(formModel.length);
expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems()); expect(groupComp.chips.getChipsItems()).toEqual(chips.getChipsItems());
})); }));
@@ -280,7 +282,7 @@ describe('DsDynamicGroupComponent test suite', () => {
groupFixture.detectChanges(); groupFixture.detectChanges();
expect(groupComp.chips.getChipsItems()).toEqual(modelValue); expect(groupComp.chips.getChipsItems()).toEqual(modelValue);
expect(groupComp.formCollapsed).toEqual(Observable.of(true)); expect(groupComp.formCollapsed).toEqual(observableOf(true));
})); }));
it('should delete existing chips item', () => { it('should delete existing chips item', () => {
@@ -292,7 +294,7 @@ describe('DsDynamicGroupComponent test suite', () => {
btnEl.click(); btnEl.click();
expect(groupComp.chips.getChipsItems()).toEqual([]); expect(groupComp.chips.getChipsItems()).toEqual([]);
expect(groupComp.formCollapsed).toEqual(Observable.of(false)); expect(groupComp.formCollapsed).toEqual(observableOf(false));
}); });
}); });
}); });

View File

@@ -73,7 +73,7 @@ export class DsDynamicGroupComponent implements OnDestroy, OnInit {
} else { } else {
this.expandForm(); this.expandForm();
} }
// this.formCollapsed = (isNotEmpty(value) && !(value.length === 1 && hasOnlyEmptyProperties(value[0]))) ? Observable.of(true) : Observable.of(false); // this.formCollapsed = (isNotEmpty(value) && !(value.length === 1 && hasOnlyEmptyProperties(value[0]))) ? observableOf(true) : observableOf(false);
}); });
this.formId = this.formService.getUniqueId(this.model.id); this.formId = this.formService.getUniqueId(this.model.id);

View File

@@ -2,12 +2,11 @@
import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { async, ComponentFixture, fakeAsync, flush, inject, TestBed, } from '@angular/core/testing'; import { async, ComponentFixture, fakeAsync, flush, inject, TestBed, } from '@angular/core/testing';
import { of as observableOf } from 'rxjs';
import { DynamicFormsCoreModule } from '@ng-dynamic-forms/core'; import { DynamicFormsCoreModule } from '@ng-dynamic-forms/core';
import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstrap'; import { DynamicFormsNGBootstrapUIModule } from '@ng-dynamic-forms/ui-ng-bootstrap';
import { NgbModule, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap'; import { NgbModule, NgbTypeaheadSelectItemEvent } from '@ng-bootstrap/ng-bootstrap';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of'
import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model';
import { AuthorityService } from '../../../../../../core/integration/authority.service'; import { AuthorityService } from '../../../../../../core/integration/authority.service';
@@ -140,7 +139,7 @@ describe('DsDynamicTagComponent test suite', () => {
it('should search when 3+ characters typed', fakeAsync(() => { it('should search when 3+ characters typed', fakeAsync(() => {
spyOn((tagComp as any).authorityService, 'getEntriesByName').and.callThrough(); spyOn((tagComp as any).authorityService, 'getEntriesByName').and.callThrough();
tagComp.search(Observable.of('test')).subscribe(() => { tagComp.search(observableOf('test')).subscribe(() => {
expect((tagComp as any).authorityService.getEntriesByName).toHaveBeenCalled(); expect((tagComp as any).authorityService.getEntriesByName).toHaveBeenCalled();
}); });
})); }));

View File

@@ -3,8 +3,7 @@ import { ChangeDetectorRef, Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/c
import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormControl, FormGroup, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { async, ComponentFixture, fakeAsync, inject, TestBed, } from '@angular/core/testing'; import { async, ComponentFixture, fakeAsync, inject, TestBed, } from '@angular/core/testing';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { of as observableOf } from 'rxjs';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model'; import { AuthorityOptions } from '../../../../../../core/integration/models/authority-options.model';
@@ -123,7 +122,7 @@ describe('DsDynamicTypeaheadComponent test suite', () => {
it('should search when 3+ characters typed', fakeAsync(() => { it('should search when 3+ characters typed', fakeAsync(() => {
spyOn((typeaheadComp as any).authorityService, 'getEntriesByName').and.callThrough(); spyOn((typeaheadComp as any).authorityService, 'getEntriesByName').and.callThrough();
typeaheadComp.search(Observable.of('test')).subscribe(() => { typeaheadComp.search(observableOf('test')).subscribe(() => {
expect((typeaheadComp as any).authorityService.getEntriesByName).toHaveBeenCalled(); expect((typeaheadComp as any).authorityService.getEntriesByName).toHaveBeenCalled();
}); });

View File

@@ -16,7 +16,7 @@ import {
DynamicFileUploadModel, DynamicFormArrayGroupModel, DynamicFileUploadModel, DynamicFormArrayGroupModel,
DynamicFormArrayModel, DynamicFormArrayModel,
DynamicFormControlModel, DynamicFormControlModel,
DynamicFormControlValue, // DynamicFormControlValue,
DynamicFormGroupModel, DynamicFormGroupModel,
DynamicFormService, DynamicFormService,
DynamicFormValidationService, DynamicFormValidationService,
@@ -761,8 +761,8 @@ describe('FormBuilderService test suite', () => {
(formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1'); (formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1');
(formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2'); (formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 1'); (model.get(index).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 2'); (model.get(index + step).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 2');
service.moveFormArrayGroup(index, step, formArray, model); service.moveFormArrayGroup(index, step, formArray, model);
@@ -771,8 +771,8 @@ describe('FormBuilderService test suite', () => {
expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2'); expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2');
expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1'); expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 2'); expect((model.get(index).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 1'); expect((model.get(index + step).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 1');
}); });
it('should move down a form array group', () => { it('should move down a form array group', () => {
@@ -785,8 +785,8 @@ describe('FormBuilderService test suite', () => {
(formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1'); (formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 1');
(formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2'); (formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.setValue('next test value 2');
(model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 1'); (model.get(index).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 1');
(model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).valueUpdates.next('next test value 2'); (model.get(index + step).get(0) as DynamicFormValueControlModel<any>).valueUpdates.next('next test value 2');
service.moveFormArrayGroup(index, step, formArray, model); service.moveFormArrayGroup(index, step, formArray, model);
@@ -795,8 +795,8 @@ describe('FormBuilderService test suite', () => {
expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2'); expect((formArray.at(index) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 2');
expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1'); expect((formArray.at(index + step) as FormGroup).controls.testFormArrayGroupInput.value).toEqual('next test value 1');
expect((model.get(index).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 2'); expect((model.get(index).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 2');
expect((model.get(index + step).get(0) as DynamicFormValueControlModel<DynamicFormControlValue>).value).toEqual('next test value 1'); expect((model.get(index + step).get(0) as DynamicFormValueControlModel<any>).value).toEqual('next test value 1');
}); });
it('should throw when form array group is to be moved out of bounds', () => { it('should throw when form array group is to be moved out of bounds', () => {

View File

@@ -1,8 +1,7 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { cold, hot } from 'jasmine-marbles'; import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { AppState } from '../app.reducer'; import { AppState } from '../app.reducer';
import { HostWindowState } from './host-window.reducer';
import { GridBreakpoint, HostWindowService, WidthCategory } from './host-window.service'; import { GridBreakpoint, HostWindowService, WidthCategory } from './host-window.service';
@@ -13,7 +12,7 @@ describe('HostWindowService', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
const _initialState = { hostWindow: { width: 1600, height: 770 } }; const _initialState = { hostWindow: { width: 1600, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined); store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store); service = new HostWindowService(store);
}); });
@@ -49,7 +48,7 @@ describe('HostWindowService', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
const _initialState = { hostWindow: { width: 1100, height: 770 } }; const _initialState = { hostWindow: { width: 1100, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined); store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store); service = new HostWindowService(store);
}); });
@@ -85,7 +84,7 @@ describe('HostWindowService', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
const _initialState = { hostWindow: { width: 800, height: 770 } }; const _initialState = { hostWindow: { width: 800, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined); store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store); service = new HostWindowService(store);
}); });
@@ -121,7 +120,7 @@ describe('HostWindowService', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
const _initialState = { hostWindow: { width: 600, height: 770 } }; const _initialState = { hostWindow: { width: 600, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined); store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store); service = new HostWindowService(store);
}); });
@@ -157,7 +156,7 @@ describe('HostWindowService', () => {
describe('', () => { describe('', () => {
beforeEach(() => { beforeEach(() => {
const _initialState = { hostWindow: { width: 400, height: 770 } }; const _initialState = { hostWindow: { width: 400, height: 770 } };
store = new Store<AppState>(Observable.of(_initialState), undefined, undefined); store = new Store<AppState>(observableOf(_initialState), undefined, undefined);
service = new HostWindowService(store); service = new HostWindowService(store);
}); });

View File

@@ -99,8 +99,10 @@ export class HostWindowService {
isXsOrSm(): Observable<boolean> { isXsOrSm(): Observable<boolean> {
return observableCombineLatest( return observableCombineLatest(
this.isXs(), this.isXs(),
this.isSm(), this.isSm()
((isXs, isSm) => isXs || isSm) ).pipe(
).pipe(distinctUntilChanged()); map(([isXs, isSm]) => isXs || isSm),
distinctUntilChanged()
);
} }
} }

View File

@@ -4,9 +4,13 @@ import { NotificationsBoardComponent } from './notifications-board/notifications
import { NotificationComponent } from './notification/notification.component'; import { NotificationComponent } from './notification/notification.component';
import { Store, StoreModule } from '@ngrx/store'; import { Store, StoreModule } from '@ngrx/store';
import { notificationsReducer } from './notifications.reducers'; import { notificationsReducer } from './notifications.reducers';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import 'rxjs/add/observable/of'; import 'rxjs/add/observable/of';
import { NewNotificationAction, RemoveAllNotificationsAction, RemoveNotificationAction } from './notifications.actions'; import {
NewNotificationAction,
RemoveAllNotificationsAction,
RemoveNotificationAction
} from './notifications.actions';
import { Notification } from './models/notification.model'; import { Notification } from './models/notification.model';
import { NotificationType } from './models/notification-type'; import { NotificationType } from './models/notification-type';
import { GlobalConfig } from '../../../config/global-config.interface'; import { GlobalConfig } from '../../../config/global-config.interface';
@@ -14,7 +18,7 @@ import { GlobalConfig } from '../../../config/global-config.interface';
describe('NotificationsService test', () => { describe('NotificationsService test', () => {
const store: Store<Notification> = jasmine.createSpyObj('store', { const store: Store<Notification> = jasmine.createSpyObj('store', {
dispatch: {}, dispatch: {},
select: Observable.of(true) select: observableOf(true)
}); });
let service; let service;
let envConfig: GlobalConfig; let envConfig: GlobalConfig;
@@ -43,25 +47,25 @@ describe('NotificationsService test', () => {
}); });
it('Success method should dispatch NewNotificationAction with proper parameter', () => { it('Success method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.success('Title', Observable.of('Content')); const notification = service.success('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Success); expect(notification.type).toBe(NotificationType.Success);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification)); expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
}); });
it('Warning method should dispatch NewNotificationAction with proper parameter', () => { it('Warning method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.warning('Title', Observable.of('Content')); const notification = service.warning('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Warning); expect(notification.type).toBe(NotificationType.Warning);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification)); expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
}); });
it('Info method should dispatch NewNotificationAction with proper parameter', () => { it('Info method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.info('Title', Observable.of('Content')); const notification = service.info('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Info); expect(notification.type).toBe(NotificationType.Info);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification)); expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
}); });
it('Error method should dispatch NewNotificationAction with proper parameter', () => { it('Error method should dispatch NewNotificationAction with proper parameter', () => {
const notification = service.error('Title', Observable.of('Content')); const notification = service.error('Title', observableOf('Content'));
expect(notification.type).toBe(NotificationType.Error); expect(notification.type).toBe(NotificationType.Error);
expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification)); expect(store.dispatch).toHaveBeenCalledWith(new NewNotificationAction(notification));
}); });

View File

@@ -3,7 +3,7 @@ import { By } from '@angular/platform-browser';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { RouterStub } from '../testing/router-stub'; import { RouterStub } from '../testing/router-stub';
import { ViewMode } from '../../core/shared/view-mode.model'; import { ViewMode } from '../../core/shared/view-mode.model';
@@ -14,7 +14,7 @@ describe('ObjectCollectionComponent', () => {
const queryParam = 'test query'; const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
const activatedRouteStub = { const activatedRouteStub = {
queryParams: Observable.of({ queryParams: observableOf({
query: queryParam, query: queryParam,
scope: scopeParam scope: scopeParam
}) })

View File

@@ -4,13 +4,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../utils/truncate.pipe'; import { TruncatePipe } from '../../utils/truncate.pipe';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
let itemGridElementComponent: ItemGridElementComponent; let itemGridElementComponent: ItemGridElementComponent;
let fixture: ComponentFixture<ItemGridElementComponent>; let fixture: ComponentFixture<ItemGridElementComponent>;
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), { const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.contributor.author', key: 'dc.contributor.author',
@@ -24,7 +24,7 @@ const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
}] }]
}); });
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), { const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.title', key: 'dc.title',

View File

@@ -1,4 +1,3 @@
import { combineLatest as observableCombineLatest, BehaviorSubject, Observable } from 'rxjs'; import { combineLatest as observableCombineLatest, BehaviorSubject, Observable } from 'rxjs';
import { startWith, distinctUntilChanged, map } from 'rxjs/operators'; import { startWith, distinctUntilChanged, map } from 'rxjs/operators';
@@ -38,9 +37,11 @@ export class ObjectGridComponent implements OnInit {
@Input() hideGear = false; @Input() hideGear = false;
@Input() hidePagerWhenSinglePage = true; @Input() hidePagerWhenSinglePage = true;
private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>; private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>;
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) { @Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
this._objects$.next(objects); this._objects$.next(objects);
} }
get objects() { get objects() {
return this._objects$.getValue(); return this._objects$.getValue();
} }
@@ -111,8 +112,7 @@ export class ObjectGridComponent implements OnInit {
this.columns$ = observableCombineLatest( this.columns$ = observableCombineLatest(
nbColumns$, nbColumns$,
this._objects$, this._objects$).pipe(map(([nbColumns, objects]) => {
(nbColumns, objects) => {
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) { if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
const page = objects.payload.page; const page = objects.payload.page;
@@ -130,7 +130,7 @@ export class ObjectGridComponent implements OnInit {
} else { } else {
return []; return [];
} }
}); }));
} }
onPageChange(event) { onPageChange(event) {

View File

@@ -1,6 +1,6 @@
import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component'; import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let collectionSearchResultGridElementComponent: CollectionSearchResultGridElemen
let fixture: ComponentFixture<CollectionSearchResultGridElementComponent>; let fixture: ComponentFixture<CollectionSearchResultGridElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult(); const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult();

View File

@@ -1,6 +1,6 @@
import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component'; import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let communitySearchResultGridElementComponent: CommunitySearchResultGridElementC
let fixture: ComponentFixture<CommunitySearchResultGridElementComponent>; let fixture: ComponentFixture<CommunitySearchResultGridElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult(); const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult();

View File

@@ -1,7 +1,7 @@
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component'; import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
@@ -13,13 +13,13 @@ let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>; let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult(); const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithAuthorAndDate.hitHighlights = []; mockItemWithAuthorAndDate.hitHighlights = [];
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), { mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.contributor.author', key: 'dc.contributor.author',
@@ -36,7 +36,7 @@ mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult(); const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithoutAuthorAndDate.hitHighlights = []; mockItemWithoutAuthorAndDate.hitHighlights = [];
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), { mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.title', key: 'dc.title',

View File

@@ -1,6 +1,6 @@
import { WrapperGridElementComponent } from './wrapper-grid-element.component'; import { WrapperGridElementComponent } from './wrapper-grid-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { RouterStub } from '../../testing/router-stub'; import { RouterStub } from '../../testing/router-stub';
import { NO_ERRORS_SCHEMA } from '@angular/core'; import { NO_ERRORS_SCHEMA } from '@angular/core';
@@ -11,7 +11,7 @@ let fixture: ComponentFixture<WrapperGridElementComponent>;
const queryParam = 'test query'; const queryParam = 'test query';
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f'; const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
const activatedRouteStub = { const activatedRouteStub = {
queryParams: Observable.of({ queryParams: observableOf({
query: queryParam, query: queryParam,
scope: scopeParam scope: scopeParam
}) })

View File

@@ -4,13 +4,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../utils/truncate.pipe'; import { TruncatePipe } from '../../utils/truncate.pipe';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
let itemListElementComponent: ItemListElementComponent; let itemListElementComponent: ItemListElementComponent;
let fixture: ComponentFixture<ItemListElementComponent>; let fixture: ComponentFixture<ItemListElementComponent>;
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), { const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.contributor.author', key: 'dc.contributor.author',
@@ -24,7 +24,7 @@ const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
}] }]
}); });
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), { const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.title', key: 'dc.title',

View File

@@ -1,6 +1,6 @@
import { CollectionSearchResultListElementComponent } from './collection-search-result-list-element.component'; import { CollectionSearchResultListElementComponent } from './collection-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let collectionSearchResultListElementComponent: CollectionSearchResultListElemen
let fixture: ComponentFixture<CollectionSearchResultListElementComponent>; let fixture: ComponentFixture<CollectionSearchResultListElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult(); const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult();

View File

@@ -1,6 +1,6 @@
import { CommunitySearchResultListElementComponent } from './community-search-result-list-element.component'; import { CommunitySearchResultListElementComponent } from './community-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
@@ -12,7 +12,7 @@ let communitySearchResultListElementComponent: CommunitySearchResultListElementC
let fixture: ComponentFixture<CommunitySearchResultListElementComponent>; let fixture: ComponentFixture<CommunitySearchResultListElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult(); const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult();

View File

@@ -1,7 +1,7 @@
import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component'; import { ItemSearchResultListElementComponent } from './item-search-result-list-element.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
import { By } from '@angular/platform-browser'; import { By } from '@angular/platform-browser';
import { TruncatePipe } from '../../../utils/truncate.pipe'; import { TruncatePipe } from '../../../utils/truncate.pipe';
import { Item } from '../../../../core/shared/item.model'; import { Item } from '../../../../core/shared/item.model';
@@ -13,13 +13,13 @@ let itemSearchResultListElementComponent: ItemSearchResultListElementComponent;
let fixture: ComponentFixture<ItemSearchResultListElementComponent>; let fixture: ComponentFixture<ItemSearchResultListElementComponent>;
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: number) => Observable.of(true), isCollapsed: (id: number) => observableOf(true),
}; };
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult(); const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithAuthorAndDate.hitHighlights = []; mockItemWithAuthorAndDate.hitHighlights = [];
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), { mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.contributor.author', key: 'dc.contributor.author',
@@ -36,7 +36,7 @@ mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult(); const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
mockItemWithoutAuthorAndDate.hitHighlights = []; mockItemWithoutAuthorAndDate.hitHighlights = [];
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), { mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
bitstreams: Observable.of({}), bitstreams: observableOf({}),
metadata: [ metadata: [
{ {
key: 'dc.title', key: 'dc.title',

View File

@@ -18,7 +18,6 @@ import { PaginationComponentOptions } from './pagination-component-options.model
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model'; import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { hasValue, isNotEmpty } from '../empty.util'; import { hasValue, isNotEmpty } from '../empty.util';
import { PageInfo } from '../../core/shared/page-info.model'; import { PageInfo } from '../../core/shared/page-info.model';
import { isNumeric } from 'tslint';
/** /**
* The default pagination controls component. * The default pagination controls component.
@@ -419,7 +418,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/ */
private validatePage(page: any): number { private validatePage(page: any): number {
let result = this.currentPage; let result = this.currentPage;
if (isNumeric(page)) { if (!isNaN(page)) {
result = +page; result = +page;
} }
return result; return result;

View File

@@ -1,7 +1,7 @@
import { RouteService } from './route.service'; import { RouteService } from './route.service';
import { async, TestBed } from '@angular/core/testing'; import { async, TestBed } from '@angular/core/testing';
import { ActivatedRoute, convertToParamMap, Params } from '@angular/router'; import { ActivatedRoute, convertToParamMap, Params } from '@angular/router';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
describe('RouteService', () => { describe('RouteService', () => {
let service: RouteService; let service: RouteService;
@@ -24,8 +24,8 @@ describe('RouteService', () => {
{ {
provide: ActivatedRoute, provide: ActivatedRoute,
useValue: { useValue: {
queryParams: Observable.of(paramObject), queryParams: observableOf(paramObject),
queryParamMap: Observable.of(convertToParamMap(paramObject)) queryParamMap: observableOf(convertToParamMap(paramObject))
}, },
}, },
] ]

View File

@@ -1,4 +1,3 @@
import { distinctUntilChanged, map } from 'rxjs/operators'; import { distinctUntilChanged, map } from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
@@ -15,29 +14,41 @@ export class RouteService {
} }
getQueryParameterValues(paramName: string): Observable<string[]> { getQueryParameterValues(paramName: string): Observable<string[]> {
return this.route.queryParamMap.pipe(map((map) => [...map.getAll(paramName)]),distinctUntilChanged(),); return this.route.queryParamMap.pipe(
map((params) => [...params.getAll(paramName)]),
distinctUntilChanged()
);
} }
getQueryParameterValue(paramName: string): Observable<string> { getQueryParameterValue(paramName: string): Observable<string> {
return this.route.queryParamMap.pipe(map((map) => map.get(paramName)),distinctUntilChanged(),); return this.route.queryParamMap.pipe(
map((params) => params.get(paramName)),
distinctUntilChanged()
);
} }
hasQueryParam(paramName: string): Observable<boolean> { hasQueryParam(paramName: string): Observable<boolean> {
return this.route.queryParamMap.pipe(map((map) => map.has(paramName)),distinctUntilChanged(),); return this.route.queryParamMap.pipe(
map((params) => params.has(paramName)),
distinctUntilChanged()
);
} }
hasQueryParamWithValue(paramName: string, paramValue: string): Observable<boolean> { hasQueryParamWithValue(paramName: string, paramValue: string): Observable<boolean> {
return this.route.queryParamMap.pipe(map((map) => map.getAll(paramName).indexOf(paramValue) > -1),distinctUntilChanged(),); return this.route.queryParamMap.pipe(
map((params) => params.getAll(paramName).indexOf(paramValue) > -1),
distinctUntilChanged()
);
} }
getQueryParamsWithPrefix(prefix: string): Observable<Params> { getQueryParamsWithPrefix(prefix: string): Observable<Params> {
return this.route.queryParamMap.pipe( return this.route.queryParamMap.pipe(
map((map) => { map((qparams) => {
const params = {}; const params = {};
map.keys qparams.keys
.filter((key) => key.startsWith(prefix)) .filter((key) => key.startsWith(prefix))
.forEach((key) => { .forEach((key) => {
params[key] = [...map.getAll(key)]; params[key] = [...qparams.getAll(key)];
}); });
return params; return params;
}), }),

View File

@@ -1,5 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { TruncatablePartComponent } from './truncatable-part.component'; import { TruncatablePartComponent } from './truncatable-part.component';
import { TruncatableService } from '../truncatable.service'; import { TruncatableService } from '../truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -15,9 +15,9 @@ describe('TruncatablePartComponent', () => {
const truncatableServiceStub: any = { const truncatableServiceStub: any = {
isCollapsed: (id: string) => { isCollapsed: (id: string) => {
if (id === id1) { if (id === id1) {
return Observable.of(true) return observableOf(true)
} else { } else {
return Observable.of(false); return observableOf(false);
} }
} }
}; };

View File

@@ -1,5 +1,5 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs'; import { of as observableOf } from 'rxjs';
import { TruncatableComponent } from './truncatable.component'; import { TruncatableComponent } from './truncatable.component';
import { TruncatableService } from './truncatable.service'; import { TruncatableService } from './truncatable.service';
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
@@ -14,9 +14,9 @@ describe('TruncatableComponent', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
isCollapsed: (id: string) => { isCollapsed: (id: string) => {
if (id === '1') { if (id === '1') {
return Observable.of(true) return observableOf(true)
} else { } else {
return Observable.of(false); return observableOf(false);
} }
}, },
expand: (id: string) => { expand: (id: string) => {

View File

@@ -1,9 +1,9 @@
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { async, TestBed } from '@angular/core/testing'; import { async, TestBed } from '@angular/core/testing';
import { Observable } from 'rxjs';
import { TruncatableService } from './truncatable.service'; import { TruncatableService } from './truncatable.service';
import { TruncatableCollapseAction, TruncatableExpandAction } from './truncatable.actions'; import { TruncatableCollapseAction, TruncatableExpandAction } from './truncatable.actions';
import { TruncatablesState } from './truncatable.reducer'; import { TruncatablesState } from './truncatable.reducer';
import { of as observableOf } from 'rxjs';
describe('TruncatableService', () => { describe('TruncatableService', () => {
const id1 = '123'; const id1 = '123';
@@ -13,7 +13,7 @@ describe('TruncatableService', () => {
/* tslint:disable:no-empty */ /* tslint:disable:no-empty */
dispatch: {}, dispatch: {},
/* tslint:enable:no-empty */ /* tslint:enable:no-empty */
select: Observable.of(true) select: observableOf(true)
}); });
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({

View File

@@ -8,23 +8,23 @@ const {
getAotPlugin getAotPlugin
} = require('./webpack/webpack.aot'); } = require('./webpack/webpack.aot');
module.exports = function(options) { module.exports = function(env, options) {
options = options || {}; env = env || {};
if (options.aot) { if (env.aot) {
console.log(`Running build for ${options.client ? 'client' : 'server'} with AoT Compilation`) console.log(`Running build for ${env.client ? 'client' : 'server'} with AoT Compilation`)
} }
let serverPartial = getServerWebpackPartial(options.aot); let serverPartial = getServerWebpackPartial(env.aot);
let serverConfig = webpackMerge({}, commonPartial, serverPartial, { let serverConfig = webpackMerge({}, commonPartial, serverPartial, {
plugins: [ plugins: [
getAotPlugin('server', !!options.aot) getAotPlugin('server', !!env.aot)
] ]
}); });
let clientConfig = webpackMerge({}, commonPartial, clientPartial, { let clientConfig = webpackMerge({}, commonPartial, clientPartial, {
plugins: [ plugins: [
getAotPlugin('client', !!options.aot) getAotPlugin('client', !!env.aot)
] ]
}); });
@@ -35,13 +35,13 @@ module.exports = function(options) {
const configs = []; const configs = [];
if (!options.aot) { if (!env.aot) {
configs.push(clientConfig, serverConfig); configs.push(clientConfig, serverConfig);
} else if (options.client) { } else if (env.client) {
configs.push(clientConfig); configs.push(clientConfig);
} else if (options.server) { } else if (env.server) {
configs.push(serverConfig); configs.push(serverConfig);
} }
return configs; return configs;
} };

View File

@@ -17,6 +17,10 @@ module.exports = {
watchOptions: { watchOptions: {
aggregateTimeout: 50, aggregateTimeout: 50,
}, },
node: {
fs: "empty",
module: "empty"
},
module: { module: {
rules: [{ rules: [{
test: /\.ts$/, test: /\.ts$/,
@@ -81,10 +85,6 @@ module.exports = {
{ {
test: /\.html$/, test: /\.html$/,
loader: 'raw-loader' loader: 'raw-loader'
},
{
test: /\.json$/,
loader: 'json-loader'
} }
] ]
}, },

View File

@@ -11,9 +11,11 @@ module.exports = {
mode: 'production', mode: 'production',
recordsOutputPath: root('webpack.records.json'), recordsOutputPath: root('webpack.records.json'),
plugins: [ plugins: [
new webpack.DefinePlugin({ new webpack.EnvironmentPlugin({
'process.env.NODE_ENV': JSON.stringify('production'), 'process.env': {
'process.env.AOT': true 'NODE_ENV': JSON.stringify('production'),
'AOT': true
}
}), }),
// Loader options // Loader options

View File

@@ -178,17 +178,6 @@ module.exports = function (options) {
exclude: [root('src/index.html')] exclude: [root('src/index.html')]
}, },
/**
* Json loader support for *.json files.
*
* See: https://github.com/webpack/json-loader
*/
{
test: /\.json$/,
loader: 'json-loader',
exclude: [root('src/index.html')]
},
/** /**
* Instruments JS files with Istanbul for subsequent code coverage reporting. * Instruments JS files with Istanbul for subsequent code coverage reporting.
* Instrument only testing sources. * Instrument only testing sources.
@@ -288,4 +277,4 @@ module.exports = function (options) {
} }
}; };
} };

1146
yarn.lock

File diff suppressed because it is too large Load Diff