Skip to content
Snippets Groups Projects
unit-view.component.ts 1.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • rhenck's avatar
    rhenck committed
    import { Component } from '@angular/core';
    
    import { PageChangeService } from 'common/services/page-change.service';
    
    import { UnitService } from '../../services/unit-services/unit.service';
    
    rhenck's avatar
    rhenck committed
    import { SelectionService } from '../../services/selection.service';
    
    import { HistoryService } from 'editor/src/app/services/history.service';
    import { PageService } from 'editor/src/app/services/unit-services/page.service';
    
      selector: 'aspect-unit-view',
    
      templateUrl: './unit-view.component.html',
    
      styleUrls: ['./unit-view.component.css']
    
    rhenck's avatar
    rhenck committed
    export class UnitViewComponent {
    
      pagesLoaded = true;
    
      constructor(public selectionService: SelectionService,
                  public unitService: UnitService,
    
                  public pageService: PageService,
    
                  public pageChangeService: PageChangeService,
    
                  public historyService: HistoryService) { }
    
    
      selectPage(newIndex: number): void {
    
        this.selectionService.selectPage(newIndex);
    
    
      addPage(): void {
    
        this.pageService.addPage();
      }
    
      /* This is a hack. The tab element gets bugged when changing the underlying array.
         With this we can temporarily remove it from the DOM and then add it again, re-initializing it. */
      refreshTabs(): void {
        this.pagesLoaded = false;
        setTimeout(() => {
          this.pagesLoaded = true;
        });