@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.
package/dist/react.esm.js
CHANGED
|
@@ -11475,6 +11475,11 @@ const buildSearchCondition = (attributeAlias, query) => `${attributeAlias} LIKE
|
|
|
11475
11475
|
const buildNamesCondition = (attributeName, names) => `${attributeName} in ${formatConditionValue({ value: names })}`;
|
|
11476
11476
|
/** Запрос пачки записей по их значениям (`attributeValue`) — для восстановления `defaultValue`. */
|
|
11477
11477
|
const buildValuesCondition = (attributeValue, values) => `${attributeValue} in ${formatConditionValue({ value: values })}`;
|
|
11478
|
+
/**
|
|
11479
|
+
* Оборачивает запрос query-datasource подзапросом с WHERE-условием дерева.
|
|
11480
|
+
* У `api.eql.getPagedQueryResult` нет поля conditions, поэтому условие вшивается в сам запрос.
|
|
11481
|
+
*/
|
|
11482
|
+
const wrapQueryWithCondition = (query, condition) => `SELECT * FROM (${query}) WHERE ${condition}`;
|
|
11478
11483
|
/** Группирует выбранные id по уровню в объектное значение фильтра `{ l{N}: [ids] }`. */
|
|
11479
11484
|
const buildFilterValue = (selected) => {
|
|
11480
11485
|
const result = {};
|
|
@@ -11575,7 +11580,8 @@ const useTreeFilterData = (type, filterName) => {
|
|
|
11575
11580
|
const configFilter = useMemo(() => getConfigFilter(filterName, currentPage?.filters), [filterName, currentPage?.filters]);
|
|
11576
11581
|
const { relatedDataSource, attributeName = DEFAULT_ATTRIBUTE_NAME, attributeValue, attributeAlias = DEFAULT_ATTRIBUTE_NAME, attributeParentName, attributeLevel, attributeHasChildren, limit = DEFAULT_DATA_SOURCE_LIMIT, } = configFilter ?? {};
|
|
11577
11582
|
const valueAttribute = attributeValue ?? attributeName;
|
|
11578
|
-
const
|
|
11583
|
+
const dataSource = useMemo(() => currentPage?.dataSources?.find(({ name }) => name === relatedDataSource), [currentPage?.dataSources, relatedDataSource]);
|
|
11584
|
+
const { layerName, query: sourceQuery, ds } = dataSource ?? {};
|
|
11579
11585
|
const mapNode = useCallback(({ properties }) => {
|
|
11580
11586
|
const hasChildren = attributeHasChildren ? !!properties[attributeHasChildren] : false;
|
|
11581
11587
|
const data = {
|
|
@@ -11592,12 +11598,18 @@ const useTreeFilterData = (type, filterName) => {
|
|
|
11592
11598
|
};
|
|
11593
11599
|
}, [valueAttribute, attributeName, attributeAlias, attributeParentName, attributeLevel, attributeHasChildren]);
|
|
11594
11600
|
const runQuery = useCallback(async (condition) => {
|
|
11595
|
-
|
|
11596
|
-
|
|
11601
|
+
// Datasource на основе слоя: условие уходит как conditions слоя.
|
|
11602
|
+
if (layerName) {
|
|
11603
|
+
const response = await api.layers.getFeatures(layerName, { withGeom: false, limit, conditions: [condition] });
|
|
11604
|
+
return response.features ?? [];
|
|
11605
|
+
}
|
|
11606
|
+
// Datasource типа query: условие вшивается в EQL подзапросом.
|
|
11607
|
+
if (sourceQuery) {
|
|
11608
|
+
const response = await api.eql.getPagedQueryResult({ saveInHistory: false }, { ds, query: wrapQueryWithCondition(sourceQuery, condition), limit, offset: 0 });
|
|
11609
|
+
return response.features ?? [];
|
|
11597
11610
|
}
|
|
11598
|
-
|
|
11599
|
-
|
|
11600
|
-
}, [api, layerName, limit]);
|
|
11611
|
+
return [];
|
|
11612
|
+
}, [api, layerName, sourceQuery, ds, limit]);
|
|
11601
11613
|
const loadLevelOne = useCallback(async () => {
|
|
11602
11614
|
if (!attributeLevel) {
|
|
11603
11615
|
return [];
|