2018-05-28 11:50:42 +02:00
|
|
|
/**
|
|
|
|
* Created by stefania on 7/17/17.
|
|
|
|
*/
|
2018-11-27 18:33:17 +01:00
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute, NavigationStart, Router } from '@angular/router';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { PageHelpContent } from '@app/core/model/help-content/page-help-content';
|
|
|
|
import { HelpContentService } from '@app/core/services/help-content/help-content.service';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2018-11-27 18:33:17 +01:00
|
|
|
import { takeUntil } from 'rxjs/operators';
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2018-05-28 11:50:42 +02:00
|
|
|
@Component({
|
2018-10-05 17:00:54 +02:00
|
|
|
selector: 'app-help-content',
|
|
|
|
template: `
|
2018-05-28 11:50:42 +02:00
|
|
|
<ng-template [ngIf]="contents && contents.length>0">
|
|
|
|
<ng-template ngFor let-content [ngForOf]="contents">
|
|
|
|
<div [innerHTML]="content.content" class="uk-margin-medium-bottom"></div>
|
|
|
|
</ng-template>
|
|
|
|
</ng-template>
|
|
|
|
`,
|
|
|
|
})
|
2018-11-27 18:33:17 +01:00
|
|
|
export class HelpContentComponent extends BaseComponent implements OnInit {
|
2018-10-05 17:00:54 +02:00
|
|
|
@Input() position: string;
|
|
|
|
contents: any[];
|
|
|
|
errorMessage: string = null;
|
|
|
|
constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) {
|
2018-11-27 18:33:17 +01:00
|
|
|
super();
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
2018-11-27 18:33:17 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
ngOnInit() {
|
|
|
|
this.errorMessage = null;
|
2018-11-27 18:33:17 +01:00
|
|
|
this.router.events
|
|
|
|
.pipe(takeUntil(this._destroyed))
|
|
|
|
.subscribe(event => {
|
|
|
|
if (event instanceof NavigationStart) {
|
2019-09-23 10:17:03 +02:00
|
|
|
// this._helpContentService.getActivePageContent(event['url'])
|
|
|
|
// .pipe(takeUntil(this._destroyed))
|
|
|
|
// .subscribe(
|
|
|
|
// pageContent => this.shiftThroughContent(pageContent),
|
|
|
|
// error => this.handleError(<any>error));
|
2018-11-27 18:33:17 +01:00
|
|
|
}
|
|
|
|
});
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
|
|
|
shiftThroughContent(pageContent: PageHelpContent) {
|
|
|
|
this.contents = pageContent.content[this.position];
|
|
|
|
}
|
|
|
|
isPresent() {
|
|
|
|
return (this.contents && this.contents.length > 0);
|
|
|
|
}
|
|
|
|
handleError(error) {
|
|
|
|
this.contents = [];
|
|
|
|
this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')';
|
|
|
|
}
|
2018-05-28 11:50:42 +02:00
|
|
|
}
|
2018-07-11 15:47:36 +02:00
|
|
|
|
2019-02-15 11:27:47 +01:00
|
|
|
// @Component({
|
|
|
|
// selector: 'app-aside-help-content',
|
|
|
|
// template: `
|
|
|
|
// <ng-template [ngIf]="contents && contents.length>0">
|
|
|
|
// <ng-template ngFor let-content [ngForOf]="contents">
|
|
|
|
// <div [innerHTML]="content.content" class="uk-card uk-card-body uk-card-default sidemenu uk-margin-bottom"></div>
|
|
|
|
// </ng-template>
|
|
|
|
// </ng-template>
|
|
|
|
// `,
|
|
|
|
// })
|
|
|
|
// export class AsideHelpContentComponent extends HelpContentComponent {
|
|
|
|
// }
|