Update Method list to work with new menu structure

This commit is contained in:
Roman Hotsiy 2016-12-23 00:43:19 +02:00
parent ac0681c8a9
commit 398aa60a46
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 21 additions and 12 deletions

View File

@ -1,10 +1,11 @@
<div class="methods">
<div class="tag" *ngFor="let tag of tags;let catIdx = index; trackBy:trackByTagName">
<div class="tag-info" [attr.section]="tag.id" *ngIf="!tag.headless">
<div class="tag" *ngFor="let tag of tags; trackBy:trackByTagName" [attr.section]="tag.id">
<div class="tag-info" *ngIf="tag.name">
<h1 class="sharable-header"> <a class="share-link" href="#{{tag.id}}"></a>{{tag.name}} </h1>
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
</div>
<method *lazyFor="let method of tag.methods;let show = show;" [hidden]="!show" [pointer]="method.pointer" [attr.pointer]="method.pointer"
[attr.section]="method.tag" [tag]="method.tag" [attr.operation-id]="method.operationId"></method>
<method *lazyFor="let method of tag.items; let show = show;" [hidden]="!show"
[pointer]="method.metadata.pointer" [attr.section]="method.id"
[attr.operation-id]="method.metadata.operationId"></method>
</div>
</div>

View File

@ -19,15 +19,23 @@ export class MethodsList extends BaseComponent implements OnInit {
}
init() {
let tags = SchemaHelper.buildMenuTree(this.specMgr.schema);
this.tags = tags.filter(tagInfo => !tagInfo.virtual);
this.tags.forEach(tagInfo => {
// inject tag name into method info
tagInfo.methods = tagInfo.methods || [];
tagInfo.methods.forEach(method => {
method.tag = tagInfo.id;
});
let flatMenuItems = SchemaHelper.flatMenu(SchemaHelper.buildMenuTree(this.specMgr.schema));
this.tags = [];
let emptyTag = {
name: '',
items: []
}
flatMenuItems.forEach(menuItem => {
if (!menuItem.metadata) return;
if (menuItem.metadata.type === 'tag') {
this.tags.push(menuItem);
}
if (menuItem.metadata.type === 'method' && !menuItem.parent) {
emptyTag.items.push(menuItem);
}
});
if (emptyTag.items.length) this.tags.push(emptyTag);
}
trackByTagName(_, el) {