From 398aa60a46e086d4a676ed7bc76c19759c60167b Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 23 Dec 2016 00:43:19 +0200 Subject: [PATCH] Update Method list to work with new menu structure --- lib/components/MethodsList/methods-list.html | 9 ++++---- lib/components/MethodsList/methods-list.ts | 24 +++++++++++++------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 61caa17f..f80a471d 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,10 +1,11 @@
-
-
+
+

{{tag.name}}

- +
diff --git a/lib/components/MethodsList/methods-list.ts b/lib/components/MethodsList/methods-list.ts index ec130328..3db51eb8 100644 --- a/lib/components/MethodsList/methods-list.ts +++ b/lib/components/MethodsList/methods-list.ts @@ -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) {