mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
65272: Post-merge fixes
This commit is contained in:
@@ -26,7 +26,7 @@ export class EditItemTemplatePageComponent implements OnInit {
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -6,6 +6,7 @@ import { ItemTemplateDataService } from '../../core/data/item-template-data.serv
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { find } from 'rxjs/operators';
|
||||
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
|
||||
@@ -23,7 +24,7 @@ export class ItemTemplatePageResolver implements Resolve<RemoteData<Item>> {
|
||||
* or an error if something went wrong
|
||||
*/
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
}
|
@@ -75,6 +75,13 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
||||
* @returns {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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
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)));
|
||||
}
|
||||
|
||||
@@ -395,7 +402,7 @@ export abstract class DataService<T extends CacheableObject> implements UpdateDa
|
||||
*/
|
||||
create(dso: T, parentUUID?: string): Observable<RemoteData<T>> {
|
||||
const requestId = this.requestService.generateRequestId();
|
||||
const endpoint$ = this.getBrowseEndpoint().pipe(
|
||||
const endpoint$ = this.getEndpoint().pipe(
|
||||
isNotEmptyOperator(),
|
||||
distinctUntilChanged(),
|
||||
map((endpoint: string) => parentUUID ? `${endpoint}?parent=${parentUUID}` : endpoint)
|
||||
|
@@ -8,7 +8,6 @@ import { Observable } from 'rxjs/internal/Observable';
|
||||
import { DSOChangeAnalyzer } from './dso-change-analyzer.service';
|
||||
import { RequestService } from './request.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 { CoreState } from '../core.reducers';
|
||||
import { ObjectCacheService } from '../cache/object-cache.service';
|
||||
@@ -18,6 +17,8 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { BrowseService } from '../browse/browse.service';
|
||||
import { CollectionDataService } from './collection-data.service';
|
||||
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 */
|
||||
/**
|
||||
@@ -41,7 +42,6 @@ class DataServiceImpl extends ItemDataService {
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected bs: BrowseService,
|
||||
protected objectCache: ObjectCacheService,
|
||||
@@ -49,8 +49,9 @@ class DataServiceImpl extends ItemDataService {
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DSOChangeAnalyzer<Item>,
|
||||
protected bundleService: BundleDataService,
|
||||
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
|
||||
* @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);
|
||||
return super.findById(collectionID);
|
||||
return super.findById(collectionID, ...linksToFollow);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +121,7 @@ class DataServiceImpl extends ItemDataService {
|
||||
*/
|
||||
deleteByCollectionID(item: Item, collectionID: string): Observable<boolean> {
|
||||
this.setRegularEndpoint();
|
||||
return super.delete(item);
|
||||
return super.delete(item.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +138,6 @@ export class ItemTemplateDataService implements UpdateDataService<Item> {
|
||||
constructor(
|
||||
protected requestService: RequestService,
|
||||
protected rdbService: RemoteDataBuildService,
|
||||
protected dataBuildService: NormalizedObjectBuildService,
|
||||
protected store: Store<CoreState>,
|
||||
protected bs: BrowseService,
|
||||
protected objectCache: ObjectCacheService,
|
||||
@@ -144,8 +145,9 @@ export class ItemTemplateDataService implements UpdateDataService<Item> {
|
||||
protected notificationsService: NotificationsService,
|
||||
protected http: HttpClient,
|
||||
protected comparator: DSOChangeAnalyzer<Item>,
|
||||
protected bundleService: BundleDataService,
|
||||
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
|
||||
* @param collectionID
|
||||
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which {@link HALLink}s should be automatically resolved
|
||||
*/
|
||||
findByCollectionID(collectionID: string): Observable<RemoteData<Item>> {
|
||||
return this.dataService.findByCollectionID(collectionID);
|
||||
findByCollectionID(collectionID: string, ...linksToFollow: Array<FollowLinkConfig<Item>>): Observable<RemoteData<Item>> {
|
||||
return this.dataService.findByCollectionID(collectionID, ...linksToFollow);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,18 +1,24 @@
|
||||
import { inheritSerialization } from 'cerialize';
|
||||
import { Item } from './item.model';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { RemoteData } from '../data/remote-data';
|
||||
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
|
||||
*/
|
||||
@typedObject
|
||||
@inheritSerialization(Item)
|
||||
export class TemplateItem extends Item {
|
||||
static type = new ResourceType('itemtemplate');
|
||||
static type = ITEM_TEMPLATE;
|
||||
|
||||
/**
|
||||
* The Collection that this item is a template for
|
||||
*/
|
||||
@link(COLLECTION)
|
||||
templateItemOf: Observable<RemoteData<Collection>>;
|
||||
|
||||
}
|
||||
|
9
src/app/core/shared/template-item.resource-type.ts
Normal file
9
src/app/core/shared/template-item.resource-type.ts
Normal 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');
|
Reference in New Issue
Block a user