2015-10-08 23:21:51 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-05-09 22:55:16 +03:00
|
|
|
import { forwardRef } from '@angular/core';
|
2016-06-22 21:17:48 +03:00
|
|
|
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
2016-05-09 22:55:16 +03:00
|
|
|
import { Method } from '../Method/method';
|
2016-05-06 00:48:41 +03:00
|
|
|
import { EncodeURIComponentPipe } from '../../utils/pipes';
|
2016-07-01 17:24:59 +03:00
|
|
|
import { SchemaHelper } from '../../services/index';
|
2015-10-08 23:21:51 +03:00
|
|
|
|
2015-10-09 23:19:35 +03:00
|
|
|
@RedocComponent({
|
2015-10-08 23:21:51 +03:00
|
|
|
selector: 'methods-list',
|
2016-05-25 18:34:31 +03:00
|
|
|
templateUrl: './methods-list.html',
|
|
|
|
styleUrls: ['./methods-list.css'],
|
2016-05-09 22:55:16 +03:00
|
|
|
directives: [ forwardRef(() => Method) ],
|
2016-05-18 16:59:54 +03:00
|
|
|
pipes: [ EncodeURIComponentPipe ],
|
|
|
|
detect: true
|
2015-10-08 23:21:51 +03:00
|
|
|
})
|
2016-05-06 00:48:41 +03:00
|
|
|
export class MethodsList extends BaseComponent {
|
2016-05-25 18:34:31 +03:00
|
|
|
data:any;
|
2016-06-23 17:36:38 +03:00
|
|
|
constructor(specMgr:SpecManager) {
|
|
|
|
super(specMgr);
|
2015-10-08 23:21:51 +03:00
|
|
|
}
|
|
|
|
|
2015-10-09 23:19:35 +03:00
|
|
|
prepareModel() {
|
2015-10-08 23:21:51 +03:00
|
|
|
this.data = {};
|
2015-10-18 19:32:11 +03:00
|
|
|
// follow SwaggerUI behavior for cases when one method has more than one tag:
|
|
|
|
// duplicate methods
|
2015-10-08 23:21:51 +03:00
|
|
|
|
2016-07-01 17:24:59 +03:00
|
|
|
let tags = SchemaHelper.buildMenuTree(this.specMgr.schema);
|
|
|
|
tags.forEach(tagInfo => {
|
|
|
|
// inject tag name into method info
|
|
|
|
tagInfo.methods = tagInfo.methods || [];
|
|
|
|
tagInfo.methods.forEach(method => {
|
|
|
|
method.tag = name;
|
2015-10-29 00:22:12 +03:00
|
|
|
});
|
2016-07-01 17:24:59 +03:00
|
|
|
});
|
2015-10-29 00:22:12 +03:00
|
|
|
this.data.tags = tags;
|
2015-10-10 15:34:46 +03:00
|
|
|
// TODO: check $ref field
|
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;
|
|
|
|
}
|
2015-10-08 23:21:51 +03:00
|
|
|
}
|