@evergis/react 4.0.82 → 4.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,6 +7,11 @@ export declare const buildSearchCondition: (attributeAlias: string, query: strin
7
7
  export declare const buildNamesCondition: (attributeName: string, names: Array<string | number>) => string;
8
8
  /** Запрос пачки записей по их значениям (`attributeValue`) — для восстановления `defaultValue`. */
9
9
  export declare const buildValuesCondition: (attributeValue: string, values: Array<string | number>) => string;
10
+ /**
11
+ * Оборачивает запрос query-datasource подзапросом с WHERE-условием дерева.
12
+ * У `api.eql.getPagedQueryResult` нет поля conditions, поэтому условие вшивается в сам запрос.
13
+ */
14
+ export declare const wrapQueryWithCondition: (query: string, condition: string) => string;
10
15
  /** Группирует выбранные id по уровню в объектное значение фильтра `{ l{N}: [ids] }`. */
11
16
  export declare const buildFilterValue: (selected: Map<TreeId, number>) => TreeFilterValue;
12
17
  /** Разбирает объектное значение фильтра в карту `id → level`. */
package/dist/index.js CHANGED
@@ -11477,6 +11477,11 @@ const buildSearchCondition = (attributeAlias, query) => `${attributeAlias} LIKE
11477
11477
  const buildNamesCondition = (attributeName, names) => `${attributeName} in ${formatConditionValue({ value: names })}`;
11478
11478
  /** Запрос пачки записей по их значениям (`attributeValue`) — для восстановления `defaultValue`. */
11479
11479
  const buildValuesCondition = (attributeValue, values) => `${attributeValue} in ${formatConditionValue({ value: values })}`;
11480
+ /**
11481
+ * Оборачивает запрос query-datasource подзапросом с WHERE-условием дерева.
11482
+ * У `api.eql.getPagedQueryResult` нет поля conditions, поэтому условие вшивается в сам запрос.
11483
+ */
11484
+ const wrapQueryWithCondition = (query, condition) => `SELECT * FROM (${query}) WHERE ${condition}`;
11480
11485
  /** Группирует выбранные id по уровню в объектное значение фильтра `{ l{N}: [ids] }`. */
11481
11486
  const buildFilterValue = (selected) => {
11482
11487
  const result = {};
@@ -11577,7 +11582,8 @@ const useTreeFilterData = (type, filterName) => {
11577
11582
  const configFilter = React.useMemo(() => getConfigFilter(filterName, currentPage?.filters), [filterName, currentPage?.filters]);
11578
11583
  const { relatedDataSource, attributeName = DEFAULT_ATTRIBUTE_NAME, attributeValue, attributeAlias = DEFAULT_ATTRIBUTE_NAME, attributeParentName, attributeLevel, attributeHasChildren, limit = DEFAULT_DATA_SOURCE_LIMIT, } = configFilter ?? {};
11579
11584
  const valueAttribute = attributeValue ?? attributeName;
11580
- const layerName = React.useMemo(() => currentPage?.dataSources?.find(({ name }) => name === relatedDataSource)?.layerName, [currentPage?.dataSources, relatedDataSource]);
11585
+ const dataSource = React.useMemo(() => currentPage?.dataSources?.find(({ name }) => name === relatedDataSource), [currentPage?.dataSources, relatedDataSource]);
11586
+ const { layerName, query: sourceQuery, ds } = dataSource ?? {};
11581
11587
  const mapNode = React.useCallback(({ properties }) => {
11582
11588
  const hasChildren = attributeHasChildren ? !!properties[attributeHasChildren] : false;
11583
11589
  const data = {
@@ -11594,12 +11600,18 @@ const useTreeFilterData = (type, filterName) => {
11594
11600
  };
11595
11601
  }, [valueAttribute, attributeName, attributeAlias, attributeParentName, attributeLevel, attributeHasChildren]);
11596
11602
  const runQuery = React.useCallback(async (condition) => {
11597
- if (!layerName) {
11598
- return [];
11603
+ // Datasource на основе слоя: условие уходит как conditions слоя.
11604
+ if (layerName) {
11605
+ const response = await api.layers.getFeatures(layerName, { withGeom: false, limit, conditions: [condition] });
11606
+ return response.features ?? [];
11607
+ }
11608
+ // Datasource типа query: условие вшивается в EQL подзапросом.
11609
+ if (sourceQuery) {
11610
+ const response = await api.eql.getPagedQueryResult({ saveInHistory: false }, { ds, query: wrapQueryWithCondition(sourceQuery, condition), limit, offset: 0 });
11611
+ return response.features ?? [];
11599
11612
  }
11600
- const response = await api.layers.getFeatures(layerName, { withGeom: false, limit, conditions: [condition] });
11601
- return response.features ?? [];
11602
- }, [api, layerName, limit]);
11613
+ return [];
11614
+ }, [api, layerName, sourceQuery, ds, limit]);
11603
11615
  const loadLevelOne = React.useCallback(async () => {
11604
11616
  if (!attributeLevel) {
11605
11617
  return [];