mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #1628 from 4Science/CST-5676
Bitstream edit page fixes
This commit is contained in:
@@ -10,6 +10,9 @@ import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/re
|
|||||||
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
|
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
|
||||||
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
||||||
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
|
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
|
||||||
|
import { BitstreamBreadcrumbResolver } from '../core/breadcrumbs/bitstream-breadcrumb.resolver';
|
||||||
|
import { BitstreamBreadcrumbsService } from '../core/breadcrumbs/bitstream-breadcrumbs.service';
|
||||||
|
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
|
|
||||||
const EDIT_BITSTREAM_PATH = ':id/edit';
|
const EDIT_BITSTREAM_PATH = ':id/edit';
|
||||||
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
||||||
@@ -48,7 +51,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
path: EDIT_BITSTREAM_PATH,
|
path: EDIT_BITSTREAM_PATH,
|
||||||
component: EditBitstreamPageComponent,
|
component: EditBitstreamPageComponent,
|
||||||
resolve: {
|
resolve: {
|
||||||
bitstream: BitstreamPageResolver
|
bitstream: BitstreamPageResolver,
|
||||||
|
breadcrumb: BitstreamBreadcrumbResolver,
|
||||||
},
|
},
|
||||||
canActivate: [AuthenticatedGuard]
|
canActivate: [AuthenticatedGuard]
|
||||||
},
|
},
|
||||||
@@ -67,15 +71,17 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
{
|
{
|
||||||
path: 'edit',
|
path: 'edit',
|
||||||
resolve: {
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
resourcePolicy: ResourcePolicyResolver
|
resourcePolicy: ResourcePolicyResolver
|
||||||
},
|
},
|
||||||
component: ResourcePolicyEditComponent,
|
component: ResourcePolicyEditComponent,
|
||||||
data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
|
data: { breadcrumbKey: 'item.edit', title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
resolve: {
|
resolve: {
|
||||||
bitstream: BitstreamPageResolver
|
bitstream: BitstreamPageResolver,
|
||||||
|
breadcrumb: BitstreamBreadcrumbResolver,
|
||||||
},
|
},
|
||||||
component: BitstreamAuthorizationsComponent,
|
component: BitstreamAuthorizationsComponent,
|
||||||
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
|
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
|
||||||
@@ -86,6 +92,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
|||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
BitstreamPageResolver,
|
BitstreamPageResolver,
|
||||||
|
BitstreamBreadcrumbResolver,
|
||||||
|
BitstreamBreadcrumbsService
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class BitstreamPageRoutingModule {
|
export class BitstreamPageRoutingModule {
|
||||||
|
@@ -7,6 +7,15 @@ import { BitstreamDataService } from '../core/data/bitstream-data.service';
|
|||||||
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
|
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
|
||||||
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../core/shared/operators';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The self links defined in this list are expected to be requested somewhere in the near future
|
||||||
|
* Requesting them as embeds will limit the number of requests
|
||||||
|
*/
|
||||||
|
export const BITSTREAM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig<Bitstream>[] = [
|
||||||
|
followLink('bundle', {}, followLink('item')),
|
||||||
|
followLink('format')
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a resolver that requests a specific bitstream before the route is activated
|
* This class represents a resolver that requests a specific bitstream before the route is activated
|
||||||
*/
|
*/
|
||||||
@@ -34,9 +43,6 @@ export class BitstreamPageResolver implements Resolve<RemoteData<Bitstream>> {
|
|||||||
* Requesting them as embeds will limit the number of requests
|
* Requesting them as embeds will limit the number of requests
|
||||||
*/
|
*/
|
||||||
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
||||||
return [
|
return BITSTREAM_PAGE_LINKS_TO_FOLLOW;
|
||||||
followLink('bundle', {}, followLink('item')),
|
|
||||||
followLink('format')
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts
Normal file
31
src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
|
import { BitstreamDataService } from '../data/bitstream-data.service';
|
||||||
|
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver';
|
||||||
|
import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver';
|
||||||
|
import { BitstreamBreadcrumbsService } from './bitstream-breadcrumbs.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class that resolves the BreadcrumbConfig object for an Item
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BitstreamBreadcrumbResolver extends DSOBreadcrumbResolver<Bitstream> {
|
||||||
|
constructor(
|
||||||
|
protected breadcrumbService: BitstreamBreadcrumbsService, protected dataService: BitstreamDataService) {
|
||||||
|
super(breadcrumbService, dataService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method that returns the follow links to already resolve
|
||||||
|
* The self links defined in this list are expected to be requested somewhere in the near future
|
||||||
|
* Requesting them as embeds will limit the number of requests
|
||||||
|
*/
|
||||||
|
get followLinks(): FollowLinkConfig<Bitstream>[] {
|
||||||
|
return BITSTREAM_PAGE_LINKS_TO_FOLLOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
85
src/app/core/breadcrumbs/bitstream-breadcrumbs.service.ts
Normal file
85
src/app/core/breadcrumbs/bitstream-breadcrumbs.service.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
import { map, switchMap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { Breadcrumb } from '../../breadcrumbs/breadcrumb/breadcrumb.model';
|
||||||
|
import { DSONameService } from './dso-name.service';
|
||||||
|
import { ChildHALResource } from '../shared/child-hal-resource.model';
|
||||||
|
import { LinkService } from '../cache/builders/link.service';
|
||||||
|
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||||
|
import { RemoteData } from '../data/remote-data';
|
||||||
|
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||||
|
import { getDSORoute } from '../../app-routing-paths';
|
||||||
|
import { DSOBreadcrumbsService } from './dso-breadcrumbs.service';
|
||||||
|
import { BitstreamDataService } from '../data/bitstream-data.service';
|
||||||
|
import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../shared/operators';
|
||||||
|
import { Bitstream } from '../shared/bitstream.model';
|
||||||
|
import { Bundle } from '../shared/bundle.model';
|
||||||
|
import { Item } from '../shared/item.model';
|
||||||
|
import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from '../../bitstream-page/bitstream-page.resolver';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Service to calculate DSpaceObject breadcrumbs for a single part of the route
|
||||||
|
*/
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class BitstreamBreadcrumbsService extends DSOBreadcrumbsService {
|
||||||
|
constructor(
|
||||||
|
protected bitstreamService: BitstreamDataService,
|
||||||
|
protected linkService: LinkService,
|
||||||
|
protected dsoNameService: DSONameService
|
||||||
|
) {
|
||||||
|
super(linkService, dsoNameService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to recursively calculate the breadcrumbs
|
||||||
|
* This method returns the name and url of the key and all its parent DSOs recursively, top down
|
||||||
|
* @param key The key (a DSpaceObject) used to resolve the breadcrumb
|
||||||
|
* @param url The url to use as a link for this breadcrumb
|
||||||
|
*/
|
||||||
|
getBreadcrumbs(key: ChildHALResource & DSpaceObject, url: string): Observable<Breadcrumb[]> {
|
||||||
|
const label = this.dsoNameService.getName(key);
|
||||||
|
const crumb = new Breadcrumb(label, url);
|
||||||
|
|
||||||
|
return this.getOwningItem(key.uuid).pipe(
|
||||||
|
switchMap((parentRD: RemoteData<ChildHALResource & DSpaceObject>) => {
|
||||||
|
if (isNotEmpty(parentRD) && hasValue(parentRD.payload)) {
|
||||||
|
const parent = parentRD.payload;
|
||||||
|
return super.getBreadcrumbs(parent, getDSORoute(parent));
|
||||||
|
}
|
||||||
|
return observableOf([]);
|
||||||
|
|
||||||
|
}),
|
||||||
|
map((breadcrumbs: Breadcrumb[]) => [...breadcrumbs, crumb])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
getOwningItem(uuid: string): Observable<RemoteData<Item>> {
|
||||||
|
return this.bitstreamService.findById(uuid, true, true, ...BITSTREAM_PAGE_LINKS_TO_FOLLOW).pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((bitstream: Bitstream) => {
|
||||||
|
if (hasValue(bitstream)) {
|
||||||
|
return bitstream.bundle.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
getRemoteDataPayload(),
|
||||||
|
switchMap((bundle: Bundle) => {
|
||||||
|
if (hasValue(bundle)) {
|
||||||
|
return bundle.item.pipe(
|
||||||
|
getFirstCompletedRemoteData(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return observableOf(undefined);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return observableOf(undefined);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -20,8 +20,8 @@ import { getDSORoute } from '../../app-routing-paths';
|
|||||||
})
|
})
|
||||||
export class DSOBreadcrumbsService implements BreadcrumbsProviderService<ChildHALResource & DSpaceObject> {
|
export class DSOBreadcrumbsService implements BreadcrumbsProviderService<ChildHALResource & DSpaceObject> {
|
||||||
constructor(
|
constructor(
|
||||||
private linkService: LinkService,
|
protected linkService: LinkService,
|
||||||
private dsoNameService: DSONameService
|
protected dsoNameService: DSONameService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -7,13 +7,13 @@ import { BITSTREAM_FORMAT } from './bitstream-format.resource-type';
|
|||||||
import { BITSTREAM } from './bitstream.resource-type';
|
import { BITSTREAM } from './bitstream.resource-type';
|
||||||
import { DSpaceObject } from './dspace-object.model';
|
import { DSpaceObject } from './dspace-object.model';
|
||||||
import { HALLink } from './hal-link.model';
|
import { HALLink } from './hal-link.model';
|
||||||
import { HALResource } from './hal-resource.model';
|
|
||||||
import {BUNDLE} from './bundle.resource-type';
|
import {BUNDLE} from './bundle.resource-type';
|
||||||
import {Bundle} from './bundle.model';
|
import {Bundle} from './bundle.model';
|
||||||
|
import { ChildHALResource } from './child-hal-resource.model';
|
||||||
|
|
||||||
@typedObject
|
@typedObject
|
||||||
@inheritSerialization(DSpaceObject)
|
@inheritSerialization(DSpaceObject)
|
||||||
export class Bitstream extends DSpaceObject implements HALResource {
|
export class Bitstream extends DSpaceObject implements ChildHALResource {
|
||||||
static type = BITSTREAM;
|
static type = BITSTREAM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,4 +66,8 @@ export class Bitstream extends DSpaceObject implements HALResource {
|
|||||||
*/
|
*/
|
||||||
@link(BUNDLE)
|
@link(BUNDLE)
|
||||||
bundle?: Observable<RemoteData<Bundle>>;
|
bundle?: Observable<RemoteData<Bundle>>;
|
||||||
|
|
||||||
|
getParentLinkKey(): keyof this['_links'] {
|
||||||
|
return 'format';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
<div *ngIf="(getResourcePolicies() | async)?.length > 0" class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-bordered table-hover">
|
<table class="table table-striped table-bordered table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="text-center">
|
<tr *ngIf="(getResourcePolicies() | async)?.length > 0" class="text-center">
|
||||||
<th>
|
<th>
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<th>{{'resource-policies.table.headers.edit' | translate}}</th>
|
<th>{{'resource-policies.table.headers.edit' | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody *ngIf="(getResourcePolicies() | async)?.length > 0">
|
||||||
<tr *ngFor="let entry of (getResourcePolicies() | async); trackById">
|
<tr *ngFor="let entry of (getResourcePolicies() | async); trackById">
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="custom-control custom-checkbox">
|
<div class="custom-control custom-checkbox">
|
||||||
|
Reference in New Issue
Block a user