2015-10-08 23:21:51 +03:00
|
|
|
'use strict';
|
2016-08-30 17:07:54 +03:00
|
|
|
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',
|
2016-05-25 18:34:31 +03:00
|
|
|
templateUrl: './methods-list.html',
|
2016-08-30 17:07:54 +03:00
|
|
|
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;
|
|
|
|
|
2016-07-21 13:35:27 +03:00
|
|
|
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) {
|
2016-06-23 17:36:38 +03:00
|
|
|
super(specMgr);
|
2015-10-08 23:21:51 +03:00
|
|
|
}
|
|
|
|
|
2016-07-20 11:07:08 +03:00
|
|
|
init() {
|
2016-12-25 15:24:58 +03:00
|
|
|
let flatMenuItems = this.menu.flatItems;
|
2016-12-23 01:43:19 +03:00
|
|
|
this.tags = [];
|
|
|
|
let emptyTag = {
|
|
|
|
name: '',
|
|
|
|
items: []
|
2016-12-25 20:15:24 +03:00
|
|
|
};
|
2016-12-23 01:43:19 +03:00
|
|
|
flatMenuItems.forEach(menuItem => {
|
2016-12-25 15:24:58 +03:00
|
|
|
// skip items that are not bound to swagger tags/methods
|
2016-12-23 01:43:19 +03:00
|
|
|
if (!menuItem.metadata) return;
|
|
|
|
|
|
|
|
if (menuItem.metadata.type === 'tag') {
|
|
|
|
this.tags.push(menuItem);
|
|
|
|
}
|
|
|
|
if (menuItem.metadata.type === 'method' && !menuItem.parent) {
|
|
|
|
emptyTag.items.push(menuItem);
|
|
|
|
}
|
2016-07-01 17:24:59 +03:00
|
|
|
});
|
2016-12-23 01:43:19 +03:00
|
|
|
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
|
|
|
}
|