[CST-5676] Breadcrumbs changes

This commit is contained in:
Sufiyan Shaikh
2022-04-20 15:44:01 +05:30
parent 6480b75aed
commit 01f3cbcaea
4 changed files with 63 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/re
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
import { LegacyBitstreamUrlResolver } from './legacy-bitstream-url.resolver';
import { BitstreamBreadcrumbResolver } from '../core/breadcrumbs/bitstream-breadcrumb.resolver';
const EDIT_BITSTREAM_PATH = ':id/edit';
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
@@ -25,7 +26,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
path: 'handle/:prefix/:suffix/:filename',
component: BitstreamDownloadPageComponent,
resolve: {
bitstream: LegacyBitstreamUrlResolver
bitstream: LegacyBitstreamUrlResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
},
{
@@ -33,7 +35,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
path: ':prefix/:suffix/:sequence_id/:filename',
component: BitstreamDownloadPageComponent,
resolve: {
bitstream: LegacyBitstreamUrlResolver
bitstream: LegacyBitstreamUrlResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
},
{
@@ -41,14 +44,16 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
path: ':id/download',
component: BitstreamDownloadPageComponent,
resolve: {
bitstream: BitstreamPageResolver
bitstream: BitstreamPageResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
},
{
path: EDIT_BITSTREAM_PATH,
component: EditBitstreamPageComponent,
resolve: {
bitstream: BitstreamPageResolver
bitstream: BitstreamPageResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
canActivate: [AuthenticatedGuard]
},
@@ -59,7 +64,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
{
path: 'create',
resolve: {
resourcePolicyTarget: ResourcePolicyTargetResolver
resourcePolicyTarget: ResourcePolicyTargetResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
component: ResourcePolicyCreateComponent,
data: { title: 'resource-policies.create.page.title', showBreadcrumbs: true }
@@ -67,7 +73,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
{
path: 'edit',
resolve: {
resourcePolicy: ResourcePolicyResolver
resourcePolicy: ResourcePolicyResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
component: ResourcePolicyEditComponent,
data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
@@ -75,7 +82,8 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
{
path: '',
resolve: {
bitstream: BitstreamPageResolver
bitstream: BitstreamPageResolver,
breadcrumb: BitstreamBreadcrumbResolver
},
component: BitstreamAuthorizationsComponent,
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
@@ -86,6 +94,7 @@ const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
],
providers: [
BitstreamPageResolver,
BitstreamBreadcrumbResolver
]
})
export class BitstreamPageRoutingModule {

View File

@@ -7,6 +7,19 @@ import { BitstreamDataService } from '../core/data/bitstream-data.service';
import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model';
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('format', {},
followLink('parentCommunity', {},
followLink('parentCommunity'))
),
followLink('bundle'),
followLink('thumbnail')
];
/**
* This class represents a resolver that requests a specific bitstream before the route is activated
*/

View File

@@ -0,0 +1,28 @@
import { Injectable } from '@angular/core';
import { DSOBreadcrumbsService } from './dso-breadcrumbs.service';
import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver';
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 'src/app/bitstream-page/bitstream-page.resolver';
/**
* The class that resolves the BreadcrumbConfig object for an Item
*/
@Injectable({
providedIn: 'root'
})
export class BitstreamBreadcrumbResolver extends DSOBreadcrumbResolver<Bitstream> {
constructor(protected breadcrumbService: DSOBreadcrumbsService, 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;
}
}

View File

@@ -7,13 +7,13 @@ import { BITSTREAM_FORMAT } from './bitstream-format.resource-type';
import { BITSTREAM } from './bitstream.resource-type';
import { DSpaceObject } from './dspace-object.model';
import { HALLink } from './hal-link.model';
import { HALResource } from './hal-resource.model';
import {BUNDLE} from './bundle.resource-type';
import {Bundle} from './bundle.model';
import { ChildHALResource } from './child-hal-resource.model';
@typedObject
@inheritSerialization(DSpaceObject)
export class Bitstream extends DSpaceObject implements HALResource {
export class Bitstream extends DSpaceObject implements ChildHALResource {
static type = BITSTREAM;
/**
@@ -66,4 +66,8 @@ export class Bitstream extends DSpaceObject implements HALResource {
*/
@link(BUNDLE)
bundle?: Observable<RemoteData<Bundle>>;
getParentLinkKey(): keyof this['_links'] {
return 'format';
}
}