@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
90 lines (89 loc) • 2.68 kB
TypeScript
import type OlFeature from 'ol/Feature.js';
import { GridDataById } from '../../../tools/featuretogriddatabyid.js';
import { ColumnComponent, ColumnDefinition, RowComponent } from 'tabulator-tables';
import IGirafeContext from '../../../tools/context/icontext.js';
/**
* Represents the header text and state of a tab.
*/
export interface TabHeader {
id: string;
text: string;
active: boolean;
}
/**
* Represents a column in a data table.
*/
export interface Column {
id: string;
name: string;
}
/**
* Represents the content and backrefs of a tab.
*/
export interface TabContent {
columns: Column[];
data: unknown[][];
features: OlFeature[];
}
export default class SelectionTabulatorManager {
private readonly featureToGridData;
private idTab;
private tabHeaders;
private table;
private element;
private data;
private readonly context;
private readonly columnAliasHelper;
private readonly minimalColumnWidth;
private readonly columnPositionsBeforeFreezing;
private popupLastImageSrc;
private popupLastInstance;
private get tableColumns();
constructor(context: IGirafeContext);
/**
* Set the HTML element to be used by the grid.
*/
setElement(htmlElement: HTMLElement): void;
/**
* Replace the data of the current grid with the data of the specified tab.
*/
replaceData(id: string): void;
/**
* Activates a tab matching the given id.
*/
activateTab(id: string): void;
/**
* Creates (replace) the Tabulator grid based on the provided tab id and related data and features.
*/
displayGrid(id: string): void;
/**
* Transforms the given features into grid data and sets tab headers.
* The grid data are completely replaced.
*/
featuresToGridData(features: OlFeature[]): void;
/**
* Converts grid data to grid tab format and adds it to the idTab object.
* @private
*/
private gridDataToGridTab;
columnsToGridColumns(idTable: string, columns: string[]): ColumnDefinition[];
getLookupColumnForFreezing(): [ColumnComponent, boolean];
filterEmptyColumnsOnData(data: GridDataById): GridDataById;
/**
* @returns A newly created grid column object.
* @private
*/
private createGridColumn;
blockRedraw(): void;
restoreRedraw(): void;
redraw(force?: boolean): void;
selectAll(): void;
selectNone(): void;
invertSelection(): void;
getSelectedRows(): RowComponent[];
getSelectedData(): any[];
getColumnFields(): string[];
getTabHeaders(): TabHeader[];
clearTabHeaders(): void;
getTabIds(): string[];
}