62063: JSDocs and comments

This commit is contained in:
Kristof De Langhe
2019-04-30 17:24:58 +02:00
parent 41e55d8d44
commit 369a6dfaea
7 changed files with 48 additions and 0 deletions

View File

@@ -150,6 +150,12 @@ module.exports = {
fiveYearLimit: 30,
// The absolute lowest year to display in the dropdown (only used when no lowest date can be found for all items)
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: [
{
metadata: 'title',

View File

@@ -10,6 +10,10 @@ export const DEFAULT_BROWSE_BY_TYPE = BrowseByType.Metadata;
const map = new Map();
/**
* Decorator used for rendering Browse-By pages by type
* @param browseByType The type of page
*/
export function rendersBrowseBy(browseByType: BrowseByType) {
return function decorator(component: any) {
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) {
const comp = map.get(browseByType);
if (hasNoValue(comp)) {

View File

@@ -10,14 +10,23 @@ import { getComponentByBrowseByType } from './browse-by-decorator';
selector: 'ds-browse-by-switcher',
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 {
/**
* Resolved browse config
*/
browseByTypeConfig: Observable<BrowseByTypeConfig>;
public constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig,
protected route: ActivatedRoute) {
}
/**
* Fetch the correct browse config from environment.js
*/
ngOnInit(): void {
this.browseByTypeConfig = this.route.params.pipe(
map((params) => {
@@ -27,6 +36,9 @@ export class BrowseBySwitcherComponent implements OnInit {
);
}
/**
* Fetch the component depending on the browse type
*/
getComponent() {
return this.browseByTypeConfig.pipe(
map((config: BrowseByTypeConfig) => getComponentByBrowseByType(config.type))

View File

@@ -78,6 +78,7 @@ export class NavbarComponent extends MenuComponent implements OnInit {
index: 2
},
];
// Read the different Browse-By types from config and add them to the browse menu
const types = this.config.browseBy.types;
types.forEach((typeConfig) => {
menuList.push({

View File

@@ -16,6 +16,9 @@ export class ComcolPageBrowseByComponent implements OnInit {
*/
@Input() id: string;
/**
* List of currently active browse configurations
*/
types: BrowseByTypeConfig[];
constructor(@Inject(GLOBAL_CONFIG) public config: GlobalConfig) {

View File

@@ -20,5 +20,8 @@ export interface BrowseByConfig extends Config {
*/
defaultLowerLimit: number;
/**
* A list of all the active Browse-By pages
*/
types: BrowseByTypeConfig[];
}

View File

@@ -1,8 +1,23 @@
import { Config } from './config.interface';
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 {
/**
* The browse id used for fetching browse data from the rest api
* e.g. author
*/
metadata: string;
/**
* The type of Browse-By page to render
*/
type: BrowseByType;
/**
* The metadata field to use for rendering starts-with options (only necessary when type is set to BrowseByType.Date)
*/
metadataField: string;
}