62063: Configurable Browse-By menus

This commit is contained in:
Kristof De Langhe
2019-04-30 16:54:50 +02:00
parent 67e5578bba
commit 41e55d8d44
4 changed files with 37 additions and 54 deletions

View File

@@ -555,7 +555,7 @@
"control_panel": "Control Panel", "control_panel": "Control Panel",
"browse_global": "All of DSpace", "browse_global": "All of DSpace",
"browse_global_communities_and_collections": "Communities & Collections", "browse_global_communities_and_collections": "Communities & Collections",
"browse_global_by_issue_date": "By Issue Date", "browse_global_by_dateissued": "By Issue Date",
"browse_global_by_author": "By Author", "browse_global_by_author": "By Author",
"browse_global_by_title": "By Title", "browse_global_by_title": "By Title",
"browse_global_by_subject": "By Subject", "browse_global_by_subject": "By Subject",

View File

@@ -1,4 +1,4 @@
import { Component, Injector, OnInit } from '@angular/core'; import { Component, Inject, Injector, OnInit } from '@angular/core';
import { slideMobileNav } from '../shared/animations/slide'; import { slideMobileNav } from '../shared/animations/slide';
import { MenuComponent } from '../shared/menu/menu.component'; import { MenuComponent } from '../shared/menu/menu.component';
import { MenuService } from '../shared/menu/menu.service'; import { MenuService } from '../shared/menu/menu.service';
@@ -6,6 +6,7 @@ import { MenuID, MenuItemType } from '../shared/menu/initial-menus-state';
import { TextMenuItemModel } from '../shared/menu/menu-item/models/text.model'; import { TextMenuItemModel } from '../shared/menu/menu-item/models/text.model';
import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model'; import { LinkMenuItemModel } from '../shared/menu/menu-item/models/link.model';
import { HostWindowService } from '../shared/host-window.service'; import { HostWindowService } from '../shared/host-window.service';
import { GLOBAL_CONFIG, GlobalConfig } from '../../config';
/** /**
* Component representing the public navbar * Component representing the public navbar
@@ -23,7 +24,8 @@ export class NavbarComponent extends MenuComponent implements OnInit {
*/ */
menuID = MenuID.PUBLIC; menuID = MenuID.PUBLIC;
constructor(protected menuService: MenuService, constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
protected menuService: MenuService,
protected injector: Injector, protected injector: Injector,
public windowService: HostWindowService public windowService: HostWindowService
) { ) {
@@ -39,7 +41,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
* Initialize all menu sections and items for this menu * Initialize all menu sections and items for this menu
*/ */
createMenu() { createMenu() {
const menuList = [ const menuList: any[] = [
/* News */ /* News */
{ {
id: 'browse_global', id: 'browse_global',
@@ -62,50 +64,6 @@ export class NavbarComponent extends MenuComponent implements OnInit {
// link: '#' // link: '#'
// } as LinkMenuItemModel, // } as LinkMenuItemModel,
// }, // },
{
id: 'browse_global_global_by_title',
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: 'menu.section.browse_global_by_title',
link: '/browse/title'
} as LinkMenuItemModel,
},
{
id: 'browse_global_global_by_issue_date',
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: 'menu.section.browse_global_by_issue_date',
link: '/browse/dateissued'
} as LinkMenuItemModel,
},
{
id: 'browse_global_by_author',
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: 'menu.section.browse_global_by_author',
link: '/browse/author'
} as LinkMenuItemModel,
},
{
id: 'browse_global_by_subject',
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: 'menu.section.browse_global_by_subject',
link: '/browse/subject'
} as LinkMenuItemModel,
},
/* Statistics */ /* Statistics */
{ {
@@ -120,6 +78,20 @@ export class NavbarComponent extends MenuComponent implements OnInit {
index: 2 index: 2
}, },
]; ];
const types = this.config.browseBy.types;
types.forEach((typeConfig) => {
menuList.push({
id: `browse_global_by_${typeConfig.metadata}`,
parentID: 'browse_global',
active: false,
visible: true,
model: {
type: MenuItemType.LINK,
text: `menu.section.browse_global_by_${typeConfig.metadata}`,
link: `/browse/${typeConfig.metadata}`
} as LinkMenuItemModel
});
});
menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection)); menuList.forEach((menuSection) => this.menuService.addSection(this.menuID, menuSection));
} }

View File

@@ -1,7 +1,6 @@
<h3>{{'browse.comcol.head' | translate}}</h3> <h3>{{'browse.comcol.head' | translate}}</h3>
<ul> <ul>
<li><a [routerLink]="['/browse/title']" [queryParams]="{scope: id}">{{'browse.comcol.by.title' | translate}}</a></li> <li *ngFor="let config of types">
<li><a [routerLink]="['/browse/dateissued']" [queryParams]="{scope: id}">{{'browse.comcol.by.dateissued' | translate}}</a></li> <a [routerLink]="['/browse/' + config.metadata]" [queryParams]="{scope: id}">{{'browse.comcol.by.' + config.metadata | translate}}</a>
<li><a [routerLink]="['/browse/author']" [queryParams]="{scope: id}">{{'browse.comcol.by.author' | translate}}</a></li> </li>
<li><a [routerLink]="['/browse/subject']" [queryParams]="{scope: id}">{{'browse.comcol.by.subject' | translate}}</a></li>
</ul> </ul>

View File

@@ -1,4 +1,6 @@
import { Component, Input } from '@angular/core'; import { Component, Inject, Input, OnInit } from '@angular/core';
import { GLOBAL_CONFIG, GlobalConfig } from '../../../config';
import { BrowseByTypeConfig } from '../../../config/browse-by-type-config.interface';
/** /**
* A component to display the "Browse By" section of a Community or Collection page * A component to display the "Browse By" section of a Community or Collection page
@@ -8,9 +10,19 @@ import { Component, Input } from '@angular/core';
selector: 'ds-comcol-page-browse-by', selector: 'ds-comcol-page-browse-by',
templateUrl: './comcol-page-browse-by.component.html', templateUrl: './comcol-page-browse-by.component.html',
}) })
export class ComcolPageBrowseByComponent { export class ComcolPageBrowseByComponent implements OnInit {
/** /**
* The ID of the Community or Collection * The ID of the Community or Collection
*/ */
@Input() id: string; @Input() id: string;
types: BrowseByTypeConfig[];
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) {
}
ngOnInit(): void {
this.types = this.config.browseBy.types;
}
} }