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

View File

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