diff --git a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts index 22cb1f5825..8b71bca423 100644 --- a/src/app/+admin/admin-sidebar/admin-sidebar.component.ts +++ b/src/app/+admin/admin-sidebar/admin-sidebar.component.ts @@ -12,9 +12,12 @@ import { first, map } from 'rxjs/operators'; import { combineLatest as combineLatestObservable } from 'rxjs'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { OnClickMenuItemModel } from '../../shared/menu/menu-item/models/onclick.model'; -import { CollectionSelectorModalWrapperComponent } from '../../shared/dso-selector/collection-selector-modal-wrapper/collection-selector-modal-wrapper.component'; -import { ItemSelectorModalWrapperComponent } from '../../shared/dso-selector/item-selector-modal-wrapper/item-selector-modal-wrapper.component'; -import { CommunitySelectorModalWrapperComponent } from '../../shared/dso-selector/community-selector-modal-wrapper/community-selector-modal-wrapper.component'; +import { CreateCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component'; +import { CreateItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component'; +import { CreateCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component'; +import { EditCollectionParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-collection-parent-selector/edit-collection-parent-selector.component'; +import { EditItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-item-parent-selector/edit-item-parent-selector.component'; +import { EditCommunityParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/edit-community-parent-selector/edit-community-parent-selector.component'; /** * Component representing the admin sidebar @@ -113,7 +116,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { type: MenuItemType.ONCLICK, text: 'menu.section.new_community', function: () => { - this.modalService.open(CommunitySelectorModalWrapperComponent); + this.modalService.open(CreateCommunityParentSelectorComponent); } } as OnClickMenuItemModel, }, @@ -126,7 +129,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { type: MenuItemType.ONCLICK, text: 'menu.section.new_collection', function: () => { - this.modalService.open(CollectionSelectorModalWrapperComponent); + this.modalService.open(CreateCollectionParentSelectorComponent); } } as OnClickMenuItemModel, }, @@ -139,7 +142,7 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { type: MenuItemType.ONCLICK, text: 'menu.section.new_item', function: () => { - this.modalService.open(ItemSelectorModalWrapperComponent); + this.modalService.open(CreateItemParentSelectorComponent); } } as OnClickMenuItemModel, }, @@ -173,10 +176,12 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { active: false, visible: true, model: { - type: MenuItemType.LINK, + type: MenuItemType.ONCLICK, text: 'menu.section.edit_community', - link: '#' - } as LinkMenuItemModel, + function: () => { + this.modalService.open(EditCommunityParentSelectorComponent); + } + } as OnClickMenuItemModel, }, { id: 'edit_collection', @@ -184,10 +189,12 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { active: false, visible: true, model: { - type: MenuItemType.LINK, + type: MenuItemType.ONCLICK, text: 'menu.section.edit_collection', - link: '#' - } as LinkMenuItemModel, + function: () => { + this.modalService.open(EditCollectionParentSelectorComponent); + } + } as OnClickMenuItemModel, }, { id: 'edit_item', @@ -195,10 +202,12 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { active: false, visible: true, model: { - type: MenuItemType.LINK, + type: MenuItemType.ONCLICK, text: 'menu.section.edit_item', - link: '#' - } as LinkMenuItemModel, + function: () => { + this.modalService.open(EditItemParentSelectorComponent); + } + } as OnClickMenuItemModel, }, /* Import */ @@ -235,7 +244,6 @@ export class AdminSidebarComponent extends MenuComponent implements OnInit { link: '#' } as LinkMenuItemModel, }, - /* Export */ { id: 'export', diff --git a/src/app/+collection-page/collection-page-routing.module.ts b/src/app/+collection-page/collection-page-routing.module.ts index ddcf36a0cc..cdbd7650b2 100644 --- a/src/app/+collection-page/collection-page-routing.module.ts +++ b/src/app/+collection-page/collection-page-routing.module.ts @@ -8,17 +8,36 @@ import { AuthenticatedGuard } from '../core/auth/authenticated.guard'; import { EditCollectionPageComponent } from './edit-collection-page/edit-collection-page.component'; import { CreateCollectionPageGuard } from './create-collection-page/create-collection-page.guard'; import { DeleteCollectionPageComponent } from './delete-collection-page/delete-collection-page.component'; +import { URLCombiner } from '../core/url-combiner/url-combiner'; +import { getCollectionModulePath } from '../app-routing.module'; + +export const COLLECTION_PARENT_PARAMETER = 'parent'; + +export function getCollectionPageRoute(collectionId: string) { + return new URLCombiner(getCollectionModulePath(), collectionId).toString(); +} + +export function getCollectionEditPath(id: string) { + return new URLCombiner(getCollectionModulePath(), COLLECTION_EDIT_PATH.replace(/:id/, id)).toString() +} + +export function getCollectionCreatePath() { + return new URLCombiner(getCollectionModulePath(), COLLECTION_CREATE_PATH).toString() +} + +const COLLECTION_CREATE_PATH = 'create'; +const COLLECTION_EDIT_PATH = ':id/edit'; @NgModule({ imports: [ RouterModule.forChild([ { - path: 'create', + path: COLLECTION_CREATE_PATH, component: CreateCollectionPageComponent, canActivate: [AuthenticatedGuard, CreateCollectionPageGuard] }, { - path: ':id/edit', + path: COLLECTION_EDIT_PATH, pathMatch: 'full', component: EditCollectionPageComponent, canActivate: [AuthenticatedGuard], diff --git a/src/app/+community-page/community-page-routing.module.ts b/src/app/+community-page/community-page-routing.module.ts index 02f28f6375..cecd17ec10 100644 --- a/src/app/+community-page/community-page-routing.module.ts +++ b/src/app/+community-page/community-page-routing.module.ts @@ -8,17 +8,36 @@ import { AuthenticatedGuard } from '../core/auth/authenticated.guard'; import { EditCommunityPageComponent } from './edit-community-page/edit-community-page.component'; import { CreateCommunityPageGuard } from './create-community-page/create-community-page.guard'; import { DeleteCommunityPageComponent } from './delete-community-page/delete-community-page.component'; +import { URLCombiner } from '../core/url-combiner/url-combiner'; +import { getCommunityModulePath } from '../app-routing.module'; + +export const COMMUNITY_PARENT_PARAMETER = 'parent'; + +export function getCommunityPageRoute(communityId: string) { + return new URLCombiner(getCommunityModulePath(), communityId).toString(); +} + +export function getCommunityEditPath(id: string) { + return new URLCombiner(getCommunityModulePath(), COMMUNITY_EDIT_PATH.replace(/:id/, id)).toString() +} + +export function getCommunityCreatePath() { + return new URLCombiner(getCommunityModulePath(), COMMUNITY_CREATE_PATH).toString() +} + +const COMMUNITY_CREATE_PATH = 'create'; +const COMMUNITY_EDIT_PATH = ':id/edit'; @NgModule({ imports: [ RouterModule.forChild([ { - path: 'create', + path: COMMUNITY_CREATE_PATH, component: CreateCommunityPageComponent, canActivate: [AuthenticatedGuard, CreateCommunityPageGuard] }, { - path: ':id/edit', + path: COMMUNITY_EDIT_PATH, pathMatch: 'full', component: EditCommunityPageComponent, canActivate: [AuthenticatedGuard], diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 1476aa5dad..1448601067 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -8,13 +8,21 @@ const ITEM_MODULE_PATH = 'items'; export function getItemModulePath() { return `/${ITEM_MODULE_PATH}`; } +const COLLECTION_MODULE_PATH = 'collections'; +export function getCollectionModulePath() { + return `/${COLLECTION_MODULE_PATH}`; +} +const COMMUNITY_MODULE_PATH = 'communities'; +export function getCommunityModulePath() { + return `/${COMMUNITY_MODULE_PATH}`; +} @NgModule({ imports: [ RouterModule.forRoot([ { path: '', redirectTo: '/home', pathMatch: 'full' }, { path: 'home', loadChildren: './+home-page/home-page.module#HomePageModule' }, - { path: 'communities', loadChildren: './+community-page/community-page.module#CommunityPageModule' }, - { path: 'collections', loadChildren: './+collection-page/collection-page.module#CollectionPageModule' }, + { path: COMMUNITY_MODULE_PATH, loadChildren: './+community-page/community-page.module#CommunityPageModule' }, + { path: COLLECTION_MODULE_PATH, loadChildren: './+collection-page/collection-page.module#CollectionPageModule' }, { path: ITEM_MODULE_PATH, loadChildren: './+item-page/item-page.module#ItemPageModule' }, { path: 'search', loadChildren: './+search-page/search-page.module#SearchPageModule' }, { path: 'browse', loadChildren: './+browse-by/browse-by.module#BrowseByModule' }, diff --git a/src/app/shared/dso-selector/collection-selector-modal-wrapper/collection-selector-modal-wrapper.component.html b/src/app/shared/dso-selector/collection-selector-modal-wrapper/collection-selector-modal-wrapper.component.html deleted file mode 100644 index f3bf405651..0000000000 --- a/src/app/shared/dso-selector/collection-selector-modal-wrapper/collection-selector-modal-wrapper.component.html +++ /dev/null @@ -1,6 +0,0 @@ -