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">
<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'">
<li *ngFor="let method of cat.methods; trackBy:summary; let methIdx = index"
[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];
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();
}

View File

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