File

src/lib/table-select-controls/table-select-controls.component.ts

Metadata

Index

Properties
Methods

Constructor

constructor(selectRows: SelectRowService<any>, windowRef: WindowRef)
Parameters :
Name Type Optional
selectRows SelectRowService<any> No
windowRef WindowRef No

Methods

Public cancel
cancel()
Returns : void
Public select
select()
Returns : void

Properties

Public hasNotSelected$
Type : Observable<boolean>
import {
  ChangeDetectionStrategy,
  Component,
  Inject,
} from '@angular/core';
import type { WindowRef } from '@rxap/window-system';
import { RXAP_WINDOW_REF } from '@rxap/window-system';
import type { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { SelectRowService } from '../select-row/select-row.service';
import { AsyncPipe } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';

@Component({
    selector: 'rxap-table-select-controls',
    templateUrl: './table-select-controls.component.html',
    styleUrls: ['./table-select-controls.component.scss'],
    changeDetection: ChangeDetectionStrategy.OnPush,
    imports: [
        MatButtonModule,
        AsyncPipe,
    ]
})
export class TableSelectControlsComponent {
  public hasNotSelected$: Observable<boolean>;

  constructor(
    private readonly selectRows: SelectRowService<any>,
    @Inject(RXAP_WINDOW_REF)
    private readonly windowRef: WindowRef,
  ) {
    this.hasNotSelected$ = this.selectRows.selectedRows$.pipe(
      map((selected) => selected.length === 0),
    );
  }

  public cancel() {
    this.windowRef.close();
  }

  public select() {
    this.windowRef.close(this.selectRows.selectedRows);
  }
}
<div class="flex flex-row gap-4">
  <button (click)="cancel()" class="grow-0" mat-stroked-button type="button">
    <ng-container i18n>Cancel</ng-container>
  </button>
  <button (click)="select()" [disabled]="hasNotSelected$ | async" class="grow-0" mat-raised-button type="button">
    <ng-container i18n>Select</ng-container>
  </button>
</div>

./table-select-controls.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""