All files / app/component/plugin/plugin-list plugin-list.component.ts

78.94% Statements 15/19
61.11% Branches 11/18
66.66% Functions 4/6
76.92% Lines 10/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 492x         2x 2x 2x                 6x   2x         2x             4x         1x 1x                        
import { Component, Input, QueryList, ViewChildren } from '@angular/core';
import { Router } from '@angular/router';
import { HasChanges } from '../../../guard/pending-changes.guard';
import { Page } from '../../../model/page';
import { Plugin } from '../../../model/plugin';
import { LoadingComponent } from '../../loading/loading.component';
import { PageControlsComponent } from '../../page-controls/page-controls.component';
import { PluginComponent } from '../plugin.component';
 
@Component({
  selector: 'app-plugin-list',
  templateUrl: './plugin-list.component.html',
  styleUrls: ['./plugin-list.component.scss'],
  host: { 'class': 'plugin-list' },
  imports: [PluginComponent, PageControlsComponent, LoadingComponent]
})
export class PluginListComponent implements HasChanges {
 
  @ViewChildren(PluginComponent)
  list?: QueryList<PluginComponent>;
 
  private _page?: Page<Plugin>;
 
  constructor(private router: Router) { }
 
  saveChanges() {
    return !this.list?.find(p => !p.saveChanges());
  }
 
  get page() {
    return this._page;
  }
 
  @Input()
  set page(value: Page<Plugin> | undefined) {
    this._page = value;
    Iif (this._page) {
      if (this._page.page.number > 0 && this._page.page.number >= this._page.page.totalPages) {
        this.router.navigate([], {
          queryParams: {
            pageNumber: this._page.page.totalPages - 1
          },
          queryParamsHandling: "merge",
        });
      }
    }
  }
}