mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-08 06:04:56 +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);
|
MenuStore.updateOnHistory(history.currentId, this.scroll);
|
||||||
|
|
||||||
this.spec = new SpecStore(spec, specUrl, this.options);
|
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) {
|
if (!this.options.disableSearch) {
|
||||||
this.search = new SearchStore();
|
this.search = new SearchStore();
|
||||||
|
|
|
@ -8,9 +8,12 @@ import { ScrollService } from './ScrollService';
|
||||||
import { flattenByProp, SECURITY_SCHEMES_SECTION_PREFIX } from '../utils';
|
import { flattenByProp, SECURITY_SCHEMES_SECTION_PREFIX } from '../utils';
|
||||||
import { GROUP_DEPTH } from './MenuBuilder';
|
import { GROUP_DEPTH } from './MenuBuilder';
|
||||||
|
|
||||||
|
import {RedocNormalizedOptions} from "./RedocNormalizedOptions";
|
||||||
|
|
||||||
export type MenuItemGroupType = 'group' | 'tag' | 'section';
|
export type MenuItemGroupType = 'group' | 'tag' | 'section';
|
||||||
export type MenuItemType = MenuItemGroupType | 'operation';
|
export type MenuItemType = MenuItemGroupType | 'operation';
|
||||||
|
|
||||||
|
|
||||||
/** Generic interface for MenuItems */
|
/** Generic interface for MenuItems */
|
||||||
export interface IMenuItem {
|
export interface IMenuItem {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -74,11 +77,21 @@ export class MenuStore {
|
||||||
*
|
*
|
||||||
* @param spec [SpecStore](#SpecStore) which contains page content structure
|
* @param spec [SpecStore](#SpecStore) which contains page content structure
|
||||||
* @param scroll scroll service instance used by this menu
|
* @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.items = spec.contentItems;
|
||||||
|
|
||||||
this.flatItems = flattenByProp(this.items || [], 'items');
|
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.flatItems.forEach((item, idx) => (item.absoluteIdx = idx));
|
||||||
|
|
||||||
this.subscribe();
|
this.subscribe();
|
||||||
|
|
|
@ -11,6 +11,7 @@ export interface RedocRawOptions {
|
||||||
hideHostname?: boolean | string;
|
hideHostname?: boolean | string;
|
||||||
expandResponses?: string | 'all';
|
expandResponses?: string | 'all';
|
||||||
requiredPropsFirst?: boolean | string;
|
requiredPropsFirst?: boolean | string;
|
||||||
|
sortNavigationTags?: boolean | string;
|
||||||
sortPropsAlphabetically?: boolean | string;
|
sortPropsAlphabetically?: boolean | string;
|
||||||
sortEnumValuesAlphabetically?: boolean | string;
|
sortEnumValuesAlphabetically?: boolean | string;
|
||||||
noAutoAuth?: boolean | string;
|
noAutoAuth?: boolean | string;
|
||||||
|
@ -165,6 +166,7 @@ export class RedocNormalizedOptions {
|
||||||
hideHostname: boolean;
|
hideHostname: boolean;
|
||||||
expandResponses: { [code: string]: boolean } | 'all';
|
expandResponses: { [code: string]: boolean } | 'all';
|
||||||
requiredPropsFirst: boolean;
|
requiredPropsFirst: boolean;
|
||||||
|
sortNavigationTags: boolean;
|
||||||
sortPropsAlphabetically: boolean;
|
sortPropsAlphabetically: boolean;
|
||||||
sortEnumValuesAlphabetically: boolean;
|
sortEnumValuesAlphabetically: boolean;
|
||||||
noAutoAuth: boolean;
|
noAutoAuth: boolean;
|
||||||
|
@ -220,6 +222,7 @@ export class RedocNormalizedOptions {
|
||||||
this.requiredPropsFirst = argValueToBoolean(raw.requiredPropsFirst);
|
this.requiredPropsFirst = argValueToBoolean(raw.requiredPropsFirst);
|
||||||
this.sortPropsAlphabetically = argValueToBoolean(raw.sortPropsAlphabetically);
|
this.sortPropsAlphabetically = argValueToBoolean(raw.sortPropsAlphabetically);
|
||||||
this.sortEnumValuesAlphabetically = argValueToBoolean(raw.sortEnumValuesAlphabetically);
|
this.sortEnumValuesAlphabetically = argValueToBoolean(raw.sortEnumValuesAlphabetically);
|
||||||
|
this.sortNavigationTags = argValueToBoolean(raw.sortNavigationTags);
|
||||||
this.noAutoAuth = argValueToBoolean(raw.noAutoAuth);
|
this.noAutoAuth = argValueToBoolean(raw.noAutoAuth);
|
||||||
this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars);
|
this.nativeScrollbars = argValueToBoolean(raw.nativeScrollbars);
|
||||||
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
this.pathInMiddlePanel = argValueToBoolean(raw.pathInMiddlePanel);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user