@elliemae/ds-query-builder 2.2.0-alpha.4 → 3.0.0-next.2
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/cjs/DSQueryBuilder.js +97 -117
- package/cjs/components/AndOrController/AndOrController.js +162 -148
- package/cjs/components/ConditionController/ConditionController.js +72 -88
- package/cjs/components/DisplayOutput/DisplayOutput.js +68 -63
- package/cjs/components/DragContainerController/DragContainerController.js +41 -61
- package/cjs/components/DragControllerRow/DragControllerRow.js +46 -50
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +32 -54
- package/cjs/components/Nestable/Nestable.js +209 -143
- package/cjs/components/Nestable/NestableItem.js +90 -98
- package/cjs/components/Nestable/actions/events.js +95 -72
- package/cjs/components/Nestable/actions/getItemOptions.js +15 -36
- package/cjs/components/Nestable/actions/getPaths.js +51 -46
- package/cjs/components/Nestable/actions/index.js +28 -42
- package/cjs/components/Nestable/actions/moveItem.js +42 -44
- package/cjs/components/Nestable/actions/paths.js +55 -48
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +23 -39
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +26 -39
- package/cjs/components/Nestable/index.js +7 -36
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -36
- package/cjs/components/QueryBuilderImpl.js +202 -118
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +78 -80
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +211 -154
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +26 -39
- package/cjs/components/format/format.js +22 -48
- package/cjs/components/format/sqlFormat.js +48 -69
- package/cjs/components/format/sqlSafeFormat.js +55 -72
- package/cjs/components/format/xmlFormat.js +50 -71
- package/cjs/components/helpers/actions.js +186 -151
- package/cjs/components/helpers/constants.js +8 -36
- package/cjs/components/helpers/dependencies.js +64 -49
- package/cjs/components/helpers/selectors.js +101 -161
- package/cjs/components/helpers/store.js +104 -86
- package/cjs/components/helpers/types.js +44 -72
- package/cjs/index.js +29 -36
- package/cjs/propTypes.js +94 -102
- package/esm/DSQueryBuilder.js +72 -103
- package/esm/components/AndOrController/AndOrController.js +147 -113
- package/esm/components/ConditionController/ConditionController.js +62 -57
- package/esm/components/DisplayOutput/DisplayOutput.js +59 -31
- package/esm/components/DragContainerController/DragContainerController.js +35 -32
- package/esm/components/DragControllerRow/DragControllerRow.js +38 -21
- package/esm/components/FieldControllerRow/FieldControllerRow.js +26 -25
- package/esm/components/Nestable/Nestable.js +186 -115
- package/esm/components/Nestable/NestableItem.js +82 -69
- package/esm/components/Nestable/actions/events.js +79 -45
- package/esm/components/Nestable/actions/getItemOptions.js +11 -7
- package/esm/components/Nestable/actions/getPaths.js +43 -17
- package/esm/components/Nestable/actions/index.js +6 -13
- package/esm/components/Nestable/actions/moveItem.js +31 -13
- package/esm/components/Nestable/actions/paths.js +47 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +19 -10
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +22 -10
- package/esm/components/Nestable/index.js +2 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -7
- package/esm/components/QueryBuilderImpl.js +187 -82
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +70 -50
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +201 -123
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +17 -10
- package/esm/components/format/format.js +17 -16
- package/esm/components/format/sqlFormat.js +43 -39
- package/esm/components/format/sqlSafeFormat.js +50 -43
- package/esm/components/format/xmlFormat.js +45 -41
- package/esm/components/helpers/actions.js +160 -123
- package/esm/components/helpers/constants.js +2 -7
- package/esm/components/helpers/dependencies.js +39 -19
- package/esm/components/helpers/selectors.js +93 -132
- package/esm/components/helpers/store.js +82 -54
- package/esm/components/helpers/types.js +33 -44
- package/esm/index.js +4 -7
- package/esm/propTypes.js +72 -55
- package/package.json +12 -12
- package/cjs/DSQueryBuilder.js.map +0 -7
- package/cjs/components/AndOrController/AndOrController.js.map +0 -7
- package/cjs/components/ConditionController/ConditionController.js.map +0 -7
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/cjs/components/Nestable/Nestable.js.map +0 -7
- package/cjs/components/Nestable/NestableItem.js.map +0 -7
- package/cjs/components/Nestable/actions/events.js.map +0 -7
- package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/cjs/components/Nestable/actions/getPaths.js.map +0 -7
- package/cjs/components/Nestable/actions/index.js.map +0 -7
- package/cjs/components/Nestable/actions/moveItem.js.map +0 -7
- package/cjs/components/Nestable/actions/paths.js.map +0 -7
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/index.js.map +0 -7
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/cjs/components/QueryBuilderImpl.js.map +0 -7
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/cjs/components/format/format.js.map +0 -7
- package/cjs/components/format/sqlFormat.js.map +0 -7
- package/cjs/components/format/sqlSafeFormat.js.map +0 -7
- package/cjs/components/format/xmlFormat.js.map +0 -7
- package/cjs/components/helpers/actions.js.map +0 -7
- package/cjs/components/helpers/constants.js.map +0 -7
- package/cjs/components/helpers/dependencies.js.map +0 -7
- package/cjs/components/helpers/selectors.js.map +0 -7
- package/cjs/components/helpers/store.js.map +0 -7
- package/cjs/components/helpers/types.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/esm/DSQueryBuilder.js.map +0 -7
- package/esm/components/AndOrController/AndOrController.js.map +0 -7
- package/esm/components/ConditionController/ConditionController.js.map +0 -7
- package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/esm/components/DragContainerController/DragContainerController.js.map +0 -7
- package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/esm/components/Nestable/Nestable.js.map +0 -7
- package/esm/components/Nestable/NestableItem.js.map +0 -7
- package/esm/components/Nestable/actions/events.js.map +0 -7
- package/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/esm/components/Nestable/actions/getPaths.js.map +0 -7
- package/esm/components/Nestable/actions/index.js.map +0 -7
- package/esm/components/Nestable/actions/moveItem.js.map +0 -7
- package/esm/components/Nestable/actions/paths.js.map +0 -7
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/esm/components/Nestable/index.js.map +0 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/esm/components/QueryBuilderImpl.js.map +0 -7
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/esm/components/format/format.js.map +0 -7
- package/esm/components/format/sqlFormat.js.map +0 -7
- package/esm/components/format/sqlSafeFormat.js.map +0 -7
- package/esm/components/format/xmlFormat.js.map +0 -7
- package/esm/components/helpers/actions.js.map +0 -7
- package/esm/components/helpers/constants.js.map +0 -7
- package/esm/components/helpers/dependencies.js.map +0 -7
- package/esm/components/helpers/selectors.js.map +0 -7
- package/esm/components/helpers/store.js.map +0 -7
- package/esm/components/helpers/types.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
3
5
|
const conditionSql = (condition, value) => {
|
|
4
6
|
const {
|
|
5
7
|
EQUAL,
|
|
@@ -13,53 +15,55 @@ const conditionSql = (condition, value) => {
|
|
|
13
15
|
LESS_THAN_OR_EQUAL,
|
|
14
16
|
START_WITH
|
|
15
17
|
} = QB_OPERATOR_TYPES;
|
|
16
|
-
if (condition === EQUAL)
|
|
17
|
-
|
|
18
|
-
if (condition ===
|
|
19
|
-
|
|
20
|
-
if (condition ===
|
|
21
|
-
|
|
22
|
-
if (condition ===
|
|
23
|
-
|
|
24
|
-
if (condition ===
|
|
25
|
-
|
|
26
|
-
if (condition === NOT_CONTAINS)
|
|
27
|
-
return ` NOT LIKE '%${value}%'`;
|
|
28
|
-
if (condition === BETWEEN)
|
|
29
|
-
return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
30
|
-
if (condition === GREATER_THAN_OR_EQUAL)
|
|
31
|
-
return ` >= ${value}`;
|
|
32
|
-
if (condition === LESS_THAN_OR_EQUAL)
|
|
33
|
-
return ` <= ${value}`;
|
|
34
|
-
if (condition === START_WITH)
|
|
35
|
-
return ` LIKE '${value}%'`;
|
|
18
|
+
if (condition === EQUAL) return " = '".concat(value, "'");
|
|
19
|
+
if (condition === NOT_EQUAL) return " <> '".concat(value, "'");
|
|
20
|
+
if (condition === GREATER_THAN) return " > ".concat(value);
|
|
21
|
+
if (condition === LESS_THAN) return " < ".concat(value);
|
|
22
|
+
if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
|
|
23
|
+
if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
|
|
24
|
+
if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
|
|
25
|
+
if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
|
|
26
|
+
if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
|
|
27
|
+
if (condition === START_WITH) return " LIKE '".concat(value, "%'");
|
|
36
28
|
return condition;
|
|
37
29
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
|
|
31
|
+
const renderFilterSQl = filter => {
|
|
32
|
+
const {
|
|
33
|
+
field,
|
|
34
|
+
operator,
|
|
35
|
+
value
|
|
36
|
+
} = filter.element;
|
|
37
|
+
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
41
38
|
};
|
|
42
|
-
|
|
39
|
+
|
|
40
|
+
const sqlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
43
47
|
const groupSql = (item, idGroup) => {
|
|
44
48
|
if (idGroup === main) {
|
|
45
|
-
const
|
|
46
|
-
return
|
|
49
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
|
|
53
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
50
55
|
};
|
|
56
|
+
|
|
51
57
|
const filterSql = (filters, groupCondition) => {
|
|
52
|
-
const filterGroup = filters.map(
|
|
53
|
-
if (filter.element.type === "filter")
|
|
54
|
-
|
|
55
|
-
return ` ${groupSql(filter) || ""} `;
|
|
58
|
+
const filterGroup = filters.map(filter => {
|
|
59
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
60
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
56
61
|
});
|
|
57
62
|
return filterGroup.join(groupCondition);
|
|
58
63
|
};
|
|
59
|
-
|
|
64
|
+
|
|
65
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
60
66
|
return sql;
|
|
61
67
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=sqlFormat.js.map
|
|
68
|
+
|
|
69
|
+
export { sqlFormat };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
3
5
|
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
6
|
+
|
|
4
7
|
const conditionSql = (condition, value) => {
|
|
5
8
|
const {
|
|
6
9
|
EQUAL,
|
|
@@ -13,57 +16,61 @@ const conditionSql = (condition, value) => {
|
|
|
13
16
|
GREATER_THAN_OR_EQUAL,
|
|
14
17
|
LESS_THAN_OR_EQUAL,
|
|
15
18
|
START_WITH
|
|
16
|
-
} = QB_OPERATOR_TYPES;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (condition === NOT_EQUAL)
|
|
21
|
-
|
|
22
|
-
if (condition ===
|
|
23
|
-
|
|
24
|
-
if (condition ===
|
|
25
|
-
|
|
26
|
-
if (condition ===
|
|
27
|
-
|
|
28
|
-
if (condition ===
|
|
29
|
-
return ` NOT LIKE '%${value}%'`;
|
|
30
|
-
if (condition === BETWEEN)
|
|
31
|
-
return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
32
|
-
if (condition === GREATER_THAN_OR_EQUAL)
|
|
33
|
-
return ` >= ${value}`;
|
|
34
|
-
if (condition === LESS_THAN_OR_EQUAL)
|
|
35
|
-
return ` <= ${value}`;
|
|
36
|
-
if (condition === START_WITH)
|
|
37
|
-
return ` LIKE '${value}%'`;
|
|
19
|
+
} = QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
|
|
20
|
+
|
|
21
|
+
const valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
|
|
22
|
+
if (condition === EQUAL) return " = ".concat(valueDisplay);
|
|
23
|
+
if (condition === NOT_EQUAL) return " <> ".concat(valueDisplay);
|
|
24
|
+
if (condition === GREATER_THAN) return " > ".concat(valueDisplay);
|
|
25
|
+
if (condition === LESS_THAN) return " < ".concat(valueDisplay);
|
|
26
|
+
if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
|
|
27
|
+
if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
|
|
28
|
+
if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
|
|
31
|
+
if (condition === START_WITH) return " LIKE '".concat(value, "%'");
|
|
38
32
|
return condition;
|
|
39
33
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
34
|
+
|
|
35
|
+
const renderFilterSQl = filter => {
|
|
36
|
+
const {
|
|
37
|
+
field,
|
|
38
|
+
operator,
|
|
39
|
+
value
|
|
40
|
+
} = filter.element; // eslint-disable-next-line no-restricted-globals
|
|
41
|
+
|
|
42
|
+
const fieldDisplay = // eslint-disable-next-line no-restricted-globals
|
|
43
|
+
/[.]/.test(field) || !isNaN(field) ? "\\\"".concat(field, "\\\"") : field;
|
|
44
|
+
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
44
45
|
};
|
|
45
|
-
|
|
46
|
+
|
|
47
|
+
const sqlSafeFormat = _ref => {
|
|
48
|
+
let {
|
|
49
|
+
main,
|
|
50
|
+
mapGroups,
|
|
51
|
+
items
|
|
52
|
+
} = _ref;
|
|
53
|
+
|
|
46
54
|
const groupSql = (item, idGroup) => {
|
|
47
55
|
if (idGroup === main) {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
56
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
57
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
50
58
|
}
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
|
|
60
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
61
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
53
62
|
};
|
|
63
|
+
|
|
54
64
|
const filterSql = (filters, groupCondition) => {
|
|
55
|
-
const filterGroup = filters.map(
|
|
56
|
-
if (filter.element.type === "filter")
|
|
57
|
-
|
|
58
|
-
return ` ${groupSql(filter) || ""} `;
|
|
65
|
+
const filterGroup = filters.map(filter => {
|
|
66
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
67
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
59
68
|
});
|
|
60
69
|
return filterGroup.join(groupCondition);
|
|
61
70
|
};
|
|
62
|
-
|
|
71
|
+
|
|
72
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
63
73
|
return sql;
|
|
64
74
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
sqlSafeFormat
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=sqlSafeFormat.js.map
|
|
75
|
+
|
|
76
|
+
export { specialChar, sqlSafeFormat };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
3
5
|
const conditionSql = (condition, value) => {
|
|
4
6
|
const {
|
|
5
7
|
EQUAL,
|
|
@@ -13,53 +15,55 @@ const conditionSql = (condition, value) => {
|
|
|
13
15
|
LESS_THAN_OR_EQUAL,
|
|
14
16
|
START_WITH
|
|
15
17
|
} = QB_OPERATOR_TYPES;
|
|
16
|
-
if (condition === EQUAL)
|
|
17
|
-
|
|
18
|
-
if (condition ===
|
|
19
|
-
|
|
20
|
-
if (condition ===
|
|
21
|
-
|
|
22
|
-
if (condition ===
|
|
23
|
-
|
|
24
|
-
if (condition ===
|
|
25
|
-
|
|
26
|
-
if (condition === NOT_CONTAINS)
|
|
27
|
-
return `<condition>NOT_LIKE</condition><value>${value}</value>`;
|
|
28
|
-
if (condition === BETWEEN)
|
|
29
|
-
return `<condition>NOT_LIKE</condition><value><from>${value[0]}</from><to>${value[1]}</to></value>`;
|
|
30
|
-
if (condition === GREATER_THAN_OR_EQUAL)
|
|
31
|
-
return `<condition>GREATER_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
32
|
-
if (condition === LESS_THAN_OR_EQUAL)
|
|
33
|
-
return `<condition>LESS_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
34
|
-
if (condition === START_WITH)
|
|
35
|
-
return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
18
|
+
if (condition === EQUAL) return "<condition>EQUAL</condition><value>".concat(value, "</value>");
|
|
19
|
+
if (condition === NOT_EQUAL) return "<condition>NOT_EQUAL</condition><value>".concat(value, "</value>");
|
|
20
|
+
if (condition === GREATER_THAN) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
|
|
21
|
+
if (condition === LESS_THAN) return "<condition>LESS_THAN</condition><value>".concat(value, "</value>");
|
|
22
|
+
if (condition === CONTAINS) return "<condition>LIKE</condition><value>".concat(value, "</value>");
|
|
23
|
+
if (condition === NOT_CONTAINS) return "<condition>NOT_LIKE</condition><value>".concat(value, "</value>");
|
|
24
|
+
if (condition === BETWEEN) return "<condition>NOT_LIKE</condition><value><from>".concat(value[0], "</from><to>").concat(value[1], "</to></value>");
|
|
25
|
+
if (condition === GREATER_THAN_OR_EQUAL) return "<condition>GREATER_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
|
|
26
|
+
if (condition === LESS_THAN_OR_EQUAL) return "<condition>LESS_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
|
|
27
|
+
if (condition === START_WITH) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
|
|
36
28
|
return condition;
|
|
37
29
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
|
|
31
|
+
const renderFilterSQl = filter => {
|
|
32
|
+
const {
|
|
33
|
+
field,
|
|
34
|
+
operator,
|
|
35
|
+
value
|
|
36
|
+
} = filter.element;
|
|
37
|
+
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
41
38
|
};
|
|
42
|
-
|
|
39
|
+
|
|
40
|
+
const xmlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
43
47
|
const groupXML = (item, idGroup) => {
|
|
44
48
|
if (idGroup === main) {
|
|
45
|
-
const
|
|
46
|
-
return
|
|
49
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
47
51
|
}
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
|
|
53
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
50
55
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
+
|
|
57
|
+
const filterXML = filters => {
|
|
58
|
+
const filterGroup = filters.map(filter => {
|
|
59
|
+
if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
|
|
60
|
+
return " ".concat(groupXML(filter), " ");
|
|
56
61
|
});
|
|
57
|
-
return filterGroup.join(
|
|
62
|
+
return filterGroup.join('');
|
|
58
63
|
};
|
|
59
|
-
|
|
64
|
+
|
|
65
|
+
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
60
66
|
return xml;
|
|
61
67
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=xmlFormat.js.map
|
|
68
|
+
|
|
69
|
+
export { xmlFormat };
|