@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
39 lines (38 loc) • 1.81 kB
TypeScript
import BaseLayer from '../../../models/layers/baselayer.js';
import IGirafeContext from '../../../tools/context/icontext.js';
export default class TreeViewFilterHelper {
private readonly context;
constructor(context: IGirafeContext);
/**
* Filters a tree structure of layers based on a search query.
* Updates the visibility of layers matching the search text.
*
* @param {BaseLayer[]} layerTree - The tree structure of layers to filter.
* @param {string} searchText - The text query used to filter the layers.
*/
filterLayerTree(layerTree: BaseLayer[], searchText: string): void;
/**
* Toggles visibility of layers whose IDs match the provided list.
*
* @param {BaseLayer[]} layerTree - The tree structure of layers.
* @param {string[]} matchingIds - Array of IDs whose visibility should be toggled.
*/
private toggleLayerVisibility;
/**
* Prepares a list of layer tree items for search by processing them hierarchically.
*
* @param {BaseLayer} layer - The layer to process.
* @param {string[]} [parentIds=[]] - An array of parent IDs representing the hierarchy above the current layer.
* @returns {{ idList: string[]; name: string }[]} An array of objects where each object contains:
* - `idList`: A combined array of parent IDs, the layer's own ID, and all of its children IDs.
* - `name`: The localized and lowercased name of the layer.
*/
private prepareTreeItemForSearch;
/**
* Retrieves the tree item IDs of the given layer and all its child layers recursively.
*
* @param {BaseLayer} layer - The root layer from which to start collecting tree item IDs.
* @returns {string[]} An array of tree item IDs.
*/
private getChildIdsRecursively;
}