Activate virtual and emtpy menu items

This commit is contained in:
Roman Hotsiy 2016-11-28 11:14:08 +02:00
parent 932b2c95c9
commit 833f98167a
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
3 changed files with 9 additions and 5 deletions

View File

@ -10,7 +10,7 @@
<div *ngFor="let cat of categories; let idx = index" class="menu-cat"> <div *ngFor="let cat of categories; let idx = index" class="menu-cat">
<label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [hidden]="cat.headless" <label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [hidden]="cat.headless"
[ngClass]="{active: cat.active, disabled: !cat.ready && cat.methods.length}"> {{cat.name}}</label> [ngClass]="{active: cat.active, disabled: !cat.ready }"> {{cat.name}}</label>
<ul class="menu-subitems" [@itemAnimation]="cat.active ? 'expanded' : 'collapsed'"> <ul class="menu-subitems" [@itemAnimation]="cat.active ? 'expanded' : 'collapsed'">
<li *ngFor="let method of cat.methods; trackBy:summary; let methIdx = index" <li *ngFor="let method of cat.methods; trackBy:summary; let methIdx = index"
[ngClass]="{active: method.active, disabled: !method.ready}" [ngClass]="{active: method.active, disabled: !method.ready}"

View File

@ -53,11 +53,16 @@ export class MenuService {
}); });
} }
enableItem(catIdx, methodIdx) { enableItem(catIdx, methodIdx, skipUpdate = false) {
let cat = this.categories[catIdx]; let cat = this.categories[catIdx];
cat.ready = true; cat.ready = true;
cat.methods[methodIdx].ready = true; if (cat.methods.length) cat.methods[methodIdx].ready = true;
let prevCat = this.categories[catIdx - 1];
if (prevCat && !prevCat.ready && (prevCat.virtual || !prevCat.methods.length)) {
this.enableItem(catIdx - 1, -1, true);
}
if (skipUpdate) return;
this.changed.next(); this.changed.next();
} }

View File

@ -306,7 +306,7 @@ export class SchemaHelper {
for (let header of (<Array<string>>(schema.info && schema.info['x-redoc-markdown-headers'] || []))) { for (let header of (<Array<string>>(schema.info && schema.info['x-redoc-markdown-headers'] || []))) {
let id = 'section/' + slugify(header); let id = 'section/' + slugify(header);
tag2MethodMapping[id] = { tag2MethodMapping[id] = {
name: header, id: id, virtual: true, ready: true, methods: [], idx: catIdx name: header, id: id, virtual: true, methods: [], idx: catIdx
}; };
catIdx++; catIdx++;
} }
@ -319,7 +319,6 @@ export class SchemaHelper {
description: tag.description, description: tag.description,
headless: tag.name === '', headless: tag.name === '',
empty: !!tag['x-traitTag'], empty: !!tag['x-traitTag'],
ready: !!tag['x-traitTag'],
methods: [], methods: [],
idx: catIdx idx: catIdx
}; };