File

projects/onto-search/src/lib/onto-search-results/onto-search-results.component.ts

Metadata

selector onto-search-results
styleUrls onto-search-results.component.scss
templateUrl onto-search-results.component.html

Inputs

componentClass

Styling class applied to div wrapper of the table

Type: string | string[]

config

Table configuration, containing table and column specific configuration
If configuration is changed dynamically it must be passed as new object to
be detected by angular change detection

Type: TableConfig

datasource

The data source for the table

Type: any[]

sort

Table sort information

Type: Sort

Outputs

sortData

Fired whenever there is change in sorting column or direction.
Sends a {@link Sort} object

$event type: EventEmitter<Sort>

Properties

displayColumns
displayColumns: string[]
import {Component, EventEmitter, Input, OnChanges, Output, SimpleChanges} from '@angular/core';
import {TableConfig} from './models/configuration-types';
import {Sort} from '@angular/material/sort';

@Component({
  selector: 'onto-search-results',
  templateUrl: './onto-search-results.component.html',
  styleUrls: ['./onto-search-results.component.scss'],
})
export class OntoSearchResultsComponent implements OnChanges {
  /**
   * The data source for the table
   */
  @Input()
  public datasource: any[];

  /**
   * Table configuration, containing table and column specific configuration
   * If configuration is changed dynamically it must be passed as new object to
   * be detected by angular change detection
   */
  @Input()
  public config: TableConfig;

  /**
   * Table sort information
   */
  @Input()
  sort: Sort;

  /**
   * Styling class applied to div wrapper of the table
   */
  @Input()
  componentClass: string | string[];

  /**
   * Fired whenever there is change in sorting column or direction.
   * Sends a {@link Sort} object
   */
  @Output()
  sortData: EventEmitter<Sort> = new EventEmitter<Sort>();

  displayColumns: string[];

  public ngOnChanges(changes: SimpleChanges): void {
    if (changes.config && changes.config.currentValue) {
      const permanentColumns = [...this.config.columnConfigurations
          .filter((column) => column.permanent)]
          .map((column) => column.name);

      const dynamicColumns = [...this.config.columnConfigurations
          .filter((column) => !column.permanent && !column.hidden)]
          .map((column) => column.name);

      this.displayColumns = [...permanentColumns, ...dynamicColumns];
    }
  }
}

results matching ""

    No results matching ""