1
|
/**
|
2
|
* Created by stefania on 7/17/17.
|
3
|
*/
|
4
|
import {Component, Input, OnInit} from "@angular/core";
|
5
|
import {ActivatedRoute, Router} from "@angular/router";
|
6
|
import {HelpContentService} from "../../services/help-content.service";
|
7
|
import {Content, PageContent} from "../../domain/page-content";
|
8
|
|
9
|
@Component({
|
10
|
selector: 'help-content',
|
11
|
template: `
|
12
|
<template [ngIf]="contents && contents.length>0">
|
13
|
<template ngFor let-content [ngForOf]="contents">
|
14
|
<div [innerHTML]="content.content" class="uk-margin-medium-bottom"></div>
|
15
|
</template>
|
16
|
</template>
|
17
|
`,
|
18
|
})
|
19
|
|
20
|
export class HelpContentComponent implements OnInit {
|
21
|
|
22
|
@Input('position')
|
23
|
position: string;
|
24
|
|
25
|
contents: Content[];
|
26
|
errorMessage: string = null;
|
27
|
|
28
|
constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) {
|
29
|
}
|
30
|
|
31
|
ngOnInit() {
|
32
|
|
33
|
this.errorMessage = null;
|
34
|
|
35
|
this._helpContentService.getActivePageContent(this.router.url).subscribe(
|
36
|
pageContent => this.shiftThroughContent(pageContent),
|
37
|
error => this.handleError(<any>error));
|
38
|
}
|
39
|
|
40
|
shiftThroughContent(pageContent: PageContent) {
|
41
|
this.contents = pageContent.content[this.position];
|
42
|
}
|
43
|
|
44
|
isPresent() {
|
45
|
return (this.contents && this.contents.length > 0);
|
46
|
}
|
47
|
|
48
|
handleError(error) {
|
49
|
this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')';
|
50
|
}
|
51
|
}
|
52
|
|
53
|
@Component({
|
54
|
selector: 'aside-help-content',
|
55
|
template: `
|
56
|
<template [ngIf]="contents && contents.length>0">
|
57
|
<template ngFor let-content [ngForOf]="contents">
|
58
|
<div [innerHTML]="content.content" class="uk-card uk-card-body uk-card-default sidemenu uk-margin-bottom"></div>
|
59
|
</template>
|
60
|
</template>
|
61
|
`,
|
62
|
})
|
63
|
export class AsideHelpContentComponent extends HelpContentComponent {
|
64
|
|
65
|
}
|