mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
updated angular/rxjs to v6 successfully
This commit is contained in:
@@ -4,13 +4,13 @@ import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../utils/truncate.pipe';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { Observable } from 'rxjs';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
|
||||
let itemGridElementComponent: ItemGridElementComponent;
|
||||
let fixture: ComponentFixture<ItemGridElementComponent>;
|
||||
|
||||
const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
@@ -24,7 +24,7 @@ const mockItemWithAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
}]
|
||||
});
|
||||
const mockItemWithoutAuthorAndDate: Item = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
@@ -26,7 +25,7 @@ import { PaginationComponentOptions } from '../pagination/pagination-component-o
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
encapsulation: ViewEncapsulation.Emulated,
|
||||
selector: 'ds-object-grid',
|
||||
styleUrls: [ './object-grid.component.scss' ],
|
||||
styleUrls: ['./object-grid.component.scss'],
|
||||
templateUrl: './object-grid.component.html',
|
||||
animations: [fadeIn]
|
||||
})
|
||||
@@ -38,9 +37,11 @@ export class ObjectGridComponent implements OnInit {
|
||||
@Input() hideGear = false;
|
||||
@Input() hidePagerWhenSinglePage = true;
|
||||
private _objects$: BehaviorSubject<RemoteData<PaginatedList<ListableObject>>>;
|
||||
|
||||
@Input() set objects(objects: RemoteData<PaginatedList<ListableObject>>) {
|
||||
this._objects$.next(objects);
|
||||
}
|
||||
|
||||
get objects() {
|
||||
return this._objects$.getValue();
|
||||
}
|
||||
@@ -111,26 +112,25 @@ export class ObjectGridComponent implements OnInit {
|
||||
|
||||
this.columns$ = observableCombineLatest(
|
||||
nbColumns$,
|
||||
this._objects$,
|
||||
(nbColumns, objects) => {
|
||||
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
|
||||
const page = objects.payload.page;
|
||||
this._objects$).pipe(map(([nbColumns, objects]) => {
|
||||
if (hasValue(objects) && hasValue(objects.payload) && hasValue(objects.payload.page)) {
|
||||
const page = objects.payload.page;
|
||||
|
||||
const result = [];
|
||||
const result = [];
|
||||
|
||||
page.forEach((obj: ListableObject, i: number) => {
|
||||
const colNb = i % nbColumns;
|
||||
let col = result[colNb];
|
||||
if (hasNoValue(col)) {
|
||||
col = [];
|
||||
}
|
||||
result[colNb] = [...col, obj];
|
||||
});
|
||||
return result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
page.forEach((obj: ListableObject, i: number) => {
|
||||
const colNb = i % nbColumns;
|
||||
let col = result[colNb];
|
||||
if (hasNoValue(col)) {
|
||||
col = [];
|
||||
}
|
||||
result[colNb] = [...col, obj];
|
||||
});
|
||||
return result;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
onPageChange(event) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { CollectionSearchResultGridElementComponent } from './collection-search-result-grid-element.component';
|
||||
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 { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
@@ -12,7 +12,7 @@ let collectionSearchResultGridElementComponent: CollectionSearchResultGridElemen
|
||||
let fixture: ComponentFixture<CollectionSearchResultGridElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => Observable.of(true),
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const mockCollectionWithAbstract: CollectionSearchResult = new CollectionSearchResult();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { CommunitySearchResultGridElementComponent } from './community-search-result-grid-element.component';
|
||||
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 { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
@@ -12,7 +12,7 @@ let communitySearchResultGridElementComponent: CommunitySearchResultGridElementC
|
||||
let fixture: ComponentFixture<CommunitySearchResultGridElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => Observable.of(true),
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const mockCommunityWithAbstract: CommunitySearchResult = new CommunitySearchResult();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { ItemSearchResultGridElementComponent } from './item-search-result-grid-element.component';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { Observable } from 'rxjs';
|
||||
import { NO_ERRORS_SCHEMA, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TruncatePipe } from '../../../utils/truncate.pipe';
|
||||
import { Item } from '../../../../core/shared/item.model';
|
||||
@@ -13,13 +13,13 @@ let itemSearchResultGridElementComponent: ItemSearchResultGridElementComponent;
|
||||
let fixture: ComponentFixture<ItemSearchResultGridElementComponent>;
|
||||
|
||||
const truncatableServiceStub: any = {
|
||||
isCollapsed: (id: number) => Observable.of(true),
|
||||
isCollapsed: (id: number) => observableOf(true),
|
||||
};
|
||||
|
||||
const mockItemWithAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithAuthorAndDate.hitHighlights = [];
|
||||
mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.contributor.author',
|
||||
@@ -36,7 +36,7 @@ mockItemWithAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||
const mockItemWithoutAuthorAndDate: ItemSearchResult = new ItemSearchResult();
|
||||
mockItemWithoutAuthorAndDate.hitHighlights = [];
|
||||
mockItemWithoutAuthorAndDate.dspaceObject = Object.assign(new Item(), {
|
||||
bitstreams: Observable.of({}),
|
||||
bitstreams: observableOf({}),
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { WrapperGridElementComponent } from './wrapper-grid-element.component';
|
||||
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 { RouterStub } from '../../testing/router-stub';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
@@ -11,7 +11,7 @@ let fixture: ComponentFixture<WrapperGridElementComponent>;
|
||||
const queryParam = 'test query';
|
||||
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
|
||||
const activatedRouteStub = {
|
||||
queryParams: Observable.of({
|
||||
queryParams: observableOf({
|
||||
query: queryParam,
|
||||
scope: scopeParam
|
||||
})
|
||||
|
Reference in New Issue
Block a user