1 |
|
import {AfterViewInit, Component, Input, OnInit, ViewChild} from '@angular/core';
|
|
1 |
import { Component, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
|
2 |
2 |
import { MatPaginator } from '@angular/material/paginator';
|
3 |
|
import { MatSort } from '@angular/material/sort';
|
4 |
|
import { MatTable } from '@angular/material/table';
|
5 |
|
import { SearchPaginatorDataSource } from './search-paginator-datasource';
|
|
3 |
import { MatTableDataSource } from '@angular/material/table';
|
6 |
4 |
import { TextRegion } from '../../../../model/parts/TextRegion';
|
7 |
5 |
import { SearchResponse } from '../../../../model/SearchResponse';
|
8 |
6 |
|
... | ... | |
11 |
9 |
templateUrl: './search-paginator.component.html',
|
12 |
10 |
styleUrls: ['./search-paginator.component.css']
|
13 |
11 |
})
|
14 |
|
export class SearchPaginatorComponent implements AfterViewInit, OnInit {
|
15 |
|
@ViewChild(MatPaginator) paginator: MatPaginator;
|
16 |
|
@ViewChild(MatSort) sort: MatSort;
|
17 |
|
@ViewChild(MatTable) table: MatTable<TextRegion>;
|
|
12 |
export class SearchPaginatorComponent implements OnChanges {
|
|
13 |
@ViewChild(MatPaginator, {static: true}) paginator: MatPaginator;
|
18 |
14 |
@Input() inputData: SearchResponse;
|
19 |
|
dataSource: SearchPaginatorDataSource;
|
|
15 |
tableDataSource: MatTableDataSource<TextRegion>;
|
20 |
16 |
|
21 |
17 |
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
22 |
18 |
displayedColumns = ['image'];
|
23 |
19 |
|
24 |
|
ngOnInit() {
|
25 |
|
this.dataSource = new SearchPaginatorDataSource();
|
26 |
|
this.dataSource.data = this.inputData.textRegions;
|
|
20 |
ngOnChanges(changes: SimpleChanges): void {
|
|
21 |
this.tableDataSource = new MatTableDataSource<TextRegion>(this.inputData.textRegions);
|
|
22 |
this.tableDataSource.paginator = this.paginator;
|
27 |
23 |
}
|
28 |
24 |
|
29 |
|
ngAfterViewInit() {
|
30 |
|
this.dataSource.sort = this.sort;
|
31 |
|
this.dataSource.paginator = this.paginator;
|
32 |
|
this.table.dataSource = this.dataSource;
|
33 |
|
}
|
34 |
25 |
}
|
Re #7802: Implementace vykreslování search page s výsledky
- zprovoznění refresh paginatoru a tabulky