@elliemae/ds-query-builder 2.4.2-rc.9 → 2.4.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/components/AndOrController/AndOrController.js +5 -5
- package/cjs/components/ConditionController/ConditionController.js +1 -1
- package/cjs/components/DragContainerController/DragContainerController.js +1 -1
- package/cjs/components/Nestable/Nestable.js +3 -3
- package/cjs/components/Nestable/NestableItem.js +3 -3
- package/cjs/components/Nestable/actions/events.js +1 -1
- package/cjs/components/Nestable/actions/getPaths.js +0 -1
- package/cjs/components/Nestable/actions/paths.js +0 -1
- package/cjs/components/QueryBuilderImpl.js +1 -1
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +6 -9
- package/cjs/components/format/sqlFormat.js +16 -16
- package/cjs/components/format/sqlSafeFormat.js +18 -18
- package/cjs/components/format/xmlFormat.js +16 -16
- package/cjs/components/helpers/actions.js +2 -2
- package/cjs/propTypes.js +3 -1
- package/esm/components/AndOrController/AndOrController.js +5 -5
- package/esm/components/ConditionController/ConditionController.js +1 -1
- package/esm/components/DragContainerController/DragContainerController.js +1 -1
- package/esm/components/Nestable/Nestable.js +3 -3
- package/esm/components/Nestable/NestableItem.js +3 -3
- package/esm/components/Nestable/actions/events.js +1 -1
- package/esm/components/Nestable/actions/getPaths.js +0 -1
- package/esm/components/Nestable/actions/paths.js +0 -1
- package/esm/components/QueryBuilderImpl.js +1 -1
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +6 -9
- package/esm/components/format/sqlFormat.js +16 -16
- package/esm/components/format/sqlSafeFormat.js +18 -18
- package/esm/components/format/xmlFormat.js +16 -16
- package/esm/components/helpers/actions.js +2 -2
- package/esm/propTypes.js +3 -1
- package/package.json +12 -12
|
@@ -111,12 +111,12 @@ class AndOrController extends React.Component {
|
|
|
111
111
|
} = this.state;
|
|
112
112
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
113
113
|
ref: this.myRef,
|
|
114
|
-
className:
|
|
114
|
+
className: `${cssClassName} ${mainModifier(condition ? 'active' : 'default')} step-${step} ${isMain ? 'is-main-group-join' : ''}` // onMouseEnter={this.handleMouseEnterRow}
|
|
115
115
|
,
|
|
116
116
|
onMouseLeave: this.handleMouseLeaveRow // onMouseMove={this.handleMouseMove}
|
|
117
117
|
,
|
|
118
118
|
children: /*#__PURE__*/_jsx__default["default"]("div", {
|
|
119
|
-
className:
|
|
119
|
+
className: `${classNameBlock('content')} step-${step}`
|
|
120
120
|
}, void 0, /*#__PURE__*/_jsx__default["default"](DSTooltip__default["default"], {
|
|
121
121
|
delayClose: delayClose,
|
|
122
122
|
delayOpen: delayOpen,
|
|
@@ -134,8 +134,8 @@ class AndOrController extends React.Component {
|
|
|
134
134
|
style: {
|
|
135
135
|
transition: '0.2s',
|
|
136
136
|
position: 'absolute',
|
|
137
|
-
top:
|
|
138
|
-
right:
|
|
137
|
+
top: `${top}px`,
|
|
138
|
+
right: `${right}px`
|
|
139
139
|
},
|
|
140
140
|
children: [/*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
141
141
|
buttonType: buttonActionType,
|
|
@@ -169,7 +169,7 @@ class AndOrController extends React.Component {
|
|
|
169
169
|
}),
|
|
170
170
|
tooltipType: DSTooltip.TooltipType.TOOLBAR,
|
|
171
171
|
triggerComponent: /*#__PURE__*/_jsx__default["default"]("div", {
|
|
172
|
-
className:
|
|
172
|
+
className: `${classNameBlock('trigger-controller')} ${showDragController ? classNameBlockModifier('draggable', 'trigger-controller') : ''} step-${step}`
|
|
173
173
|
}, void 0, /*#__PURE__*/_jsx__default["default"]("div", {
|
|
174
174
|
className: classNameElement('condition-display')
|
|
175
175
|
}, void 0, /*#__PURE__*/_jsx__default["default"]("span", {
|
|
@@ -73,7 +73,7 @@ const ConditionController = _ref => {
|
|
|
73
73
|
}
|
|
74
74
|
}), /*#__PURE__*/_jsx__default["default"](DSButton__default["default"], {
|
|
75
75
|
buttonType: buttonActionType,
|
|
76
|
-
className:
|
|
76
|
+
className: `${classNameElement('add-rule-container')} no-border-right`,
|
|
77
77
|
icon: _ParenthesisAdd || (_ParenthesisAdd = /*#__PURE__*/_jsx__default["default"](dsIcons.ParenthesisAdd, {})),
|
|
78
78
|
onClick: onAddRuleContainer,
|
|
79
79
|
size: buttonActionSize,
|
|
@@ -24,7 +24,7 @@ const DragContainerController = _ref => {
|
|
|
24
24
|
cssClassName
|
|
25
25
|
} = dsClassnames.convertPropToCssClassName('query-builder-drag-group');
|
|
26
26
|
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
27
|
-
className:
|
|
27
|
+
className: `${cssClassName}`
|
|
28
28
|
}, void 0, /*#__PURE__*/_jsx__default["default"](Icon, {
|
|
29
29
|
color: color,
|
|
30
30
|
size: size
|
|
@@ -248,7 +248,7 @@ class Nestable extends React.Component {
|
|
|
248
248
|
const {
|
|
249
249
|
dragItem
|
|
250
250
|
} = this.state;
|
|
251
|
-
const el = document.querySelector(
|
|
251
|
+
const el = document.querySelector(`.nestable-${group} .nestable-item-${dragItem.id}`);
|
|
252
252
|
let listStyles = {};
|
|
253
253
|
|
|
254
254
|
if (el) {
|
|
@@ -290,11 +290,11 @@ class Nestable extends React.Component {
|
|
|
290
290
|
let childClass = 'single';
|
|
291
291
|
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
292
292
|
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
293
|
-
className: cn__default["default"]('nestable',
|
|
293
|
+
className: cn__default["default"]('nestable', `nestable-${group}`, {
|
|
294
294
|
'is-drag-active': dragItem
|
|
295
295
|
})
|
|
296
296
|
}, void 0, /*#__PURE__*/_jsx__default["default"]("ol", {
|
|
297
|
-
className:
|
|
297
|
+
className: `nestable-list nestable-group nestable-child-count-${childClass}`
|
|
298
298
|
}, void 0, items.map((item, i) => /*#__PURE__*/_jsx__default["default"](NestableItem, {
|
|
299
299
|
index: i,
|
|
300
300
|
isAndItem: isAndItem,
|
|
@@ -47,7 +47,7 @@ const NestableItem = _ref => {
|
|
|
47
47
|
const isOrGroup = item.element.type === 'group' && (item.element.condition === '' || item.element.condition === false);
|
|
48
48
|
const isAndGroup = item.element.type === 'group' && !(item.element.condition === '' || item.element.condition === false);
|
|
49
49
|
const itemProps = {
|
|
50
|
-
className: cn__default["default"](
|
|
50
|
+
className: cn__default["default"](`nestable-item${isCopy ? '-copy' : ''}`, `nestable-item${isCopy ? '-copy' : ''}-${item.id}`, `nestable-item-type-${item.element.type}`, {
|
|
51
51
|
'is-or-group': isOrGroup,
|
|
52
52
|
'is-and-group': isAndGroup,
|
|
53
53
|
'is-and-filter': item.element.type === 'filter' && isAndItem,
|
|
@@ -87,7 +87,7 @@ const NestableItem = _ref => {
|
|
|
87
87
|
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
88
88
|
return /*#__PURE__*/jsxRuntime.jsxs("li", _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
89
89
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
90
|
-
className:
|
|
90
|
+
className: `nestable-item-name nestable-item-name--${item.element.type} `
|
|
91
91
|
}, rowProps), {}, {
|
|
92
92
|
children: renderItem({
|
|
93
93
|
item,
|
|
@@ -95,7 +95,7 @@ const NestableItem = _ref => {
|
|
|
95
95
|
index
|
|
96
96
|
})
|
|
97
97
|
})), hasChildren && item.element.type === 'group' && !isCollapsed && /*#__PURE__*/_jsx__default["default"]("ol", {
|
|
98
|
-
className:
|
|
98
|
+
className: `nestable-list nestable-child-count-${childClass} `
|
|
99
99
|
}, void 0, item[childrenProp].map((currentitem, i) => /*#__PURE__*/_jsx__default["default"](NestableItem, {
|
|
100
100
|
index: i,
|
|
101
101
|
isAndItem: isAndGroup,
|
|
@@ -59,7 +59,7 @@ function onMouseMove(e) {
|
|
|
59
59
|
clientY
|
|
60
60
|
} = e;
|
|
61
61
|
const transformProps = utils.getTransformProps(clientX, clientY);
|
|
62
|
-
const elCopy = document.querySelector(
|
|
62
|
+
const elCopy = document.querySelector(`.nestable-${group} .nestable-drag-layer > .nestable-list`);
|
|
63
63
|
|
|
64
64
|
if (!this.elCopyStyles) {
|
|
65
65
|
const offset = utils.getOffsetRect(this.el);
|
|
@@ -9,7 +9,6 @@ require('core-js/modules/esnext.iterator.constructor.js');
|
|
|
9
9
|
require('core-js/modules/esnext.iterator.every.js');
|
|
10
10
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
11
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
12
|
|
|
14
13
|
function getRealNextPath(prevPath, nextPath) {
|
|
15
14
|
const {
|
|
@@ -9,7 +9,6 @@ require('core-js/modules/esnext.iterator.constructor.js');
|
|
|
9
9
|
require('core-js/modules/esnext.iterator.every.js');
|
|
10
10
|
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
11
|
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
12
|
|
|
14
13
|
function getRealNextPath(prevPath, nextPath) {
|
|
15
14
|
const {
|
|
@@ -272,7 +272,7 @@ class QueryBuilderImpl extends React.Component {
|
|
|
272
272
|
singleRow
|
|
273
273
|
}
|
|
274
274
|
}, void 0, /*#__PURE__*/jsxRuntime.jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
275
|
-
className:
|
|
275
|
+
className: `nested-main-group ${condition !== true ? 'is-or-group' : 'is-and-groupL'} ${singleRow ? 'query-main-single-row' : 'query-main-multiple-row'}`,
|
|
276
276
|
children: [/*#__PURE__*/_jsx__default["default"](Nestable, {
|
|
277
277
|
isAndItem: condition === true,
|
|
278
278
|
isDraggableItem: this.isDraggableItem,
|
|
@@ -2,7 +2,6 @@
|
|
|
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
5
|
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
6
|
require('core-js/modules/esnext.iterator.map.js');
|
|
8
7
|
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
@@ -41,14 +40,12 @@ const RenderField = _ref => {
|
|
|
41
40
|
hasError
|
|
42
41
|
} = _ref;
|
|
43
42
|
const ref = React__default["default"].useRef();
|
|
44
|
-
const id = React__default["default"].useMemo(() =>
|
|
43
|
+
const id = React__default["default"].useMemo(() => `el_${String.fromCharCode(65 + Math.floor(Math.random() * 26))}`, []);
|
|
45
44
|
return /*#__PURE__*/_jsx__default["default"]("div", {
|
|
46
|
-
className:
|
|
45
|
+
className: `em-ds-query-builder-row-input child-type-${target} ${hasError && hasError.error ? 'row-input-error' : ''}`,
|
|
47
46
|
onMouseDownCapture: () => {
|
|
48
|
-
var _ref$current;
|
|
49
|
-
|
|
50
47
|
// eslint-disable-next-line no-underscore-dangle
|
|
51
|
-
const _refInput =
|
|
48
|
+
const _refInput = ref.current?.querySelector(`#${id}`);
|
|
52
49
|
|
|
53
50
|
if (_refInput && _refInput.focus) setTimeout(_refInput.focus());
|
|
54
51
|
handleMouseEnterInput();
|
|
@@ -171,8 +168,8 @@ class QueryBuilderRow extends React.Component {
|
|
|
171
168
|
idGroup,
|
|
172
169
|
additionalInfo: _objectSpread(_objectSpread({}, additionalInfo), {}, {
|
|
173
170
|
[target]: extraData,
|
|
174
|
-
[
|
|
175
|
-
[
|
|
171
|
+
[`${target}_error`]: hasError,
|
|
172
|
+
[`${target}_touched`]: true
|
|
176
173
|
}),
|
|
177
174
|
target
|
|
178
175
|
});
|
|
@@ -238,7 +235,7 @@ class QueryBuilderRow extends React.Component {
|
|
|
238
235
|
const {
|
|
239
236
|
[target]: valueProp
|
|
240
237
|
} = this.props;
|
|
241
|
-
const isTouched = additionalInfo && additionalInfo[
|
|
238
|
+
const isTouched = additionalInfo && additionalInfo[`${target}_touched`];
|
|
242
239
|
const hasError = renderField && renderField.validation ? renderField.validation(valueProp, {
|
|
243
240
|
field,
|
|
244
241
|
operator,
|
|
@@ -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 ` = '${value}'`;
|
|
23
|
+
if (condition === NOT_EQUAL) return ` <> '${value}'`;
|
|
24
|
+
if (condition === GREATER_THAN) return ` > ${value}`;
|
|
25
|
+
if (condition === LESS_THAN) return ` < ${value}`;
|
|
26
|
+
if (condition === CONTAINS) return ` LIKE '%${value}%'`;
|
|
27
|
+
if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;
|
|
28
|
+
if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;
|
|
31
|
+
if (condition === START_WITH) return ` LIKE '${value}%'`;
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ const renderFilterSQl = filter => {
|
|
|
38
38
|
operator,
|
|
39
39
|
value
|
|
40
40
|
} = filter.element;
|
|
41
|
-
return
|
|
41
|
+
return `${field} ${conditionSql(operator, value) || ''}`;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const sqlFormat = _ref => {
|
|
@@ -51,22 +51,22 @@ const sqlFormat = _ref => {
|
|
|
51
51
|
const groupSql = (item, idGroup) => {
|
|
52
52
|
if (idGroup === main) {
|
|
53
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
54
|
-
return
|
|
54
|
+
return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
58
|
-
return
|
|
58
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const filterSql = (filters, groupCondition) => {
|
|
62
62
|
const filterGroup = filters.map(filter => {
|
|
63
|
-
if (filter.element.type === 'filter') return
|
|
64
|
-
return
|
|
63
|
+
if (filter.element.type === 'filter') return ` ${renderFilterSQl(filter)} `;
|
|
64
|
+
return ` ${groupSql(filter) || ''} `;
|
|
65
65
|
});
|
|
66
66
|
return filterGroup.join(groupCondition);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const sql =
|
|
69
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;
|
|
70
70
|
return sql;
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -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) ? `'${value}'` : value;
|
|
26
|
+
if (condition === EQUAL) return ` = ${valueDisplay}`;
|
|
27
|
+
if (condition === NOT_EQUAL) return ` <> ${valueDisplay}`;
|
|
28
|
+
if (condition === GREATER_THAN) return ` > ${valueDisplay}`;
|
|
29
|
+
if (condition === LESS_THAN) return ` < ${valueDisplay}`;
|
|
30
|
+
if (condition === CONTAINS) return ` LIKE '%${value}%'`;
|
|
31
|
+
if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;
|
|
32
|
+
if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
33
|
+
if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;
|
|
34
|
+
if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;
|
|
35
|
+
if (condition === START_WITH) return ` LIKE '${value}%'`;
|
|
36
36
|
return condition;
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -44,8 +44,8 @@ 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) ? `\\"${field}\\"` : field;
|
|
48
|
+
return `${fieldDisplay} ${conditionSql(operator, value) || ''}`;
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const sqlSafeFormat = _ref => {
|
|
@@ -58,22 +58,22 @@ const sqlSafeFormat = _ref => {
|
|
|
58
58
|
const groupSql = (item, idGroup) => {
|
|
59
59
|
if (idGroup === main) {
|
|
60
60
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
61
|
-
return
|
|
61
|
+
return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
65
|
-
return
|
|
65
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
const filterSql = (filters, groupCondition) => {
|
|
69
69
|
const filterGroup = filters.map(filter => {
|
|
70
|
-
if (filter.element.type === 'filter') return
|
|
71
|
-
return
|
|
70
|
+
if (filter.element.type === 'filter') return ` ${renderFilterSQl(filter)} `;
|
|
71
|
+
return ` ${groupSql(filter) || ''} `;
|
|
72
72
|
});
|
|
73
73
|
return filterGroup.join(groupCondition);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
const sql =
|
|
76
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;
|
|
77
77
|
return sql;
|
|
78
78
|
};
|
|
79
79
|
|
|
@@ -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>${value}</value>`;
|
|
23
|
+
if (condition === NOT_EQUAL) return `<condition>NOT_EQUAL</condition><value>${value}</value>`;
|
|
24
|
+
if (condition === GREATER_THAN) return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
25
|
+
if (condition === LESS_THAN) return `<condition>LESS_THAN</condition><value>${value}</value>`;
|
|
26
|
+
if (condition === CONTAINS) return `<condition>LIKE</condition><value>${value}</value>`;
|
|
27
|
+
if (condition === NOT_CONTAINS) return `<condition>NOT_LIKE</condition><value>${value}</value>`;
|
|
28
|
+
if (condition === BETWEEN) return `<condition>NOT_LIKE</condition><value><from>${value[0]}</from><to>${value[1]}</to></value>`;
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return `<condition>GREATER_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return `<condition>LESS_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
31
|
+
if (condition === START_WITH) return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,7 +38,7 @@ const renderFilterSQl = filter => {
|
|
|
38
38
|
operator,
|
|
39
39
|
value
|
|
40
40
|
} = filter.element;
|
|
41
|
-
return
|
|
41
|
+
return `<filter><field>${field}</field>${conditionSql(operator, value) || ''}</filter>`;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const xmlFormat = _ref => {
|
|
@@ -51,22 +51,22 @@ const xmlFormat = _ref => {
|
|
|
51
51
|
const groupXML = (item, idGroup) => {
|
|
52
52
|
if (idGroup === main) {
|
|
53
53
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
54
|
-
return
|
|
54
|
+
return `<group value="${groupCondition}">${filterXML(item)}</group>`; // eslint-disable-line
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
58
|
-
return
|
|
58
|
+
return `<group value="${groupCondition}">${filterXML(item.children)}</group>`; // eslint-disable-line
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const filterXML = filters => {
|
|
62
62
|
const filterGroup = filters.map(filter => {
|
|
63
|
-
if (filter.element.type === 'filter') return
|
|
64
|
-
return
|
|
63
|
+
if (filter.element.type === 'filter') return `${renderFilterSQl(filter) || ''} `;
|
|
64
|
+
return ` ${groupXML(filter)} `;
|
|
65
65
|
});
|
|
66
66
|
return filterGroup.join('');
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
const xml =
|
|
69
|
+
const xml = `<xml><query>${groupXML(items, main) || ''}</query></xml>`;
|
|
70
70
|
return xml;
|
|
71
71
|
};
|
|
72
72
|
|
|
@@ -29,7 +29,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
const createNewFilter = function (idGroup) {
|
|
32
|
-
const idFilter =
|
|
32
|
+
const idFilter = `filter_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
33
33
|
return {
|
|
34
34
|
idGroup,
|
|
35
35
|
field: '',
|
|
@@ -47,7 +47,7 @@ const createNewFilter = function (idGroup) {
|
|
|
47
47
|
*/
|
|
48
48
|
|
|
49
49
|
const createNewGroup = function (parentIdGroup) {
|
|
50
|
-
const idGroup =
|
|
50
|
+
const idGroup = `group_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
51
51
|
return {
|
|
52
52
|
parentIdGroup,
|
|
53
53
|
idGroup,
|
package/cjs/propTypes.js
CHANGED
|
@@ -77,7 +77,9 @@ const props = {
|
|
|
77
77
|
|
|
78
78
|
/** remove filter callback */
|
|
79
79
|
onRemoveFilter: reactDesc.PropTypes.func.description('remove filter callback'),
|
|
80
|
-
displayFixedOutput: reactDesc.PropTypes.string.description(
|
|
80
|
+
displayFixedOutput: reactDesc.PropTypes.string.description(`Label for fixed output.Using this props it will ignore 'displayOutput' and 'displayOutputLabel'
|
|
81
|
+
and it will always render the output without the ability to close it.
|
|
82
|
+
`).defaultValue(''),
|
|
81
83
|
|
|
82
84
|
/** show output */
|
|
83
85
|
displayOutput: reactDesc.PropTypes.bool.description('show output'),
|
|
@@ -102,12 +102,12 @@ class AndOrController extends Component {
|
|
|
102
102
|
} = this.state;
|
|
103
103
|
return /*#__PURE__*/jsx("div", {
|
|
104
104
|
ref: this.myRef,
|
|
105
|
-
className:
|
|
105
|
+
className: `${cssClassName} ${mainModifier(condition ? 'active' : 'default')} step-${step} ${isMain ? 'is-main-group-join' : ''}` // onMouseEnter={this.handleMouseEnterRow}
|
|
106
106
|
,
|
|
107
107
|
onMouseLeave: this.handleMouseLeaveRow // onMouseMove={this.handleMouseMove}
|
|
108
108
|
,
|
|
109
109
|
children: /*#__PURE__*/_jsx("div", {
|
|
110
|
-
className:
|
|
110
|
+
className: `${classNameBlock('content')} step-${step}`
|
|
111
111
|
}, void 0, /*#__PURE__*/_jsx(DSTooltip, {
|
|
112
112
|
delayClose: delayClose,
|
|
113
113
|
delayOpen: delayOpen,
|
|
@@ -125,8 +125,8 @@ class AndOrController extends Component {
|
|
|
125
125
|
style: {
|
|
126
126
|
transition: '0.2s',
|
|
127
127
|
position: 'absolute',
|
|
128
|
-
top:
|
|
129
|
-
right:
|
|
128
|
+
top: `${top}px`,
|
|
129
|
+
right: `${right}px`
|
|
130
130
|
},
|
|
131
131
|
children: [/*#__PURE__*/_jsx(DSButton, {
|
|
132
132
|
buttonType: buttonActionType,
|
|
@@ -160,7 +160,7 @@ class AndOrController extends Component {
|
|
|
160
160
|
}),
|
|
161
161
|
tooltipType: TooltipType.TOOLBAR,
|
|
162
162
|
triggerComponent: /*#__PURE__*/_jsx("div", {
|
|
163
|
-
className:
|
|
163
|
+
className: `${classNameBlock('trigger-controller')} ${showDragController ? classNameBlockModifier('draggable', 'trigger-controller') : ''} step-${step}`
|
|
164
164
|
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
165
165
|
className: classNameElement('condition-display')
|
|
166
166
|
}, void 0, /*#__PURE__*/_jsx("span", {
|
|
@@ -65,7 +65,7 @@ const ConditionController = _ref => {
|
|
|
65
65
|
}
|
|
66
66
|
}), /*#__PURE__*/_jsx(DSButton, {
|
|
67
67
|
buttonType: buttonActionType,
|
|
68
|
-
className:
|
|
68
|
+
className: `${classNameElement('add-rule-container')} no-border-right`,
|
|
69
69
|
icon: _ParenthesisAdd || (_ParenthesisAdd = /*#__PURE__*/_jsx(ParenthesisAdd, {})),
|
|
70
70
|
onClick: onAddRuleContainer,
|
|
71
71
|
size: buttonActionSize,
|
|
@@ -18,7 +18,7 @@ const DragContainerController = _ref => {
|
|
|
18
18
|
cssClassName
|
|
19
19
|
} = convertPropToCssClassName('query-builder-drag-group');
|
|
20
20
|
return /*#__PURE__*/_jsx("div", {
|
|
21
|
-
className:
|
|
21
|
+
className: `${cssClassName}`
|
|
22
22
|
}, void 0, /*#__PURE__*/_jsx(Icon, {
|
|
23
23
|
color: color,
|
|
24
24
|
size: size
|
|
@@ -240,7 +240,7 @@ class Nestable extends Component {
|
|
|
240
240
|
const {
|
|
241
241
|
dragItem
|
|
242
242
|
} = this.state;
|
|
243
|
-
const el = document.querySelector(
|
|
243
|
+
const el = document.querySelector(`.nestable-${group} .nestable-item-${dragItem.id}`);
|
|
244
244
|
let listStyles = {};
|
|
245
245
|
|
|
246
246
|
if (el) {
|
|
@@ -282,11 +282,11 @@ class Nestable extends Component {
|
|
|
282
282
|
let childClass = 'single';
|
|
283
283
|
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
284
284
|
return /*#__PURE__*/_jsx("div", {
|
|
285
|
-
className: cn('nestable',
|
|
285
|
+
className: cn('nestable', `nestable-${group}`, {
|
|
286
286
|
'is-drag-active': dragItem
|
|
287
287
|
})
|
|
288
288
|
}, void 0, /*#__PURE__*/_jsx("ol", {
|
|
289
|
-
className:
|
|
289
|
+
className: `nestable-list nestable-group nestable-child-count-${childClass}`
|
|
290
290
|
}, void 0, items.map((item, i) => /*#__PURE__*/_jsx(NestableItem, {
|
|
291
291
|
index: i,
|
|
292
292
|
isAndItem: isAndItem,
|
|
@@ -39,7 +39,7 @@ const NestableItem = _ref => {
|
|
|
39
39
|
const isOrGroup = item.element.type === 'group' && (item.element.condition === '' || item.element.condition === false);
|
|
40
40
|
const isAndGroup = item.element.type === 'group' && !(item.element.condition === '' || item.element.condition === false);
|
|
41
41
|
const itemProps = {
|
|
42
|
-
className: cn(
|
|
42
|
+
className: cn(`nestable-item${isCopy ? '-copy' : ''}`, `nestable-item${isCopy ? '-copy' : ''}-${item.id}`, `nestable-item-type-${item.element.type}`, {
|
|
43
43
|
'is-or-group': isOrGroup,
|
|
44
44
|
'is-and-group': isAndGroup,
|
|
45
45
|
'is-and-filter': item.element.type === 'filter' && isAndItem,
|
|
@@ -79,7 +79,7 @@ const NestableItem = _ref => {
|
|
|
79
79
|
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
80
80
|
return /*#__PURE__*/jsxs("li", _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
81
81
|
children: [/*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
82
|
-
className:
|
|
82
|
+
className: `nestable-item-name nestable-item-name--${item.element.type} `
|
|
83
83
|
}, rowProps), {}, {
|
|
84
84
|
children: renderItem({
|
|
85
85
|
item,
|
|
@@ -87,7 +87,7 @@ const NestableItem = _ref => {
|
|
|
87
87
|
index
|
|
88
88
|
})
|
|
89
89
|
})), hasChildren && item.element.type === 'group' && !isCollapsed && /*#__PURE__*/_jsx("ol", {
|
|
90
|
-
className:
|
|
90
|
+
className: `nestable-list nestable-child-count-${childClass} `
|
|
91
91
|
}, void 0, item[childrenProp].map((currentitem, i) => /*#__PURE__*/_jsx(NestableItem, {
|
|
92
92
|
index: i,
|
|
93
93
|
isAndItem: isAndGroup,
|
|
@@ -51,7 +51,7 @@ function onMouseMove(e) {
|
|
|
51
51
|
clientY
|
|
52
52
|
} = e;
|
|
53
53
|
const transformProps = getTransformProps(clientX, clientY);
|
|
54
|
-
const elCopy = document.querySelector(
|
|
54
|
+
const elCopy = document.querySelector(`.nestable-${group} .nestable-drag-layer > .nestable-list`);
|
|
55
55
|
|
|
56
56
|
if (!this.elCopyStyles) {
|
|
57
57
|
const offset = getOffsetRect(this.el);
|
|
@@ -5,7 +5,6 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.every.js';
|
|
6
6
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
7
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
8
|
|
|
10
9
|
function getRealNextPath(prevPath, nextPath) {
|
|
11
10
|
const {
|
|
@@ -5,7 +5,6 @@ import 'core-js/modules/esnext.iterator.constructor.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.every.js';
|
|
6
6
|
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
7
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
8
|
|
|
10
9
|
function getRealNextPath(prevPath, nextPath) {
|
|
11
10
|
const {
|
|
@@ -264,7 +264,7 @@ class QueryBuilderImpl extends Component {
|
|
|
264
264
|
singleRow
|
|
265
265
|
}
|
|
266
266
|
}, void 0, /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({}, containerProps), {}, {
|
|
267
|
-
className:
|
|
267
|
+
className: `nested-main-group ${condition !== true ? 'is-or-group' : 'is-and-groupL'} ${singleRow ? 'query-main-single-row' : 'query-main-multiple-row'}`,
|
|
268
268
|
children: [/*#__PURE__*/_jsx(Nestable, {
|
|
269
269
|
isAndItem: condition === true,
|
|
270
270
|
isDraggableItem: this.isDraggableItem,
|
|
@@ -5,7 +5,6 @@ import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
|
5
5
|
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
8
|
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
10
9
|
import 'core-js/modules/esnext.iterator.map.js';
|
|
11
10
|
import React, { Component } from 'react';
|
|
@@ -33,14 +32,12 @@ const RenderField = _ref => {
|
|
|
33
32
|
hasError
|
|
34
33
|
} = _ref;
|
|
35
34
|
const ref = React.useRef();
|
|
36
|
-
const id = React.useMemo(() =>
|
|
35
|
+
const id = React.useMemo(() => `el_${String.fromCharCode(65 + Math.floor(Math.random() * 26))}`, []);
|
|
37
36
|
return /*#__PURE__*/_jsx("div", {
|
|
38
|
-
className:
|
|
37
|
+
className: `em-ds-query-builder-row-input child-type-${target} ${hasError && hasError.error ? 'row-input-error' : ''}`,
|
|
39
38
|
onMouseDownCapture: () => {
|
|
40
|
-
var _ref$current;
|
|
41
|
-
|
|
42
39
|
// eslint-disable-next-line no-underscore-dangle
|
|
43
|
-
const _refInput =
|
|
40
|
+
const _refInput = ref.current?.querySelector(`#${id}`);
|
|
44
41
|
|
|
45
42
|
if (_refInput && _refInput.focus) setTimeout(_refInput.focus());
|
|
46
43
|
handleMouseEnterInput();
|
|
@@ -163,8 +160,8 @@ class QueryBuilderRow extends Component {
|
|
|
163
160
|
idGroup,
|
|
164
161
|
additionalInfo: _objectSpread(_objectSpread({}, additionalInfo), {}, {
|
|
165
162
|
[target]: extraData,
|
|
166
|
-
[
|
|
167
|
-
[
|
|
163
|
+
[`${target}_error`]: hasError,
|
|
164
|
+
[`${target}_touched`]: true
|
|
168
165
|
}),
|
|
169
166
|
target
|
|
170
167
|
});
|
|
@@ -230,7 +227,7 @@ class QueryBuilderRow extends Component {
|
|
|
230
227
|
const {
|
|
231
228
|
[target]: valueProp
|
|
232
229
|
} = this.props;
|
|
233
|
-
const isTouched = additionalInfo && additionalInfo[
|
|
230
|
+
const isTouched = additionalInfo && additionalInfo[`${target}_touched`];
|
|
234
231
|
const hasError = renderField && renderField.validation ? renderField.validation(valueProp, {
|
|
235
232
|
field,
|
|
236
233
|
operator,
|
|
@@ -15,16 +15,16 @@ const conditionSql = (condition, value) => {
|
|
|
15
15
|
LESS_THAN_OR_EQUAL,
|
|
16
16
|
START_WITH
|
|
17
17
|
} = QB_OPERATOR_TYPES;
|
|
18
|
-
if (condition === EQUAL) return
|
|
19
|
-
if (condition === NOT_EQUAL) return
|
|
20
|
-
if (condition === GREATER_THAN) return
|
|
21
|
-
if (condition === LESS_THAN) return
|
|
22
|
-
if (condition === CONTAINS) return
|
|
23
|
-
if (condition === NOT_CONTAINS) return
|
|
24
|
-
if (condition === BETWEEN) return
|
|
25
|
-
if (condition === GREATER_THAN_OR_EQUAL) return
|
|
26
|
-
if (condition === LESS_THAN_OR_EQUAL) return
|
|
27
|
-
if (condition === START_WITH) return
|
|
18
|
+
if (condition === EQUAL) return ` = '${value}'`;
|
|
19
|
+
if (condition === NOT_EQUAL) return ` <> '${value}'`;
|
|
20
|
+
if (condition === GREATER_THAN) return ` > ${value}`;
|
|
21
|
+
if (condition === LESS_THAN) return ` < ${value}`;
|
|
22
|
+
if (condition === CONTAINS) return ` LIKE '%${value}%'`;
|
|
23
|
+
if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;
|
|
24
|
+
if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
25
|
+
if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;
|
|
26
|
+
if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;
|
|
27
|
+
if (condition === START_WITH) return ` LIKE '${value}%'`;
|
|
28
28
|
return condition;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -34,7 +34,7 @@ const renderFilterSQl = filter => {
|
|
|
34
34
|
operator,
|
|
35
35
|
value
|
|
36
36
|
} = filter.element;
|
|
37
|
-
return
|
|
37
|
+
return `${field} ${conditionSql(operator, value) || ''}`;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const sqlFormat = _ref => {
|
|
@@ -47,22 +47,22 @@ const sqlFormat = _ref => {
|
|
|
47
47
|
const groupSql = (item, idGroup) => {
|
|
48
48
|
if (idGroup === main) {
|
|
49
49
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
-
return
|
|
50
|
+
return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
-
return
|
|
54
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const filterSql = (filters, groupCondition) => {
|
|
58
58
|
const filterGroup = filters.map(filter => {
|
|
59
|
-
if (filter.element.type === 'filter') return
|
|
60
|
-
return
|
|
59
|
+
if (filter.element.type === 'filter') return ` ${renderFilterSQl(filter)} `;
|
|
60
|
+
return ` ${groupSql(filter) || ''} `;
|
|
61
61
|
});
|
|
62
62
|
return filterGroup.join(groupCondition);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
const sql =
|
|
65
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;
|
|
66
66
|
return sql;
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -18,17 +18,17 @@ const conditionSql = (condition, value) => {
|
|
|
18
18
|
START_WITH
|
|
19
19
|
} = QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
|
|
20
20
|
|
|
21
|
-
const valueDisplay = isNaN(value) ?
|
|
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
|
|
21
|
+
const valueDisplay = isNaN(value) ? `'${value}'` : value;
|
|
22
|
+
if (condition === EQUAL) return ` = ${valueDisplay}`;
|
|
23
|
+
if (condition === NOT_EQUAL) return ` <> ${valueDisplay}`;
|
|
24
|
+
if (condition === GREATER_THAN) return ` > ${valueDisplay}`;
|
|
25
|
+
if (condition === LESS_THAN) return ` < ${valueDisplay}`;
|
|
26
|
+
if (condition === CONTAINS) return ` LIKE '%${value}%'`;
|
|
27
|
+
if (condition === NOT_CONTAINS) return ` NOT LIKE '%${value}%'`;
|
|
28
|
+
if (condition === BETWEEN) return ` BETWEEN ${value[0]} AND ${value[1]} `;
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return ` >= ${value}`;
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return ` <= ${value}`;
|
|
31
|
+
if (condition === START_WITH) return ` LIKE '${value}%'`;
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -40,8 +40,8 @@ const renderFilterSQl = filter => {
|
|
|
40
40
|
} = filter.element; // eslint-disable-next-line no-restricted-globals
|
|
41
41
|
|
|
42
42
|
const fieldDisplay = // eslint-disable-next-line no-restricted-globals
|
|
43
|
-
/[.]/.test(field) || !isNaN(field) ? "
|
|
44
|
-
return
|
|
43
|
+
/[.]/.test(field) || !isNaN(field) ? `\\"${field}\\"` : field;
|
|
44
|
+
return `${fieldDisplay} ${conditionSql(operator, value) || ''}`;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
const sqlSafeFormat = _ref => {
|
|
@@ -54,22 +54,22 @@ const sqlSafeFormat = _ref => {
|
|
|
54
54
|
const groupSql = (item, idGroup) => {
|
|
55
55
|
if (idGroup === main) {
|
|
56
56
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
57
|
-
return
|
|
57
|
+
return ` ( ${filterSql(item, groupCondition)} ) `; // eslint-disable-line
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
61
|
-
return
|
|
61
|
+
return ` ( ${filterSql(item.children, groupCondition)} ) `; // eslint-disable-line
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
const filterSql = (filters, groupCondition) => {
|
|
65
65
|
const filterGroup = filters.map(filter => {
|
|
66
|
-
if (filter.element.type === 'filter') return
|
|
67
|
-
return
|
|
66
|
+
if (filter.element.type === 'filter') return ` ${renderFilterSQl(filter)} `;
|
|
67
|
+
return ` ${groupSql(filter) || ''} `;
|
|
68
68
|
});
|
|
69
69
|
return filterGroup.join(groupCondition);
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
const sql =
|
|
72
|
+
const sql = ` FROM [TABLE_NAME] WHERE ${groupSql(items, main) || ''} `;
|
|
73
73
|
return sql;
|
|
74
74
|
};
|
|
75
75
|
|
|
@@ -15,16 +15,16 @@ const conditionSql = (condition, value) => {
|
|
|
15
15
|
LESS_THAN_OR_EQUAL,
|
|
16
16
|
START_WITH
|
|
17
17
|
} = QB_OPERATOR_TYPES;
|
|
18
|
-
if (condition === EQUAL) return
|
|
19
|
-
if (condition === NOT_EQUAL) return
|
|
20
|
-
if (condition === GREATER_THAN) return
|
|
21
|
-
if (condition === LESS_THAN) return
|
|
22
|
-
if (condition === CONTAINS) return
|
|
23
|
-
if (condition === NOT_CONTAINS) return
|
|
24
|
-
if (condition === BETWEEN) return
|
|
25
|
-
if (condition === GREATER_THAN_OR_EQUAL) return
|
|
26
|
-
if (condition === LESS_THAN_OR_EQUAL) return
|
|
27
|
-
if (condition === START_WITH) return
|
|
18
|
+
if (condition === EQUAL) return `<condition>EQUAL</condition><value>${value}</value>`;
|
|
19
|
+
if (condition === NOT_EQUAL) return `<condition>NOT_EQUAL</condition><value>${value}</value>`;
|
|
20
|
+
if (condition === GREATER_THAN) return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
21
|
+
if (condition === LESS_THAN) return `<condition>LESS_THAN</condition><value>${value}</value>`;
|
|
22
|
+
if (condition === CONTAINS) return `<condition>LIKE</condition><value>${value}</value>`;
|
|
23
|
+
if (condition === NOT_CONTAINS) return `<condition>NOT_LIKE</condition><value>${value}</value>`;
|
|
24
|
+
if (condition === BETWEEN) return `<condition>NOT_LIKE</condition><value><from>${value[0]}</from><to>${value[1]}</to></value>`;
|
|
25
|
+
if (condition === GREATER_THAN_OR_EQUAL) return `<condition>GREATER_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
26
|
+
if (condition === LESS_THAN_OR_EQUAL) return `<condition>LESS_THAN_OR_EQUAL</condition><value>${value}</value>`;
|
|
27
|
+
if (condition === START_WITH) return `<condition>GREATER_THAN</condition><value>${value}</value>`;
|
|
28
28
|
return condition;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -34,7 +34,7 @@ const renderFilterSQl = filter => {
|
|
|
34
34
|
operator,
|
|
35
35
|
value
|
|
36
36
|
} = filter.element;
|
|
37
|
-
return
|
|
37
|
+
return `<filter><field>${field}</field>${conditionSql(operator, value) || ''}</filter>`;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
const xmlFormat = _ref => {
|
|
@@ -47,22 +47,22 @@ const xmlFormat = _ref => {
|
|
|
47
47
|
const groupXML = (item, idGroup) => {
|
|
48
48
|
if (idGroup === main) {
|
|
49
49
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
-
return
|
|
50
|
+
return `<group value="${groupCondition}">${filterXML(item)}</group>`; // eslint-disable-line
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
-
return
|
|
54
|
+
return `<group value="${groupCondition}">${filterXML(item.children)}</group>`; // eslint-disable-line
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
const filterXML = filters => {
|
|
58
58
|
const filterGroup = filters.map(filter => {
|
|
59
|
-
if (filter.element.type === 'filter') return
|
|
60
|
-
return
|
|
59
|
+
if (filter.element.type === 'filter') return `${renderFilterSQl(filter) || ''} `;
|
|
60
|
+
return ` ${groupXML(filter)} `;
|
|
61
61
|
});
|
|
62
62
|
return filterGroup.join('');
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
const xml =
|
|
65
|
+
const xml = `<xml><query>${groupXML(items, main) || ''}</query></xml>`;
|
|
66
66
|
return xml;
|
|
67
67
|
};
|
|
68
68
|
|
|
@@ -21,7 +21,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
const createNewFilter = function (idGroup) {
|
|
24
|
-
const idFilter =
|
|
24
|
+
const idFilter = `filter_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
25
25
|
return {
|
|
26
26
|
idGroup,
|
|
27
27
|
field: '',
|
|
@@ -39,7 +39,7 @@ const createNewFilter = function (idGroup) {
|
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
41
|
const createNewGroup = function (parentIdGroup) {
|
|
42
|
-
const idGroup =
|
|
42
|
+
const idGroup = `group_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
43
43
|
return {
|
|
44
44
|
parentIdGroup,
|
|
45
45
|
idGroup,
|
package/esm/propTypes.js
CHANGED
|
@@ -73,7 +73,9 @@ const props = {
|
|
|
73
73
|
|
|
74
74
|
/** remove filter callback */
|
|
75
75
|
onRemoveFilter: PropTypes.func.description('remove filter callback'),
|
|
76
|
-
displayFixedOutput: PropTypes.string.description(
|
|
76
|
+
displayFixedOutput: PropTypes.string.description(`Label for fixed output.Using this props it will ignore 'displayOutput' and 'displayOutputLabel'
|
|
77
|
+
and it will always render the output without the ability to close it.
|
|
78
|
+
`).defaultValue(''),
|
|
77
79
|
|
|
78
80
|
/** show output */
|
|
79
81
|
displayOutput: PropTypes.bool.description('show output'),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-query-builder",
|
|
3
|
-
"version": "2.4.2
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Query Builder",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -168,17 +168,17 @@
|
|
|
168
168
|
"build": "node ../../scripts/build/build.js"
|
|
169
169
|
},
|
|
170
170
|
"dependencies": {
|
|
171
|
-
"@elliemae/ds-accordion": "2.4.2
|
|
172
|
-
"@elliemae/ds-button": "2.4.2
|
|
173
|
-
"@elliemae/ds-classnames": "2.4.2
|
|
174
|
-
"@elliemae/ds-form": "2.4.2
|
|
175
|
-
"@elliemae/ds-grid": "2.4.2
|
|
176
|
-
"@elliemae/ds-icon": "2.4.2
|
|
177
|
-
"@elliemae/ds-icons": "2.4.2
|
|
178
|
-
"@elliemae/ds-popper": "2.4.2
|
|
179
|
-
"@elliemae/ds-shared": "2.4.2
|
|
180
|
-
"@elliemae/ds-tooltip": "2.4.2
|
|
181
|
-
"@elliemae/ds-utilities": "2.4.2
|
|
171
|
+
"@elliemae/ds-accordion": "2.4.2",
|
|
172
|
+
"@elliemae/ds-button": "2.4.2",
|
|
173
|
+
"@elliemae/ds-classnames": "2.4.2",
|
|
174
|
+
"@elliemae/ds-form": "2.4.2",
|
|
175
|
+
"@elliemae/ds-grid": "2.4.2",
|
|
176
|
+
"@elliemae/ds-icon": "2.4.2",
|
|
177
|
+
"@elliemae/ds-icons": "2.4.2",
|
|
178
|
+
"@elliemae/ds-popper": "2.4.2",
|
|
179
|
+
"@elliemae/ds-shared": "2.4.2",
|
|
180
|
+
"@elliemae/ds-tooltip": "2.4.2",
|
|
181
|
+
"@elliemae/ds-utilities": "2.4.2",
|
|
182
182
|
"classnames": "~2.2.6",
|
|
183
183
|
"prop-types": "~15.7.2",
|
|
184
184
|
"react-addons-update": "~15.6.3",
|