inject options into MenuStore and allow activation of group items if configured

This commit is contained in:
Patrick Rodacker 2019-03-19 14:08:50 +01:00
parent 34c152c08a
commit 3d0db68b3b
2 changed files with 9 additions and 3 deletions

View File

@ -74,7 +74,7 @@ export class AppStore {
MenuStore.updateOnHistory(history.currentId, this.scroll);
this.spec = new SpecStore(spec, specUrl, this.options);
this.menu = new MenuStore(this.spec, this.scroll, history);
this.menu = new MenuStore(this.spec, this.scroll, history, this.options);
if (!this.options.disableSearch) {
this.search = new SearchStore();

View File

@ -7,6 +7,7 @@ import { ScrollService } from './ScrollService';
import { flattenByProp, SECURITY_SCHEMES_SECTION_PREFIX } from '../utils';
import { GROUP_DEPTH } from './MenuBuilder';
import { RedocNormalizedOptions } from "./RedocNormalizedOptions";
export type MenuItemGroupType = 'group' | 'tag' | 'section';
export type MenuItemType = MenuItemGroupType | 'operation';
@ -75,7 +76,12 @@ export class MenuStore {
* @param spec [SpecStore](#SpecStore) which contains page content structure
* @param scroll scroll service instance used by this menu
*/
constructor(spec: SpecStore, public scroll: ScrollService, public history: HistoryService) {
constructor(
spec: SpecStore,
public scroll: ScrollService,
public history: HistoryService,
public options: RedocNormalizedOptions
) {
this.items = spec.contentItems;
this.flatItems = flattenByProp(this.items || [], 'items');
@ -197,7 +203,7 @@ export class MenuStore {
// do not allow activating group items
// TODO: control over options
if (item.depth <= GROUP_DEPTH) {
if (item.depth <= GROUP_DEPTH && !this.options.collapseTagGroups) {
return;
}