mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 18:14:07 +03:00
Update Method list to work with new menu structure
This commit is contained in:
parent
ac0681c8a9
commit
398aa60a46
|
@ -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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user