mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +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 { ThemedCollectionPageComponent } from './themed-collection-page.component';
|
||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||
import { CommunityBreadcrumbResolver } from '../core/breadcrumbs/community-breadcrumb.resolver';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: COLLECTION_CREATE_PATH,
|
||||
component: CreateCollectionPageComponent,
|
||||
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard]
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: CreateCollectionPageComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver,
|
||||
},
|
||||
data: {
|
||||
breadcrumbKey: 'collection.create',
|
||||
},
|
||||
},
|
||||
],
|
||||
canActivate: [AuthenticatedGuard, CreateCollectionPageGuard],
|
||||
data: {
|
||||
breadcrumbQueryParam: 'parent',
|
||||
},
|
||||
resolve: {
|
||||
breadcrumb: CommunityBreadcrumbResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
@@ -90,7 +108,8 @@ import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||
DSOBreadcrumbsService,
|
||||
LinkService,
|
||||
CreateCollectionPageGuard,
|
||||
CollectionPageAdministratorGuard
|
||||
CollectionPageAdministratorGuard,
|
||||
CommunityBreadcrumbResolver,
|
||||
]
|
||||
})
|
||||
export class CollectionPageRoutingModule {
|
||||
|
@@ -14,14 +14,32 @@ import { CommunityPageAdministratorGuard } from './community-page-administrator.
|
||||
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
|
||||
import { ThemedCommunityPageComponent } from './themed-community-page.component';
|
||||
import { MenuItemType } from '../shared/menu/menu-item-type.model';
|
||||
import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild([
|
||||
{
|
||||
path: COMMUNITY_CREATE_PATH,
|
||||
component: CreateCommunityPageComponent,
|
||||
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard]
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
component: CreateCommunityPageComponent,
|
||||
resolve: {
|
||||
breadcrumb: I18nBreadcrumbResolver,
|
||||
},
|
||||
data: {
|
||||
breadcrumbKey: 'community.create',
|
||||
},
|
||||
}
|
||||
],
|
||||
canActivate: [AuthenticatedGuard, CreateCommunityPageGuard],
|
||||
data: {
|
||||
breadcrumbQueryParam: 'parent',
|
||||
},
|
||||
resolve: {
|
||||
breadcrumb: CommunityBreadcrumbResolver,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
|
@@ -5,6 +5,10 @@ import { CommunityDataService } from '../data/community-data.service';
|
||||
import { Community } from '../shared/community.model';
|
||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||
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
|
||||
@@ -17,6 +21,23 @@ export class CommunityBreadcrumbResolver extends DSOBreadcrumbResolver<Community
|
||||
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
|
||||
* 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';
|
||||
breadcrumbUrl = '/collections/' + uuid;
|
||||
currentUrl = breadcrumbUrl + '/edit';
|
||||
testCollection = Object.assign(new Collection(), { uuid });
|
||||
testCollection = Object.assign(new Collection(), {
|
||||
uuid: uuid,
|
||||
type: 'collection',
|
||||
});
|
||||
dsoBreadcrumbService = {};
|
||||
collectionService = {
|
||||
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 { hasValue } from '../../shared/empty.util';
|
||||
import { IdentifiableDataService } from '../data/base/identifiable-data.service';
|
||||
import { getDSORoute } from '../../app-routing-paths';
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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(
|
||||
getFirstCompletedRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
map((object: T) => {
|
||||
if (hasValue(object)) {
|
||||
const fullPath = state.url;
|
||||
const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid;
|
||||
return { provider: this.breadcrumbService, key: object, url: url };
|
||||
return { provider: this.breadcrumbService, key: object, url: getDSORoute(object) };
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
|
@@ -781,6 +781,7 @@
|
||||
"chips.remove": "Remove chip",
|
||||
|
||||
|
||||
"collection.create.breadcrumbs": "Create collection",
|
||||
|
||||
"collection.create.head": "Create a Collection",
|
||||
|
||||
@@ -1053,6 +1054,8 @@
|
||||
|
||||
|
||||
|
||||
"community.create.breadcrumbs": "Create Community",
|
||||
|
||||
"community.create.head": "Create a Community",
|
||||
|
||||
"community.create.notifications.success": "Successfully created the Community",
|
||||
|
Reference in New Issue
Block a user