Skip to content
Snippets Groups Projects
Commit aa172b6c authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

55946: Changes to comply to the new response cache features

parent 7f0e7980
No related branches found
No related tags found
No related merge requests found
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
import { ActivatedRoute, PRIMARY_OUTLET, Router, UrlSegmentGroup } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { RemoteData } from '../../core/data/remote-data';
import { Observable } from 'rxjs/Observable';
import { Collection } from '../../core/shared/collection.model';
import { SearchConfigurationService } from '../../+search-page/search-service/search-configuration.service';
import { PaginatedSearchOptions } from '../../+search-page/paginated-search-options.model';
import { PaginatedList } from '../../core/data/paginated-list';
import { flatMap, map, switchMap } from 'rxjs/operators';
import { map, switchMap } from 'rxjs/operators';
import { getSucceededRemoteData, toDSpaceObjectListRD } from '../../core/shared/operators';
import { SearchService } from '../../+search-page/search-service/search.service';
import { DSpaceObject } from '../../core/shared/dspace-object.model';
......@@ -15,11 +16,10 @@ import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { ItemDataService } from '../../core/data/item-data.service';
import { RestResponse } from '../../core/cache/response-cache.models';
import { TranslateService } from '@ngx-translate/core';
import { CollectionDataService } from '../../core/data/collection-data.service';
import { Item } from '../../core/shared/item.model';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { isNotEmpty } from '../../shared/empty.util';
import { RestResponse } from '../../core/cache/response.models';
@Component({
selector: 'ds-collection-item-mapper',
......@@ -75,7 +75,7 @@ export class CollectionItemMapperComponent implements OnInit {
}
ngOnInit(): void {
this.collectionRD$ = this.route.data.map((data) => data.collection).pipe(getSucceededRemoteData()) as Observable<RemoteData<Collection>>;
this.collectionRD$ = this.route.data.pipe(map((data) => data.collection)).pipe(getSucceededRemoteData()) as Observable<RemoteData<Collection>>;
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
this.loadItemLists();
}
......@@ -86,7 +86,7 @@ export class CollectionItemMapperComponent implements OnInit {
* TODO: When the API support it, fetch items excluding the collection's scope (currently fetches all items)
*/
loadItemLists() {
const collectionAndOptions$ = Observable.combineLatest(
const collectionAndOptions$ = observableCombineLatest(
this.collectionRD$,
this.searchOptions$
);
......@@ -120,7 +120,7 @@ export class CollectionItemMapperComponent implements OnInit {
getSucceededRemoteData(),
map((collectionRD: RemoteData<Collection>) => collectionRD.payload.id),
switchMap((collectionId: string) =>
Observable.combineLatest(ids.map((id: string) =>
observableCombineLatest(ids.map((id: string) =>
remove ? this.itemDataService.removeMappingFromCollection(id, collectionId) : this.itemDataService.mapToCollection(id, collectionId)
))
)
......@@ -132,7 +132,7 @@ export class CollectionItemMapperComponent implements OnInit {
const successful = responses.filter((response: RestResponse) => response.isSuccessful);
const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful);
if (successful.length > 0) {
const successMessages = Observable.combineLatest(
const successMessages = observableCombineLatest(
this.translateService.get(`collection.item-mapper.notifications.${messageInsertion}.success.head`),
this.translateService.get(`collection.item-mapper.notifications.${messageInsertion}.success.content`, { amount: successful.length })
);
......@@ -142,7 +142,7 @@ export class CollectionItemMapperComponent implements OnInit {
});
}
if (unsuccessful.length > 0) {
const unsuccessMessages = Observable.combineLatest(
const unsuccessMessages = observableCombineLatest(
this.translateService.get(`collection.item-mapper.notifications.${messageInsertion}.error.head`),
this.translateService.get(`collection.item-mapper.notifications.${messageInsertion}.error.content`, { amount: unsuccessful.length })
);
......
import { fadeIn, fadeInOut } from '../../shared/animations/fade';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { RemoteData } from '../../core/data/remote-data';
import { Item } from '../../core/shared/item.model';
import { map } from 'rxjs/operators';
@Component({
selector: 'ds-edit-item-page',
......@@ -28,7 +29,7 @@ export class EditItemPageComponent implements OnInit {
}
ngOnInit(): void {
this.itemRD$ = this.route.data.map((data) => data.item);
this.itemRD$ = this.route.data.pipe(map((data) => data.item));
}
}
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
import { Observable } from 'rxjs/Observable';
import { PaginatedSearchOptions } from '../../../+search-page/paginated-search-options.model';
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { Collection } from '../../../core/shared/collection.model';
......@@ -13,14 +12,12 @@ import { ActivatedRoute, Router } from '@angular/router';
import { SearchService } from '../../../+search-page/search-service/search.service';
import { SearchConfigurationService } from '../../../+search-page/search-service/search-configuration.service';
import { map, switchMap } from 'rxjs/operators';
import { CollectionDataService } from '../../../core/data/collection-data.service';
import { ItemDataService } from '../../../core/data/item-data.service';
import { RestResponse } from '../../../core/cache/response-cache.models';
import { TranslateService } from '@ngx-translate/core';
import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { C } from '@angular/core/src/render3';
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
import { isNotEmpty } from '../../../shared/empty.util';
import { RestResponse } from '../../../core/cache/response.models';
@Component({
selector: 'ds-item-collection-mapper',
......@@ -68,7 +65,7 @@ export class ItemCollectionMapperComponent implements OnInit {
}
ngOnInit(): void {
this.itemRD$ = this.route.data.map((data) => data.item).pipe(getSucceededRemoteData()) as Observable<RemoteData<Item>>;
this.itemRD$ = this.route.data.pipe(map((data) => data.item)).pipe(getSucceededRemoteData()) as Observable<RemoteData<Item>>;
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
this.loadCollectionLists();
}
......@@ -84,7 +81,7 @@ export class ItemCollectionMapperComponent implements OnInit {
switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id))
);
const itemCollectionsAndOptions$ = Observable.combineLatest(
const itemCollectionsAndOptions$ = observableCombineLatest(
this.itemCollectionsRD$,
this.searchOptions$
);
......@@ -104,7 +101,7 @@ export class ItemCollectionMapperComponent implements OnInit {
* @param {string[]} ids The list of collection UUID's to map the item to
*/
mapCollections(ids: string[]) {
const itemIdAndExcludingIds$ = Observable.combineLatest(
const itemIdAndExcludingIds$ = observableCombineLatest(
this.itemRD$.pipe(
getSucceededRemoteData(),
map((rd: RemoteData<Item>) => rd.payload),
......@@ -119,7 +116,7 @@ export class ItemCollectionMapperComponent implements OnInit {
// Map the item to the collections found in ids, excluding the collections the item is already mapped to
const responses$ = itemIdAndExcludingIds$.pipe(
switchMap(([itemId, excludingIds]) => Observable.combineLatest(this.filterIds(ids, excludingIds).map((id: string) => this.itemDataService.mapToCollection(itemId, id))))
switchMap(([itemId, excludingIds]) => observableCombineLatest(this.filterIds(ids, excludingIds).map((id: string) => this.itemDataService.mapToCollection(itemId, id))))
);
this.showNotifications(responses$, 'item.edit.item-mapper.notifications.add');
......@@ -134,7 +131,7 @@ export class ItemCollectionMapperComponent implements OnInit {
const responses$ = this.itemRD$.pipe(
getSucceededRemoteData(),
map((itemRD: RemoteData<Item>) => itemRD.payload.id),
switchMap((itemId: string) => Observable.combineLatest(ids.map((id: string) => this.itemDataService.removeMappingFromCollection(itemId, id))))
switchMap((itemId: string) => observableCombineLatest(ids.map((id: string) => this.itemDataService.removeMappingFromCollection(itemId, id))))
);
this.showNotifications(responses$, 'item.edit.item-mapper.notifications.remove');
......@@ -160,7 +157,7 @@ export class ItemCollectionMapperComponent implements OnInit {
const successful = responses.filter((response: RestResponse) => response.isSuccessful);
const unsuccessful = responses.filter((response: RestResponse) => !response.isSuccessful);
if (successful.length > 0) {
const successMessages = Observable.combineLatest(
const successMessages = observableCombineLatest(
this.translateService.get(`${messagePrefix}.success.head`),
this.translateService.get(`${messagePrefix}.success.content`, { amount: successful.length })
);
......@@ -170,7 +167,7 @@ export class ItemCollectionMapperComponent implements OnInit {
});
}
if (unsuccessful.length > 0) {
const unsuccessMessages = Observable.combineLatest(
const unsuccessMessages = observableCombineLatest(
this.translateService.get(`${messagePrefix}.error.head`),
this.translateService.get(`${messagePrefix}.error.content`, { amount: unsuccessful.length })
);
......
......@@ -9,7 +9,7 @@ import { ComColDataService } from './comcol-data.service';
import { CommunityDataService } from './community-data.service';
import { RequestService } from './request.service';
import { HALEndpointService } from '../shared/hal-endpoint.service';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { RemoteData } from './remote-data';
import { PaginatedList } from './paginated-list';
import { distinctUntilChanged, map } from 'rxjs/operators';
......
......@@ -2,9 +2,9 @@ import { Injectable } from '@angular/core';
import { ResponseParsingService } from './parsing.service';
import { RestRequest } from './request.models';
import { DSpaceRESTV2Response } from '../dspace-rest-v2/dspace-rest-v2-response.model';
import { ErrorResponse, GenericSuccessResponse, RestResponse } from '../cache/response-cache.models';
import { PaginatedList } from './paginated-list';
import { PageInfo } from '../shared/page-info.model';
import { ErrorResponse, GenericSuccessResponse, RestResponse } from '../cache/response.models';
@Injectable()
export class MappingCollectionsReponseParsingService implements ResponseParsingService {
......
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { take } from 'rxjs/operators';
import { Observable } from 'rxjs/Observable';
import { Component} from '@angular/core';
import { Item } from '../../../core/shared/item.model';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
import { ObjectSelectService } from '../object-select.service';
import { ObjectSelectComponent } from '../object-select/object-select.component';
import { isNotEmpty } from '../../empty.util';
......
......@@ -7,7 +7,7 @@ import {
ObjectSelectionInitialSelectAction, ObjectSelectionResetAction,
ObjectSelectionSelectAction, ObjectSelectionSwitchAction
} from './object-select.actions';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { hasValue } from '../empty.util';
import { map } from 'rxjs/operators';
import { AppState } from '../../app.reducer';
......
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
import { take } from 'rxjs/operators';
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list';
import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
......
import { Observable } from 'rxjs/Observable';
import { Observable } from 'rxjs';
import { of } from 'rxjs/internal/observable/of';
export class ObjectSelectServiceStub {
......@@ -12,14 +13,14 @@ export class ObjectSelectServiceStub {
getSelected(id: string): Observable<boolean> {
if (this.ids.indexOf(id) > -1) {
return Observable.of(true);
return of(true);
} else {
return Observable.of(false);
return of(false);
}
}
getAllSelected(): Observable<string[]> {
return Observable.of(this.ids);
return of(this.ids);
}
switch(id: string) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment