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

45 lines
1.0 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';
import { SchemaHelper } 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
constructor(specMgr:SpecManager) {
super(specMgr);
2015-10-08 23:21:51 +03:00
}
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 => {
2016-07-26 12:03:15 +03:00
method.tag = tagInfo.id;
});
});
2015-10-08 23:21:51 +03:00
}
2016-06-30 16:42:36 +03:00
trackByPointer(idx, el) {
return el.pointer;
}
2016-07-01 16:30:35 +03:00
trackByTagName(idx, el) {
return el.name;
}
2016-08-28 21:46:10 +03:00
ngOnInit() {
this.preinit();
}
2015-10-08 23:21:51 +03:00
}