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_tutorial_1 = require('./current-tutorial');
|
14 | var step_utils_1 = require('./step-utils');
|
15 | var StepListComponent = (function () {
|
16 | function StepListComponent(utils, router, activated, parentRoute) {
|
17 | this.utils = utils;
|
18 | this.router = router;
|
19 | this.activated = activated;
|
20 | this.parentRoute = parentRoute;
|
21 | this.extraLinks = this.extraLinks || [];
|
22 | }
|
23 | StepListComponent.prototype.getStepLink = function (step) {
|
24 | if (this.prefix && this.prefix !== '') {
|
25 | return this.prefix + '/' + this.tutorialDetails.baseRoute + step.url;
|
26 | }
|
27 | else {
|
28 | return this.utils.createAbsoluteLink('..' + step.url, this.parentRoute.firstChild);
|
29 | }
|
30 | };
|
31 | StepListComponent.prototype.isCurrent = function (url) {
|
32 | return this.router.url === url;
|
33 | };
|
34 | StepListComponent.prototype.ngOnInit = function () {
|
35 | var _this = this;
|
36 | if (this.tutorialToDisplay) {
|
37 | Object.keys(this.tutorialToDisplay.versions).forEach(function (versionIdentifier) {
|
38 | var version = _this.tutorialToDisplay.versions[versionIdentifier];
|
39 | if (version.isLatest) {
|
40 | _this.allSteps = version.steps;
|
41 | }
|
42 | });
|
43 | this.tutorialDetails = this.tutorialToDisplay;
|
44 | }
|
45 | else {
|
46 | this.activated.tutorial.subscribe(function (tutorialToDisplay) {
|
47 | _this.tutorialDetails = tutorialToDisplay;
|
48 | });
|
49 | this.activated.steps.subscribe(function (allSteps) {
|
50 | _this.allSteps = allSteps;
|
51 | });
|
52 | }
|
53 | };
|
54 | __decorate([
|
55 | core_1.Optional(),
|
56 | core_1.Input('tutorial'),
|
57 | __metadata('design:type', Object)
|
58 | ], StepListComponent.prototype, "tutorialToDisplay", void 0);
|
59 | __decorate([
|
60 | core_1.Optional(),
|
61 | core_1.Input('prefix'),
|
62 | __metadata('design:type', String)
|
63 | ], StepListComponent.prototype, "prefix", void 0);
|
64 | __decorate([
|
65 | core_1.Optional(),
|
66 | core_1.Input('extraLinks'),
|
67 | __metadata('design:type', Array)
|
68 | ], StepListComponent.prototype, "extraLinks", void 0);
|
69 | StepListComponent = __decorate([
|
70 | core_1.Component({
|
71 | selector: 'steps-list',
|
72 | template: "\n<ul *ngIf=\"tutorialDetails\" class=\"tutorial-steps-list\">\n <li class=\"step-item\" *ngFor=\"let step of allSteps; let i = index;\" [ngClass]=\"{'active-step': isCurrent(getStepLink(step))}\">\n <a class=\"step-link\" [href]=\"getStepLink(step)\">{{i + 1}}. {{step.name}}</a>\n </li>\n <li class=\"step-item extra-item\" *ngFor=\"let extraLink of extraLinks;\">\n <a [className]=\"'step-link extra-link ' + (extraLink.bold ? 'bold' : '')\" [href]=\"extraLink.link || ''\">{{extraLink.name}}</a>\n </li>\n</ul>"
|
73 | }),
|
74 | core_1.Injectable(),
|
75 | __metadata('design:paramtypes', [step_utils_1.StepsUtils, router_1.Router, current_tutorial_1.ActivatedTutorial, router_1.ActivatedRoute])
|
76 | ], StepListComponent);
|
77 | return StepListComponent;
|
78 | }());
|
79 | exports.StepListComponent = StepListComponent;
|
80 |
|
\ | No newline at end of file |