mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 20:13:07 +00:00
62063: JSDocs and comments
This commit is contained in:
@@ -150,6 +150,12 @@ module.exports = {
|
|||||||
fiveYearLimit: 30,
|
fiveYearLimit: 30,
|
||||||
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
|
||||||
defaultLowerLimit: 1900,
|
defaultLowerLimit: 1900,
|
||||||
|
// List of all the active Browse-By types
|
||||||
|
// Adding a type will activate their Browse-By page and add them to the global navigation menu, as well as community and collection pages
|
||||||
|
// Allowed fields and their purpose:
|
||||||
|
// metadata: The browse id to use for fetching info from the rest api
|
||||||
|
// type: The type of Browse-By page to display
|
||||||
|
// metadataField: The metadata-field used to create starts-with options (only necessary when the type is set to 'date')
|
||||||
types: [
|
types: [
|
||||||
{
|
{
|
||||||
metadata: 'title',
|
metadata: 'title',
|
||||||
|
@@ -10,6 +10,10 @@ export const DEFAULT_BROWSE_BY_TYPE = BrowseByType.Metadata;
|
|||||||
|
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorator used for rendering Browse-By pages by type
|
||||||
|
* @param browseByType The type of page
|
||||||
|
*/
|
||||||
export function rendersBrowseBy(browseByType: BrowseByType) {
|
export function rendersBrowseBy(browseByType: BrowseByType) {
|
||||||
return function decorator(component: any) {
|
return function decorator(component: any) {
|
||||||
if (hasNoValue(map.get(browseByType))) {
|
if (hasNoValue(map.get(browseByType))) {
|
||||||
@@ -20,6 +24,10 @@ export function rendersBrowseBy(browseByType: BrowseByType) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the component used for rendering a Browse-By page by type
|
||||||
|
* @param browseByType The type of page
|
||||||
|
*/
|
||||||
export function getComponentByBrowseByType(browseByType) {
|
export function getComponentByBrowseByType(browseByType) {
|
||||||
const comp = map.get(browseByType);
|
const comp = map.get(browseByType);
|
||||||
if (hasNoValue(comp)) {
|
if (hasNoValue(comp)) {
|
||||||
|
@@ -10,14 +10,23 @@ import { getComponentByBrowseByType } from './browse-by-decorator';
|
|||||||
selector: 'ds-browse-by-switcher',
|
selector: 'ds-browse-by-switcher',
|
||||||
templateUrl: './browse-by-switcher.component.html'
|
templateUrl: './browse-by-switcher.component.html'
|
||||||
})
|
})
|
||||||
|
/**
|
||||||
|
* Component for determining what Browse-By component to use depending on the metadata (browse ID) provided
|
||||||
|
*/
|
||||||
export class BrowseBySwitcherComponent implements OnInit {
|
export class BrowseBySwitcherComponent implements OnInit {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolved browse config
|
||||||
|
*/
|
||||||
browseByTypeConfig: Observable<BrowseByTypeConfig>;
|
browseByTypeConfig: Observable<BrowseByTypeConfig>;
|
||||||
|
|
||||||
public constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
public constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
|
||||||
protected route: ActivatedRoute) {
|
protected route: ActivatedRoute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the correct browse config from environment.js
|
||||||
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.browseByTypeConfig = this.route.params.pipe(
|
this.browseByTypeConfig = this.route.params.pipe(
|
||||||
map((params) => {
|
map((params) => {
|
||||||
@@ -27,6 +36,9 @@ export class BrowseBySwitcherComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the component depending on the browse type
|
||||||
|
*/
|
||||||
getComponent() {
|
getComponent() {
|
||||||
return this.browseByTypeConfig.pipe(
|
return this.browseByTypeConfig.pipe(
|
||||||
map((config: BrowseByTypeConfig) => getComponentByBrowseByType(config.type))
|
map((config: BrowseByTypeConfig) => getComponentByBrowseByType(config.type))
|
||||||
|
@@ -78,6 +78,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
|
|||||||
index: 2
|
index: 2
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
// Read the different Browse-By types from config and add them to the browse menu
|
||||||
const types = this.config.browseBy.types;
|
const types = this.config.browseBy.types;
|
||||||
types.forEach((typeConfig) => {
|
types.forEach((typeConfig) => {
|
||||||
menuList.push({
|
menuList.push({
|
||||||
|
@@ -16,6 +16,9 @@ export class ComcolPageBrowseByComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() id: string;
|
@Input() id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of currently active browse configurations
|
||||||
|
*/
|
||||||
types: BrowseByTypeConfig[];
|
types: BrowseByTypeConfig[];
|
||||||
|
|
||||||
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) {
|
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) {
|
||||||
|
@@ -20,5 +20,8 @@ export interface BrowseByConfig extends Config {
|
|||||||
*/
|
*/
|
||||||
defaultLowerLimit: number;
|
defaultLowerLimit: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of all the active Browse-By pages
|
||||||
|
*/
|
||||||
types: BrowseByTypeConfig[];
|
types: BrowseByTypeConfig[];
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,23 @@
|
|||||||
import { Config } from './config.interface';
|
import { Config } from './config.interface';
|
||||||
import { BrowseByType } from '../app/+browse-by/+browse-by-switcher/browse-by-decorator';
|
import { BrowseByType } from '../app/+browse-by/+browse-by-switcher/browse-by-decorator';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config used for rendering Browse-By pages and links
|
||||||
|
*/
|
||||||
export interface BrowseByTypeConfig extends Config {
|
export interface BrowseByTypeConfig extends Config {
|
||||||
|
/**
|
||||||
|
* The browse id used for fetching browse data from the rest api
|
||||||
|
* e.g. author
|
||||||
|
*/
|
||||||
metadata: string;
|
metadata: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of Browse-By page to render
|
||||||
|
*/
|
||||||
type: BrowseByType;
|
type: BrowseByType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The metadata field to use for rendering starts-with options (only necessary when type is set to BrowseByType.Date)
|
||||||
|
*/
|
||||||
metadataField: string;
|
metadataField: string;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user