File

src/lib/table-column-menu/table-show-archived-slide/table-show-archived-slide.component.ts

Implements

AfterViewInit

Metadata

Index

Methods
Inputs

Constructor

constructor(tableFilter: TableFilterService | null, tableColumnMenu: TableColumnMenuComponent, selectRows: SelectRowService | null)
Parameters :
Name Type Optional
tableFilter TableFilterService | null No
tableColumnMenu TableColumnMenuComponent No
selectRows SelectRowService | null No

Inputs

paginator
Type : MatPaginator

Methods

Public onChange
onChange($event: MatSlideToggleChange)
Parameters :
Name Type Optional
$event MatSlideToggleChange No
Returns : void
import {
  AfterViewInit,
  ChangeDetectionStrategy,
  Component,
  Inject,
  Input,
  Optional,
} from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import {
  MatSlideToggleChange,
  MatSlideToggleModule,
} from '@angular/material/slide-toggle';
import { StopPropagationDirective } from '@rxap/directives';
import { SelectRowService } from '../../select-row/select-row.service';
import { TableFilterService } from '../../table-filter/table-filter.service';
import { TableColumnMenuComponent } from '../table-column-menu.component';

@Component({
    selector: 'rxap-table-show-archived-slide',
    templateUrl: './table-show-archived-slide.component.html',
    styleUrls: ['./table-show-archived-slide.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
    imports: [StopPropagationDirective, MatSlideToggleModule]
})
export class TableShowArchivedSlideComponent implements AfterViewInit {

  @Input()
  public paginator?: MatPaginator;

  constructor(
    @Optional()
    @Inject(TableFilterService)
    private readonly tableFilter: TableFilterService | null,
    @Inject(TableColumnMenuComponent)
    private readonly tableColumnMenu: TableColumnMenuComponent,
    @Inject(SelectRowService)
    private readonly selectRows: SelectRowService | null,
  ) {
  }

  public onChange($event: MatSlideToggleChange) {
    this.paginator?.firstPage();
    this.tableFilter?.set('__archived', $event.checked);
    this.selectRows?.clear();
    if ($event.checked) {
      this.tableColumnMenu.activate('removedAt');
      this.tableColumnMenu.activate('__removedAt');
      this.tableColumnMenu.activate('__--removed-at');
      this.tableColumnMenu.activate('removed-at');
      this.tableColumnMenu.activate('__removed-at');
    } else {
      this.tableColumnMenu.deactivate('removedAt');
      this.tableColumnMenu.deactivate('__removedAt');
      this.tableColumnMenu.deactivate('__--removed-at');
      this.tableColumnMenu.deactivate('removed-at');
      this.tableColumnMenu.deactivate('__removed-at');
    }
  }

  public ngAfterViewInit() {
    this.tableColumnMenu.deactivate('removedAt');
    this.tableColumnMenu.deactivate('__removedAt');
    this.tableColumnMenu.deactivate('__--removed-at');
    this.tableColumnMenu.deactivate('removed-at');
    this.tableColumnMenu.deactivate('__removed-at');
  }

}
<div class="m-6" rxapStopPropagation>
  <mat-slide-toggle (change)="onChange($event)">
    <span class="mx-2 whitespace-nowrap" i18n>Show archived documents</span>
  </mat-slide-toggle>
</div>

./table-show-archived-slide.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""