redoc/lib/components/MethodsList/methods-list.ts

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2015-10-08 23:21:51 +03:00
'use strict';
import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core';
2016-08-22 12:12:13 +03:00
import { BaseComponent, SpecManager } from '../base';
2016-12-25 15:24:58 +03:00
import { MenuService } from '../../services/index';
2015-10-08 23:21:51 +03:00
2016-08-22 12:12:13 +03:00
@Component({
2015-10-08 23:21:51 +03:00
selector: 'methods-list',
templateUrl: './methods-list.html',
styleUrls: ['./methods-list.css'],
changeDetection: ChangeDetectionStrategy.OnPush
2015-10-08 23:21:51 +03:00
})
2016-08-28 21:46:10 +03:00
export class MethodsList extends BaseComponent implements OnInit {
2016-08-22 12:12:13 +03:00
@Input() pointer:string;
tags:Array<any> = [];
2016-08-22 12:12:13 +03:00
2016-12-25 15:24:58 +03:00
constructor(specMgr:SpecManager, private menu: MenuService) {
super(specMgr);
2015-10-08 23:21:51 +03:00
}
init() {
2016-12-25 15:24:58 +03:00
let flatMenuItems = this.menu.flatItems;
this.tags = [];
let emptyTag = {
name: '',
items: []
2016-12-25 20:15:24 +03:00
};
flatMenuItems.forEach(menuItem => {
2016-12-25 15:24:58 +03:00
// skip items that are not bound to swagger tags/methods
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);
2015-10-08 23:21:51 +03:00
}
2016-06-30 16:42:36 +03:00
2016-12-02 12:59:29 +03:00
trackByTagName(_, el) {
2016-07-01 16:30:35 +03:00
return el.name;
}
2016-08-28 21:46:10 +03:00
ngOnInit() {
this.preinit();
}
2015-10-08 23:21:51 +03:00
}