mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
112970: Added missing breadcrumbs to create community/collection pages
This commit is contained in:
@@ -21,14 +21,32 @@ import { CollectionPageAdministratorGuard } from './collection-page-administrato
|
|||||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
||||||
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
|
import { ThemedCollectionPageComponent } from './themed-collection-page.component';
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||||
|
import { CommunityBreadcrumbResolver } from '../core/breadcrumbs/community-breadcrumb.resolver';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild([
|
RouterModule.forChild([
|
||||||
{
|
{
|
||||||
path: COLLECTION_CREATE_PATH,
|
path: COLLECTION_CREATE_PATH,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
component: CreateCollectionPageComponent,
|
component: CreateCollectionPageComponent,
|
||||||
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard]
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
breadcrumbKey: 'collection.create',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard],
|
||||||
|
data: {
|
||||||
|
breadcrumbQueryParam: 'parent',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: CommunityBreadcrumbResolver,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
@@ -90,7 +108,8 @@ import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
|||||||
DSOBreadcrumbsService,
|
DSOBreadcrumbsService,
|
||||||
LinkService,
|
LinkService,
|
||||||
CreateCollectionPageGuard,
|
CreateCollectionPageGuard,
|
||||||
CollectionPageAdministratorGuard
|
CollectionPageAdministratorGuard,
|
||||||
|
CommunityBreadcrumbResolver,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CollectionPageRoutingModule {
|
export class CollectionPageRoutingModule {
|
||||||
|
@@ -14,14 +14,32 @@ import { CommunityPageAdministratorGuard } from './community-page-administrator.
|
|||||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
||||||
import { ThemedCommunityPageComponent } from './themed-community-page.component';
|
import { ThemedCommunityPageComponent } from './themed-community-page.component';
|
||||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||||
|
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild([
|
RouterModule.forChild([
|
||||||
{
|
{
|
||||||
path: COMMUNITY_CREATE_PATH,
|
path: COMMUNITY_CREATE_PATH,
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
component: CreateCommunityPageComponent,
|
component: CreateCommunityPageComponent,
|
||||||
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard]
|
resolve: {
|
||||||
|
breadcrumb: I18nBreadcrumbResolver,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
breadcrumbKey: 'community.create',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
],
|
||||||
|
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard],
|
||||||
|
data: {
|
||||||
|
breadcrumbQueryParam: 'parent',
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
breadcrumb: CommunityBreadcrumbResolver,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':id',
|
path: ':id',
|
||||||
|
@@ -5,6 +5,10 @@ import { CommunityDataService } from '../data/community-data.service';
|
|||||||
import { Community } from '../shared/community.model';
|
import { Community } from '../shared/community.model';
|
||||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
import { COMMUNITY_PAGE_LINKS_TO_FOLLOW } from '../../community-page/community-page.resolver';
|
import { COMMUNITY_PAGE_LINKS_TO_FOLLOW } from '../../community-page/community-page.resolver';
|
||||||
|
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model';
|
||||||
|
import { hasValue } from '../../shared/empty.util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class that resolves the BreadcrumbConfig object for a Community
|
* The class that resolves the BreadcrumbConfig object for a Community
|
||||||
@@ -17,6 +21,23 @@ export class CommunityBreadcrumbResolver extends DSOBreadcrumbResolver<Community
|
|||||||
super(breadcrumbService, dataService);
|
super(breadcrumbService, dataService);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to retrieve the breadcrumb config by the route id. It is also possible to retrieve the id through the
|
||||||
|
* query parameters. This is done by defining the name of the query parameter in the data section under the property
|
||||||
|
* breadcrumbQueryParam.
|
||||||
|
*
|
||||||
|
* @param route The current {@link ActivatedRouteSnapshot}
|
||||||
|
* @param state The current {@link RouterStateSnapshot}
|
||||||
|
* @returns BreadcrumbConfig object
|
||||||
|
*/
|
||||||
|
override resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<Community>> {
|
||||||
|
if (hasValue(route.data.breadcrumbQueryParam) && hasValue(route.queryParams[route.data.breadcrumbQueryParam])) {
|
||||||
|
return this.resolveById(route.queryParams[route.data.breadcrumbQueryParam]);
|
||||||
|
} else {
|
||||||
|
return super.resolve(route, state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that returns the follow links to already resolve
|
* 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
|
* The self links defined in this list are expected to be requested somewhere in the near future
|
||||||
|
@@ -18,7 +18,10 @@ describe('DSOBreadcrumbResolver', () => {
|
|||||||
uuid = '1234-65487-12354-1235';
|
uuid = '1234-65487-12354-1235';
|
||||||
breadcrumbUrl = '/collections/' + uuid;
|
breadcrumbUrl = '/collections/' + uuid;
|
||||||
currentUrl = breadcrumbUrl + '/edit';
|
currentUrl = breadcrumbUrl + '/edit';
|
||||||
testCollection = Object.assign(new Collection(), { uuid });
|
testCollection = Object.assign(new Collection(), {
|
||||||
|
uuid: uuid,
|
||||||
|
type: 'collection',
|
||||||
|
});
|
||||||
dsoBreadcrumbService = {};
|
dsoBreadcrumbService = {};
|
||||||
collectionService = {
|
collectionService = {
|
||||||
findById: (id: string) => createSuccessfulRemoteDataObject$(testCollection)
|
findById: (id: string) => createSuccessfulRemoteDataObject$(testCollection)
|
||||||
|
@@ -10,6 +10,7 @@ import { ChildHALResource } from '../shared/child-hal-resource.model';
|
|||||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||||
import { hasValue } from '../../shared/empty.util';
|
import { hasValue } from '../../shared/empty.util';
|
||||||
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
|
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
|
||||||
|
import { getDSORoute } from '../../app-routing-paths';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class that resolves the BreadcrumbConfig object for a DSpaceObject
|
* The class that resolves the BreadcrumbConfig object for a DSpaceObject
|
||||||
@@ -31,15 +32,22 @@ export abstract class DSOBreadcrumbResolver<T extends ChildHALResource & DSpaceO
|
|||||||
* @returns BreadcrumbConfig object
|
* @returns BreadcrumbConfig object
|
||||||
*/
|
*/
|
||||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<T>> {
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<T>> {
|
||||||
const uuid = route.params.id;
|
return this.resolveById(route.params.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for resolving a breadcrumb by id
|
||||||
|
*
|
||||||
|
* @param uuid The uuid to resolve
|
||||||
|
* @returns BreadcrumbConfig object
|
||||||
|
*/
|
||||||
|
resolveById(uuid: string): Observable<BreadcrumbConfig<T>> {
|
||||||
return this.dataService.findById(uuid, true, false, ...this.followLinks).pipe(
|
return this.dataService.findById(uuid, true, false, ...this.followLinks).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
getRemoteDataPayload(),
|
getRemoteDataPayload(),
|
||||||
map((object: T) => {
|
map((object: T) => {
|
||||||
if (hasValue(object)) {
|
if (hasValue(object)) {
|
||||||
const fullPath = state.url;
|
return { provider: this.breadcrumbService, key: object, url: getDSORoute(object) };
|
||||||
const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid;
|
|
||||||
return { provider: this.breadcrumbService, key: object, url: url };
|
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@@ -781,6 +781,7 @@
|
|||||||
"chips.remove": "Remove chip",
|
"chips.remove": "Remove chip",
|
||||||
|
|
||||||
|
|
||||||
|
"collection.create.breadcrumbs": "Create collection",
|
||||||
|
|
||||||
"collection.create.head": "Create a Collection",
|
"collection.create.head": "Create a Collection",
|
||||||
|
|
||||||
@@ -1053,6 +1054,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
"community.create.breadcrumbs": "Create Community",
|
||||||
|
|
||||||
"community.create.head": "Create a Community",
|
"community.create.head": "Create a Community",
|
||||||
|
|
||||||
"community.create.notifications.success": "Successfully created the Community",
|
"community.create.notifications.success": "Successfully created the Community",
|
||||||
|
Reference in New Issue
Block a user