@elliemae/ds-query-builder 2.0.0-alpha.10 → 2.0.0-alpha.14
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 +60 -56
- package/cjs/components/AndOrController/AndOrController.js +31 -39
- package/cjs/components/ConditionController/ConditionController.js +27 -33
- package/cjs/components/DisplayOutput/DisplayOutput.js +20 -21
- package/cjs/components/DragContainerController/DragContainerController.js +14 -16
- package/cjs/components/DragControllerRow/DragControllerRow.js +10 -6
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +22 -22
- package/cjs/components/Nestable/Nestable.js +47 -33
- package/cjs/components/Nestable/NestableItem.js +21 -13
- package/cjs/components/Nestable/actions/events.js +6 -1
- package/cjs/components/Nestable/actions/getPaths.js +11 -1
- package/cjs/components/Nestable/actions/moveItem.js +12 -5
- package/cjs/components/Nestable/actions/paths.js +15 -3
- package/cjs/components/QueryBuilderImpl.js +35 -31
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +28 -20
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +54 -39
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +5 -0
- package/cjs/components/format/format.js +8 -14
- package/cjs/components/format/sqlFormat.js +25 -23
- package/cjs/components/format/sqlSafeFormat.js +27 -25
- package/cjs/components/format/xmlFormat.js +25 -23
- package/cjs/components/helpers/actions.js +61 -36
- package/cjs/components/helpers/dependencies.js +17 -8
- package/cjs/components/helpers/store.js +38 -39
- package/cjs/index.js +2 -1
- package/cjs/propTypes.js +1 -3
- package/esm/DSQueryBuilder.js +60 -57
- package/esm/components/AndOrController/AndOrController.js +21 -24
- package/esm/components/ConditionController/ConditionController.js +21 -23
- package/esm/components/DisplayOutput/DisplayOutput.js +16 -14
- package/esm/components/DragContainerController/DragContainerController.js +11 -11
- package/esm/components/DragControllerRow/DragControllerRow.js +7 -2
- package/esm/components/FieldControllerRow/FieldControllerRow.js +22 -20
- package/esm/components/Nestable/Nestable.js +46 -32
- package/esm/components/Nestable/NestableItem.js +21 -13
- package/esm/components/Nestable/actions/events.js +6 -1
- package/esm/components/Nestable/actions/getPaths.js +11 -1
- package/esm/components/Nestable/actions/moveItem.js +12 -5
- package/esm/components/Nestable/actions/paths.js +15 -3
- package/esm/components/QueryBuilderImpl.js +35 -31
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +28 -20
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +54 -38
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +5 -0
- package/esm/components/format/format.js +8 -10
- package/esm/components/format/sqlFormat.js +25 -23
- package/esm/components/format/sqlSafeFormat.js +27 -25
- package/esm/components/format/xmlFormat.js +25 -23
- package/esm/components/helpers/actions.js +61 -36
- package/esm/components/helpers/dependencies.js +17 -8
- package/esm/components/helpers/store.js +38 -39
- package/esm/index.js +1 -1
- package/esm/propTypes.js +1 -3
- package/package.json +14 -7
- package/types/DSQueryBuilder.d.ts +170 -25
- package/types/components/AndOrController/AndOrController.d.ts +4 -4
- package/types/components/ConditionController/ConditionController.d.ts +2 -2
- package/types/components/DragContainerController/DragContainerController.d.ts +3 -3
- package/types/components/DragControllerRow/DragControllerRow.d.ts +2 -2
- package/types/propTypes.d.ts +133 -23
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
3
8
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
9
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
10
|
require('react');
|
|
@@ -18,9 +23,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
23
|
|
|
19
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
20
25
|
|
|
21
|
-
const QueryBuilderItem =
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const QueryBuilderItem = _ref => {
|
|
27
|
+
let {
|
|
28
|
+
item
|
|
29
|
+
} = _ref;
|
|
24
30
|
const {
|
|
25
31
|
element
|
|
26
32
|
} = item;
|
|
@@ -30,23 +36,25 @@ const QueryBuilderItem = ({
|
|
|
30
36
|
idGroup,
|
|
31
37
|
condition
|
|
32
38
|
} = element;
|
|
33
|
-
return /*#__PURE__*/_jsx__default["default"](QueryBuilderContext.QueryBuilderContext.Consumer, {}, void 0,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
return /*#__PURE__*/_jsx__default["default"](QueryBuilderContext.QueryBuilderContext.Consumer, {}, void 0, _ref2 => {
|
|
40
|
+
let {
|
|
41
|
+
fields,
|
|
42
|
+
handleFieldChange,
|
|
43
|
+
onAddFilter,
|
|
44
|
+
onAddFilterToGroup,
|
|
45
|
+
onAddRuleContainer,
|
|
46
|
+
onRemoveFilter,
|
|
47
|
+
showDragController,
|
|
48
|
+
handleRuleContainerOperator,
|
|
49
|
+
handleRuleContainerUnGroup,
|
|
50
|
+
step,
|
|
51
|
+
items,
|
|
52
|
+
isDraggableItem,
|
|
53
|
+
setDraggableItems,
|
|
54
|
+
singleRow,
|
|
55
|
+
toolTipZIndex
|
|
56
|
+
} = _ref2;
|
|
57
|
+
|
|
50
58
|
if (type === types.QB_DRAG_TYPES.FILTER) {
|
|
51
59
|
return /*#__PURE__*/jsxRuntime.jsx(QueryBuilderRow, _objectSpread(_objectSpread({}, element), {}, {
|
|
52
60
|
fields: fields,
|
|
@@ -2,9 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
4
|
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
5
|
+
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
13
|
var React = require('react');
|
|
6
|
-
var
|
|
7
|
-
var DSTooltip = require('@elliemae/ds-
|
|
14
|
+
var dsIcons = require('@elliemae/ds-icons');
|
|
15
|
+
var DSTooltip = require('@elliemae/ds-tooltip');
|
|
8
16
|
var dsClassnames = require('@elliemae/ds-classnames');
|
|
9
17
|
var dependencies = require('../helpers/dependencies.js');
|
|
10
18
|
var ConditionController = require('../ConditionController/ConditionController.js');
|
|
@@ -16,31 +24,31 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
24
|
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
17
25
|
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
18
26
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
|
-
var AlertsDetail__default = /*#__PURE__*/_interopDefaultLegacy(AlertsDetail);
|
|
20
27
|
|
|
21
28
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
22
29
|
|
|
23
30
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
24
31
|
|
|
25
|
-
const RenderField =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const RenderField = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
target,
|
|
35
|
+
component,
|
|
36
|
+
valueProp,
|
|
37
|
+
additionalInfo,
|
|
38
|
+
handleMouseEnterInput,
|
|
39
|
+
handleMouseLeaveInput,
|
|
40
|
+
onChangeHandler,
|
|
41
|
+
hasError
|
|
42
|
+
} = _ref;
|
|
35
43
|
const ref = React__default["default"].useRef();
|
|
36
|
-
const id = React__default["default"].useMemo(() =>
|
|
44
|
+
const id = React__default["default"].useMemo(() => "el_".concat(String.fromCharCode(65 + Math.floor(Math.random() * 26))), []);
|
|
37
45
|
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
38
|
-
className:
|
|
46
|
+
className: "em-ds-query-builder-row-input child-type-".concat(target, " ").concat(hasError && hasError.error ? 'row-input-error' : ''),
|
|
39
47
|
onMouseDownCapture: () => {
|
|
40
48
|
var _ref$current;
|
|
41
49
|
|
|
42
50
|
// eslint-disable-next-line no-underscore-dangle
|
|
43
|
-
const _refInput = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector(
|
|
51
|
+
const _refInput = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("#".concat(id));
|
|
44
52
|
|
|
45
53
|
if (_refInput && _refInput.focus) setTimeout(_refInput.focus());
|
|
46
54
|
handleMouseEnterInput();
|
|
@@ -55,19 +63,26 @@ const RenderField = ({
|
|
|
55
63
|
onChange: (e, extraData) => onChangeHandler(e, target, extraData),
|
|
56
64
|
value: valueProp != null ? valueProp : '',
|
|
57
65
|
checked: valueProp === true,
|
|
58
|
-
additionalInfo: additionalInfo ? additionalInfo[target] : additionalInfo || {}
|
|
66
|
+
additionalInfo: additionalInfo ? additionalInfo[target] : additionalInfo || {},
|
|
67
|
+
'aria-invalid': Boolean(hasError)
|
|
59
68
|
})
|
|
60
|
-
}), hasError && hasError.errorMessage ? /*#__PURE__*/_jsx__default["default"]("
|
|
69
|
+
}), hasError && hasError.errorMessage ? /*#__PURE__*/_jsx__default["default"]("div", {
|
|
70
|
+
style: {
|
|
71
|
+
width: '40px'
|
|
72
|
+
}
|
|
73
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](DSTooltip.DSTooltipV3, {
|
|
74
|
+
text: hasError.errorMessage
|
|
75
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"]("div", {
|
|
76
|
+
tabIndex: 0,
|
|
61
77
|
className: "row-icon-alert",
|
|
62
|
-
"data-testid": "qb-error-state-icon"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
})) : null); // return React.useMemo(
|
|
78
|
+
"data-testid": "qb-error-state-icon",
|
|
79
|
+
role: "alert"
|
|
80
|
+
}, void 0, /*#__PURE__*/_jsx__default["default"](dsIcons.AlertsDetail, {
|
|
81
|
+
width: 20,
|
|
82
|
+
height: 20,
|
|
83
|
+
color: ['danger', 900],
|
|
84
|
+
title: hasError.errorMessage
|
|
85
|
+
})))) : null); // return React.useMemo(
|
|
71
86
|
// () => (
|
|
72
87
|
// <div
|
|
73
88
|
// className={`em-ds-query-builder-row-input child-type-${target}`}
|
|
@@ -99,31 +114,31 @@ class QueryBuilderRow extends React.Component {
|
|
|
99
114
|
constructor(props) {
|
|
100
115
|
super(props);
|
|
101
116
|
|
|
102
|
-
|
|
117
|
+
this.handleMouseEnterRow = () => {};
|
|
103
118
|
|
|
104
|
-
|
|
119
|
+
this.handleMouseLeaveRow = () => {
|
|
105
120
|
this.handleTooltipRow(false);
|
|
106
|
-
}
|
|
121
|
+
};
|
|
107
122
|
|
|
108
|
-
|
|
123
|
+
this.handleMouseEnterInput = () => {
|
|
109
124
|
const {
|
|
110
125
|
setDraggableItems
|
|
111
126
|
} = this.props;
|
|
112
127
|
setDraggableItems(false);
|
|
113
|
-
}
|
|
128
|
+
};
|
|
114
129
|
|
|
115
|
-
|
|
130
|
+
this.handleMouseLeaveInput = () => {
|
|
116
131
|
const {
|
|
117
132
|
setDraggableItems
|
|
118
133
|
} = this.props;
|
|
119
134
|
setDraggableItems(true);
|
|
120
|
-
}
|
|
135
|
+
};
|
|
121
136
|
|
|
122
|
-
|
|
137
|
+
this.handleTooltipRow = isOpen => {
|
|
123
138
|
this.setState({
|
|
124
139
|
isOpen
|
|
125
140
|
});
|
|
126
|
-
}
|
|
141
|
+
};
|
|
127
142
|
|
|
128
143
|
this.state = {
|
|
129
144
|
isOpen: false
|
|
@@ -156,8 +171,8 @@ class QueryBuilderRow extends React.Component {
|
|
|
156
171
|
idGroup,
|
|
157
172
|
additionalInfo: _objectSpread(_objectSpread({}, additionalInfo), {}, {
|
|
158
173
|
[target]: extraData,
|
|
159
|
-
[
|
|
160
|
-
[
|
|
174
|
+
["".concat(target, "_error")]: hasError,
|
|
175
|
+
["".concat(target, "_touched")]: true
|
|
161
176
|
}),
|
|
162
177
|
target
|
|
163
178
|
});
|
|
@@ -212,7 +227,7 @@ class QueryBuilderRow extends React.Component {
|
|
|
212
227
|
const {
|
|
213
228
|
[target]: valueProp
|
|
214
229
|
} = this.props;
|
|
215
|
-
const isTouched = additionalInfo && additionalInfo[
|
|
230
|
+
const isTouched = additionalInfo && additionalInfo["".concat(target, "_touched")];
|
|
216
231
|
const hasError = renderField && renderField.validation ? renderField.validation(valueProp, {
|
|
217
232
|
field,
|
|
218
233
|
operator,
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
5
10
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
11
|
var React = require('react');
|
|
7
12
|
var GrowRight = require('@elliemae/ds-shared/Animations/GrowRight');
|
|
@@ -1,35 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
3
|
var sqlFormat = require('./sqlFormat.js');
|
|
5
4
|
var xmlFormat = require('./xmlFormat.js');
|
|
6
5
|
var sqlSafeFormat = require('./sqlSafeFormat.js');
|
|
7
6
|
|
|
8
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
-
|
|
10
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
11
|
-
|
|
12
7
|
class QueryBuilderFormat {
|
|
13
8
|
constructor() {
|
|
14
|
-
|
|
9
|
+
this.format = {
|
|
15
10
|
defaultFormat: query => query,
|
|
16
11
|
sqlFormat: sqlFormat.sqlFormat,
|
|
17
12
|
xmlFormat: xmlFormat.xmlFormat,
|
|
18
13
|
sqlSafeFormat: sqlSafeFormat.sqlSafeFormat
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
_defineProperty__default["default"](this, "currentFormat", 'sqlFormat');
|
|
14
|
+
};
|
|
15
|
+
this.currentFormat = 'sqlFormat';
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
this.setDefaultFormat = formatName => {
|
|
24
18
|
if (this.format[formatName]) this.currentFormat = formatName;
|
|
25
|
-
}
|
|
19
|
+
};
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
28
22
|
|
|
29
|
-
|
|
23
|
+
this.run = (query, formatName) => {
|
|
30
24
|
if (this.format[formatName]) return this.format[formatName](query);
|
|
31
25
|
return this.format[this.currentFormat](query);
|
|
32
|
-
}
|
|
26
|
+
};
|
|
33
27
|
}
|
|
34
28
|
|
|
35
29
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const conditionSql = (condition, value) => {
|
|
10
10
|
const {
|
|
11
11
|
EQUAL,
|
|
@@ -19,16 +19,16 @@ const conditionSql = (condition, value) => {
|
|
|
19
19
|
LESS_THAN_OR_EQUAL,
|
|
20
20
|
START_WITH
|
|
21
21
|
} = types.QB_OPERATOR_TYPES;
|
|
22
|
-
if (condition === EQUAL) return
|
|
23
|
-
if (condition === NOT_EQUAL) return
|
|
24
|
-
if (condition === GREATER_THAN) return
|
|
25
|
-
if (condition === LESS_THAN) return
|
|
26
|
-
if (condition === CONTAINS) return
|
|
27
|
-
if (condition === NOT_CONTAINS) return
|
|
28
|
-
if (condition === BETWEEN) return
|
|
29
|
-
if (condition === GREATER_THAN_OR_EQUAL) return
|
|
30
|
-
if (condition === LESS_THAN_OR_EQUAL) return
|
|
31
|
-
if (condition === START_WITH) return
|
|
22
|
+
if (condition === EQUAL) return " = '".concat(value, "'");
|
|
23
|
+
if (condition === NOT_EQUAL) return " <> '".concat(value, "'");
|
|
24
|
+
if (condition === GREATER_THAN) return " > ".concat(value);
|
|
25
|
+
if (condition === LESS_THAN) return " < ".concat(value);
|
|
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, "%'");
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,33 +38,35 @@ const renderFilterSQl = filter => {
|
|
|
38
38
|
operator,
|
|
39
39
|
value
|
|
40
40
|
} = filter.element;
|
|
41
|
-
return
|
|
41
|
+
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const sqlFormat =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const sqlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
50
|
+
|
|
49
51
|
const groupSql = (item, idGroup) => {
|
|
50
52
|
if (idGroup === main) {
|
|
51
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
52
|
-
return
|
|
54
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
56
|
-
return
|
|
58
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
const filterSql = (filters, groupCondition) => {
|
|
60
62
|
const filterGroup = filters.map(filter => {
|
|
61
|
-
if (filter.element.type === 'filter') return
|
|
62
|
-
return
|
|
63
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
64
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
63
65
|
});
|
|
64
66
|
return filterGroup.join(groupCondition);
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
const sql =
|
|
69
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
68
70
|
return sql;
|
|
69
71
|
};
|
|
70
72
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
10
10
|
|
|
11
11
|
const conditionSql = (condition, value) => {
|
|
@@ -22,17 +22,17 @@ const conditionSql = (condition, value) => {
|
|
|
22
22
|
START_WITH
|
|
23
23
|
} = types.QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
|
|
24
24
|
|
|
25
|
-
const valueDisplay = isNaN(value) ?
|
|
26
|
-
if (condition === EQUAL) return
|
|
27
|
-
if (condition === NOT_EQUAL) return
|
|
28
|
-
if (condition === GREATER_THAN) return
|
|
29
|
-
if (condition === LESS_THAN) return
|
|
30
|
-
if (condition === CONTAINS) return
|
|
31
|
-
if (condition === NOT_CONTAINS) return
|
|
32
|
-
if (condition === BETWEEN) return
|
|
33
|
-
if (condition === GREATER_THAN_OR_EQUAL) return
|
|
34
|
-
if (condition === LESS_THAN_OR_EQUAL) return
|
|
35
|
-
if (condition === START_WITH) return
|
|
25
|
+
const valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
|
|
26
|
+
if (condition === EQUAL) return " = ".concat(valueDisplay);
|
|
27
|
+
if (condition === NOT_EQUAL) return " <> ".concat(valueDisplay);
|
|
28
|
+
if (condition === GREATER_THAN) return " > ".concat(valueDisplay);
|
|
29
|
+
if (condition === LESS_THAN) return " < ".concat(valueDisplay);
|
|
30
|
+
if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
|
|
31
|
+
if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
|
|
32
|
+
if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
|
|
33
|
+
if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
|
|
34
|
+
if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
|
|
35
|
+
if (condition === START_WITH) return " LIKE '".concat(value, "%'");
|
|
36
36
|
return condition;
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -44,34 +44,36 @@ const renderFilterSQl = filter => {
|
|
|
44
44
|
} = filter.element; // eslint-disable-next-line no-restricted-globals
|
|
45
45
|
|
|
46
46
|
const fieldDisplay = // eslint-disable-next-line no-restricted-globals
|
|
47
|
-
/[.]/.test(field) || !isNaN(field) ?
|
|
48
|
-
return
|
|
47
|
+
/[.]/.test(field) || !isNaN(field) ? "\\\"".concat(field, "\\\"") : field;
|
|
48
|
+
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
const sqlSafeFormat =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
const sqlSafeFormat = _ref => {
|
|
52
|
+
let {
|
|
53
|
+
main,
|
|
54
|
+
mapGroups,
|
|
55
|
+
items
|
|
56
|
+
} = _ref;
|
|
57
|
+
|
|
56
58
|
const groupSql = (item, idGroup) => {
|
|
57
59
|
if (idGroup === main) {
|
|
58
60
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
59
|
-
return
|
|
61
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
63
|
-
return
|
|
65
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
64
66
|
};
|
|
65
67
|
|
|
66
68
|
const filterSql = (filters, groupCondition) => {
|
|
67
69
|
const filterGroup = filters.map(filter => {
|
|
68
|
-
if (filter.element.type === 'filter') return
|
|
69
|
-
return
|
|
70
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
71
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
70
72
|
});
|
|
71
73
|
return filterGroup.join(groupCondition);
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
const sql =
|
|
76
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
75
77
|
return sql;
|
|
76
78
|
};
|
|
77
79
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
5
7
|
var types = require('../helpers/types.js');
|
|
6
8
|
|
|
7
|
-
/* eslint-disable complexity */
|
|
8
|
-
|
|
9
9
|
const conditionSql = (condition, value) => {
|
|
10
10
|
const {
|
|
11
11
|
EQUAL,
|
|
@@ -19,16 +19,16 @@ const conditionSql = (condition, value) => {
|
|
|
19
19
|
LESS_THAN_OR_EQUAL,
|
|
20
20
|
START_WITH
|
|
21
21
|
} = types.QB_OPERATOR_TYPES;
|
|
22
|
-
if (condition === EQUAL) return
|
|
23
|
-
if (condition === NOT_EQUAL) return
|
|
24
|
-
if (condition === GREATER_THAN) return
|
|
25
|
-
if (condition === LESS_THAN) return
|
|
26
|
-
if (condition === CONTAINS) return
|
|
27
|
-
if (condition === NOT_CONTAINS) return
|
|
28
|
-
if (condition === BETWEEN) return
|
|
29
|
-
if (condition === GREATER_THAN_OR_EQUAL) return
|
|
30
|
-
if (condition === LESS_THAN_OR_EQUAL) return
|
|
31
|
-
if (condition === START_WITH) return
|
|
22
|
+
if (condition === EQUAL) return "<condition>EQUAL</condition><value>".concat(value, "</value>");
|
|
23
|
+
if (condition === NOT_EQUAL) return "<condition>NOT_EQUAL</condition><value>".concat(value, "</value>");
|
|
24
|
+
if (condition === GREATER_THAN) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
|
|
25
|
+
if (condition === LESS_THAN) return "<condition>LESS_THAN</condition><value>".concat(value, "</value>");
|
|
26
|
+
if (condition === CONTAINS) return "<condition>LIKE</condition><value>".concat(value, "</value>");
|
|
27
|
+
if (condition === NOT_CONTAINS) return "<condition>NOT_LIKE</condition><value>".concat(value, "</value>");
|
|
28
|
+
if (condition === BETWEEN) return "<condition>NOT_LIKE</condition><value><from>".concat(value[0], "</from><to>").concat(value[1], "</to></value>");
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return "<condition>GREATER_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return "<condition>LESS_THAN_OR_EQUAL</condition><value>".concat(value, "</value>");
|
|
31
|
+
if (condition === START_WITH) return "<condition>GREATER_THAN</condition><value>".concat(value, "</value>");
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,33 +38,35 @@ const renderFilterSQl = filter => {
|
|
|
38
38
|
operator,
|
|
39
39
|
value
|
|
40
40
|
} = filter.element;
|
|
41
|
-
return
|
|
41
|
+
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const xmlFormat =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
const xmlFormat = _ref => {
|
|
45
|
+
let {
|
|
46
|
+
main,
|
|
47
|
+
mapGroups,
|
|
48
|
+
items
|
|
49
|
+
} = _ref;
|
|
50
|
+
|
|
49
51
|
const groupXML = (item, idGroup) => {
|
|
50
52
|
if (idGroup === main) {
|
|
51
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
52
|
-
return
|
|
54
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
56
|
-
return
|
|
58
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
const filterXML = filters => {
|
|
60
62
|
const filterGroup = filters.map(filter => {
|
|
61
|
-
if (filter.element.type === 'filter') return
|
|
62
|
-
return
|
|
63
|
+
if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
|
|
64
|
+
return " ".concat(groupXML(filter), " ");
|
|
63
65
|
});
|
|
64
66
|
return filterGroup.join('');
|
|
65
67
|
};
|
|
66
68
|
|
|
67
|
-
const xml =
|
|
69
|
+
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
68
70
|
return xml;
|
|
69
71
|
};
|
|
70
72
|
|