mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
Added sort navigation tag
This commit is contained in:
parent
676faa943a
commit
324f8b8df0
|
@ -81,7 +81,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();
|
||||
|
|
|
@ -8,9 +8,12 @@ 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';
|
||||
|
||||
|
||||
/** Generic interface for MenuItems */
|
||||
export interface IMenuItem {
|
||||
id: string;
|
||||
|
@ -74,11 +77,21 @@ export class MenuStore {
|
|||
*
|
||||
* @param spec [SpecStore](#SpecStore) which contains page content structure
|
||||
* @param scroll scroll service instance used by this menu
|
||||
* @param history
|
||||
* @param options
|
||||
*/
|
||||
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');
|
||||
if (this.options.sortNavigationTags) {
|
||||
this.flatItems.map((item) => {
|
||||
if (item.type === "tag") {
|
||||
item.items.sort((a, b) => (a.name > b.name) ? 1 : -1)
|
||||
}
|
||||
});
|
||||
this.flatItems = flattenByProp(this.items || [], 'items');
|
||||
}
|
||||
|
||||
this.flatItems.forEach((item, idx) => (item.absoluteIdx = idx));
|
||||
|
||||
this.subscribe();
|
||||
|
|
|
@ -11,6 +11,7 @@ export interface RedocRawOptions {
|
|||
hideHostname?: boolean | string;
|
||||
expandResponses?: string | 'all';
|
||||
requiredPropsFirst?: boolean | string;
|
||||
sortNavigationTags?: boolean | string;
|
||||
sortPropsAlphabetically?: boolean | string;
|
||||
sortEnumValuesAlphabetically?: boolean | string;
|
||||
noAutoAuth?: boolean | string;
|
||||
|
@ -165,6 +166,7 @@ export class RedocNormalizedOptions {
|
|||
hideHostname: boolean;
|
||||
expandResponses: { [code: string]: boolean } | 'all';
|
||||
requiredPropsFirst: boolean;
|
||||
sortNavigationTags: boolean;
|
||||
sortPropsAlphabetically: boolean;
|
||||
sortEnumValuesAlphabetically: boolean;
|
||||
noAutoAuth: boolean;
|
||||
|
@ -220,6 +222,7 @@ export class RedocNormalizedOptions {
|
|||
this.requiredPropsFirst = argValueToBoolean(raw.requiredPropsFirst);
|
||||
this.sortPropsAlphabetically = argValueToBoolean(raw.sortPropsAlphabetically);
|
||||
this.sortEnumValuesAlphabetically = argValueToBoolean(raw.sortEnumValuesAlphabetically);
|
||||
this.sortNavigationTags = argValueToBoolean(raw.sortNavigationTags);
|
||||
this.noAutoAuth = argValueToBoolean(raw.noAutoAuth);
|
||||
this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars);
|
||||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||
|
|
Loading…
Reference in New Issue
Block a user