Page MenuHomec4science

content-view-tab-component.component.ts
No OneTemporary

File Metadata

Created
Mon, May 6, 00:40

content-view-tab-component.component.ts

import {Component, OnInit} from '@angular/core';
import {ActivatedRoute, Params, Router} from '@angular/router';
import {Subscription} from "rxjs/index";
import { TlnQueryParams} from '../models/models';
import {NavigationServiceService} from "../services/navigation-service.service";
import { TLN_CROSSREF_ROUTE, TLN_MANUSCRIPT_ROUTE, TLN_VIEWER_ROUTE } from '../tln-edition/constants';
@Component({
selector: 'app-content-view-tab-component',
templateUrl: './content-view-tab-component.component.html',
styleUrls: ['./content-view-tab-component.component.scss'],
providers: [ NavigationServiceService ]
})
export class ContentViewTabComponentComponent implements OnInit {
// navigation tabs for the content view (manuscript view, page view, rhizome view)
navTabLinks: any[];
// navbar on th left for navigating
navBarOpenState: boolean;
navBarOpenMode = 'push'; // side || over || push
queryParams: TlnQueryParams;
queryParamSubscription: Subscription;
constructor(private router: Router,
private activatedRoute: ActivatedRoute,
private naviService: NavigationServiceService) {
// The links/tabs for routing the correct view-component
this.navTabLinks = [
{
label: 'Manuskriptansicht',
link: TLN_MANUSCRIPT_ROUTE,
index: 0
}, {
label: 'Seitenansicht',
link: TLN_VIEWER_ROUTE,
index: 1
}, {
label: 'Querverweise',
link: TLN_CROSSREF_ROUTE,
index: 2
},
];
}
ngOnInit() {
this.setParamsOnInit();
// If url pasted or page refreshed --> resetting this.queryparams to the query params of the url;
// needed for active routing in the nav tabs & for general use in the template
this.queryParamSubscription = this.activatedRoute.queryParams.subscribe( (queryParams: Params ) => {
this.queryParams = new TlnQueryParams(
queryParams.navBarOpenState,
queryParams.navContext,
queryParams.manuscript,
queryParams.page,
queryParams.selectedLines,
queryParams.selectedWords,
queryParams.viewMode,
queryParams.fullscreen,
queryParams.zoom
);
});
}
setParamsOnInit() {
const qParams: Params = {};
// Set the NavBarOpenstate to false if it is false in the url query param onInit. In every other case we toggle it open actively.
if (this.activatedRoute.snapshot.queryParamMap.get('navBarOpenState') === 'false') {
this.navBarOpenState = false; } else {
this.navBarOpenState = true; }
qParams.navBarOpenState = this.navBarOpenState;
// viewMode
if (!this.activatedRoute.snapshot.queryParamMap.get('viewMode')) {
qParams.viewMode = 'Transkription/Faksimile';
}
this.naviService.updateRoute(qParams);
}
toggleNavDrawer() {
this.navBarOpenState = !this.navBarOpenState;
this.naviService.updateRoute({navBarOpenstate: this.navBarOpenState.toString()});
}
}

Event Timeline