1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | var __metadata = (this && this.__metadata) || function (k, v) {
|
9 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10 | };
|
11 | var core_1 = require('@angular/core');
|
12 | var router_1 = require('@angular/router');
|
13 | var current_api_1 = require('./current-api');
|
14 | var step_utils_1 = require('./step-utils');
|
15 | var ApiListItems = (function () {
|
16 | function ApiListItems(router, utils, activated, parentRoute) {
|
17 | this.router = router;
|
18 | this.utils = utils;
|
19 | this.activated = activated;
|
20 | this.parentRoute = parentRoute;
|
21 | }
|
22 | ApiListItems.prototype.createLink = function (api) {
|
23 | if (this.apiData.isStaticApi) {
|
24 | return this.utils.createAbsoluteLink(this.apiData.apiVersion.version + '/' + api.urlName, this.parentRoute);
|
25 | }
|
26 | else {
|
27 | return this.utils.createAbsoluteLink(this.apiData.apiVersion.name + '/' + api.apiTitle, this.parentRoute);
|
28 | }
|
29 | };
|
30 | ApiListItems.prototype.isCurrent = function (url) {
|
31 | return this.router.url === url;
|
32 | };
|
33 | ApiListItems.prototype.getFiles = function () {
|
34 | var _this = this;
|
35 | if (this.apiData.isStaticApi) {
|
36 | var staticData = this.apiData.apiVersion;
|
37 | return staticData.files.map(function (item) {
|
38 | return {
|
39 | apiTitle: item.name,
|
40 | urlName: item.urlName
|
41 | };
|
42 | });
|
43 | }
|
44 | else {
|
45 | return this.apiData.apiDefinition.files
|
46 | .filter(function (file) {
|
47 | return (_this.apiData.apiVersion.exclude || []).indexOf(file.apiTitle) === -1;
|
48 | });
|
49 | }
|
50 | };
|
51 | ApiListItems.prototype.ngOnInit = function () {
|
52 | var _this = this;
|
53 | this.activated.api.subscribe(function (data) {
|
54 | _this.apiData = data;
|
55 | });
|
56 | };
|
57 | ApiListItems = __decorate([
|
58 | core_1.Component({
|
59 | selector: 'api-list-items',
|
60 | template: "\n<ul *ngIf=\"apiData\" class=\"apis-list\">\n <li class=\"api-list-item\" *ngFor=\"let api of getFiles();\" [ngClass]=\"{'active-step': isCurrent(createLink(api))}\">\n <a class=\"api-item-link\" [href]=\"createLink(api)\">{{ api.apiTitle }}</a>\n </li>\n</ul>"
|
61 | }),
|
62 | core_1.Injectable(),
|
63 | __metadata('design:paramtypes', [router_1.Router, step_utils_1.StepsUtils, current_api_1.ActivatedApi, router_1.ActivatedRoute])
|
64 | ], ApiListItems);
|
65 | return ApiListItems;
|
66 | }());
|
67 | exports.ApiListItems = ApiListItems;
|
68 |
|
\ | No newline at end of file |