@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
85 lines (84 loc) • 2.44 kB
TypeScript
import type OlFeature from 'ol/Feature';
import { GridDataById } from '../../../tools/featuretogriddatabyid';
import { ColumnDefinition, TabulatorFull as Tabulator } from 'tabulator-tables';
/**
* 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 formatGridGeomValue;
private readonly configManager;
private readonly featureToGridData;
private readonly stateManager;
idTab: Record<string, TabContent>;
tabHeaders: TabHeader[];
table: Tabulator | null;
element: string | HTMLElement;
data: GridDataById;
constructor();
/**
* 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[];
filterEmptyColumnsOnData(data: GridDataById): GridDataById;
/**
* @returns A newly created grid column object.
* @private
*/
private createGridColumn;
/**
* Creates grid data by mapping values (simple values, or transformed values in case of HTML).
* @returns The grid data array.
* @private
*/
private createGridData;
/**
* @returns The locale specified in the configuration.
* @private
*/
private getLocale;
blockRedraw(): void;
restoreRedraw(): void;
}