65272: Post-merge fixes

This commit is contained in:
Kristof De Langhe
2020-05-04 17:38:31 +02:00
parent 07c8c593ec
commit b5e1394fce
7 changed files with 42 additions and 38 deletions

View File

@@ -26,7 +26,7 @@ export class EditItemTemplatePageComponent implements OnInit {
} }
ngOnInit(): void { ngOnInit(): void {
this.collectionRD$ = this.route.data.pipe(first(), map((data) => data.collection)); this.collectionRD$ = this.route.parent.data.pipe(first(), map((data) => data.dso));
} }
/** /**

View File

@@ -6,6 +6,7 @@ import { ItemTemplateDataService } from '../../core/data/item-template-data.serv
import { Observable } from 'rxjs/internal/Observable'; import { Observable } from 'rxjs/internal/Observable';
import { find } from 'rxjs/operators'; import { find } from 'rxjs/operators';
import { hasValue } from '../../shared/empty.util'; import { hasValue } from '../../shared/empty.util';
import { followLink } from '../../shared/utils/follow-link-config.model';
/** /**
* This class represents a resolver that requests a specific collection's item template before the route is activated * This class represents a resolver that requests a specific collection's item template before the route is activated
@@ -23,7 +24,7 @@ export class ItemTemplatePageResolver implements Resolve<RemoteData<Item>> {
* or an error if something went wrong * or an error if something went wrong
*/ */
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> { resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
return this.itemTemplateService.findByCollectionID(route.params.id).pipe( return this.itemTemplateService.findByCollectionID(route.params.id, followLink('templateItemOf')).pipe(
find((RD) => hasValue(RD.error) || RD.hasSucceeded), find((RD) => hasValue(RD.error) || RD.hasSucceeded),
); );
} }

View File

@@ -1,22 +0,0 @@
import { inheritSerialization, deserialize } from 'cerialize';
import { mapsTo, relationship } from '../builders/build-decorators';
import { TemplateItem } from '../../shared/template-item.model';
import { NormalizedItem } from './normalized-item.model';
import { Collection } from '../../shared/collection.model';
/**
* Normalized model class for a DSpace Template Item
*/
@mapsTo(TemplateItem)
@inheritSerialization(NormalizedItem)
export class NormalizedTemplateItem extends NormalizedItem {
/**
* The Collection that this item is a template for
*/
@deserialize
@relationship(Collection, false)
templateItemOf: string;
}

View File

@@ -75,6 +75,13 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
* @returns {Observable<string>} * @returns {Observable<string>}
*/ */
getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> { getBrowseEndpoint(options: FindListOptions = {}, linkPath?: string): Observable<string> {
return this.getEndpoint();
}
/**
* Get the base endpoint for all requests
*/
protected getEndpoint(): Observable<string> {
return this.halService.getEndpoint(this.linkPath); return this.halService.getEndpoint(this.linkPath);
} }
@@ -238,7 +245,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved * @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/ */
getIDHrefObs(resourceID: string, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<string> { getIDHrefObs(resourceID: string, ...linksToFollow: Array<FollowLinkConfig<T>>): Observable<string> {
return this.getBrowseEndpoint().pipe( return this.getEndpoint().pipe(
map((endpoint: string) => this.getIDHref(endpoint, resourceID, ...linksToFollow))); map((endpoint: string) => this.getIDHref(endpoint, resourceID, ...linksToFollow)));
} }
@@ -395,7 +402,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
*/ */
create(dso: T, parentUUID?: string): Observable<RemoteData<T>> { create(dso: T, parentUUID?: string): Observable<RemoteData<T>> {
const requestId = this.requestService.generateRequestId(); const requestId = this.requestService.generateRequestId();
const endpoint$ = this.getBrowseEndpoint().pipe( const endpoint$ = this.getEndpoint().pipe(
isNotEmptyOperator(), isNotEmptyOperator(),
distinctUntilChanged(), distinctUntilChanged(),
map((endpoint: string) => parentUUID ? `${endpoint}?parent=${parentUUID}` : endpoint) map((endpoint: string) => parentUUID ? `${endpoint}?parent=${parentUUID}` : endpoint)

View File

@@ -8,7 +8,6 @@ import { Observable } from 'rxjs/internal/Observable';
import { DSOChangeAnalyzer } from './dso-change-analyzer.service'; import { DSOChangeAnalyzer } from './dso-change-analyzer.service';
import { RequestService } from './request.service'; import { RequestService } from './request.service';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
import { NormalizedObjectBuildService } from '../cache/builders/normalized-object-build.service';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { CoreState } from '../core.reducers'; import { CoreState } from '../core.reducers';
import { ObjectCacheService } from '../cache/object-cache.service'; import { ObjectCacheService } from '../cache/object-cache.service';
@@ -18,6 +17,8 @@ import { HttpClient } from '@angular/common/http';
import { BrowseService } from '../browse/browse.service'; import { BrowseService } from '../browse/browse.service';
import { CollectionDataService } from './collection-data.service'; import { CollectionDataService } from './collection-data.service';
import { switchMap } from 'rxjs/operators'; import { switchMap } from 'rxjs/operators';
import { BundleDataService } from './bundle-data.service';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
/* tslint:disable:max-classes-per-file */ /* tslint:disable:max-classes-per-file */
/** /**
@@ -41,7 +42,6 @@ class DataServiceImpl extends ItemDataService {
constructor( constructor(
protected requestService: RequestService, protected requestService: RequestService,
protected rdbService: RemoteDataBuildService, protected rdbService: RemoteDataBuildService,
protected dataBuildService: NormalizedObjectBuildService,
protected store: Store<CoreState>, protected store: Store<CoreState>,
protected bs: BrowseService, protected bs: BrowseService,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
@@ -49,8 +49,9 @@ class DataServiceImpl extends ItemDataService {
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected http: HttpClient, protected http: HttpClient,
protected comparator: DSOChangeAnalyzer<Item>, protected comparator: DSOChangeAnalyzer<Item>,
protected bundleService: BundleDataService,
protected collectionService: CollectionDataService) { protected collectionService: CollectionDataService) {
super(requestService, rdbService, dataBuildService, store, bs, objectCache, halService, notificationsService, http, comparator); super(requestService, rdbService, store, bs, objectCache, halService, notificationsService, http, comparator, bundleService);
} }
/** /**
@@ -96,10 +97,11 @@ class DataServiceImpl extends ItemDataService {
/** /**
* Set the collection ID and send a find by ID request * Set the collection ID and send a find by ID request
* @param collectionID * @param collectionID
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/ */
findByCollectionID(collectionID: string): Observable<RemoteData<Item>> { findByCollectionID(collectionID: string, ...linksToFollow: Array<FollowLinkConfig<Item>>): Observable<RemoteData<Item>> {
this.setCollectionEndpoint(collectionID); this.setCollectionEndpoint(collectionID);
return super.findById(collectionID); return super.findById(collectionID, ...linksToFollow);
} }
/** /**
@@ -119,7 +121,7 @@ class DataServiceImpl extends ItemDataService {
*/ */
deleteByCollectionID(item: Item, collectionID: string): Observable<boolean> { deleteByCollectionID(item: Item, collectionID: string): Observable<boolean> {
this.setRegularEndpoint(); this.setRegularEndpoint();
return super.delete(item); return super.delete(item.uuid);
} }
} }
@@ -136,7 +138,6 @@ export class ItemTemplateDataService implements UpdateDataService<Item> {
constructor( constructor(
protected requestService: RequestService, protected requestService: RequestService,
protected rdbService: RemoteDataBuildService, protected rdbService: RemoteDataBuildService,
protected dataBuildService: NormalizedObjectBuildService,
protected store: Store<CoreState>, protected store: Store<CoreState>,
protected bs: BrowseService, protected bs: BrowseService,
protected objectCache: ObjectCacheService, protected objectCache: ObjectCacheService,
@@ -144,8 +145,9 @@ export class ItemTemplateDataService implements UpdateDataService<Item> {
protected notificationsService: NotificationsService, protected notificationsService: NotificationsService,
protected http: HttpClient, protected http: HttpClient,
protected comparator: DSOChangeAnalyzer<Item>, protected comparator: DSOChangeAnalyzer<Item>,
protected bundleService: BundleDataService,
protected collectionService: CollectionDataService) { protected collectionService: CollectionDataService) {
this.dataService = new DataServiceImpl(requestService, rdbService, dataBuildService, store, bs, objectCache, halService, notificationsService, http, comparator, collectionService); this.dataService = new DataServiceImpl(requestService, rdbService, store, bs, objectCache, halService, notificationsService, http, comparator, bundleService, collectionService);
} }
/** /**
@@ -165,9 +167,10 @@ export class ItemTemplateDataService implements UpdateDataService<Item> {
/** /**
* Find an item template by collection ID * Find an item template by collection ID
* @param collectionID * @param collectionID
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
*/ */
findByCollectionID(collectionID: string): Observable<RemoteData<Item>> { findByCollectionID(collectionID: string, ...linksToFollow: Array<FollowLinkConfig<Item>>): Observable<RemoteData<Item>> {
return this.dataService.findByCollectionID(collectionID); return this.dataService.findByCollectionID(collectionID, ...linksToFollow);
} }
/** /**

View File

@@ -1,18 +1,24 @@
import { inheritSerialization } from 'cerialize';
import { Item } from './item.model'; import { Item } from './item.model';
import { Observable } from 'rxjs/internal/Observable'; import { Observable } from 'rxjs/internal/Observable';
import { RemoteData } from '../data/remote-data'; import { RemoteData } from '../data/remote-data';
import { Collection } from './collection.model'; import { Collection } from './collection.model';
import { ResourceType } from './resource-type'; import { ITEM_TEMPLATE } from './template-item.resource-type';
import { link, typedObject } from '../cache/builders/build-decorators';
import { COLLECTION } from './collection.resource-type';
/** /**
* Class representing a DSpace Template Item * Class representing a DSpace Template Item
*/ */
@typedObject
@inheritSerialization(Item)
export class TemplateItem extends Item { export class TemplateItem extends Item {
static type = new ResourceType('itemtemplate'); static type = ITEM_TEMPLATE;
/** /**
* The Collection that this item is a template for * The Collection that this item is a template for
*/ */
@link(COLLECTION)
templateItemOf: Observable<RemoteData<Collection>>; templateItemOf: Observable<RemoteData<Collection>>;
} }

View File

@@ -0,0 +1,9 @@
import { ResourceType } from './resource-type';
/**
* The resource type for TemplateItem.
*
* Needs to be in a separate file to prevent circular
* dependencies in webpack.
*/
export const ITEM_TEMPLATE = new ResourceType('itemtemplate');