@elliemae/ds-query-builder 2.0.0-alpha.1 → 2.0.0-alpha.13
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 +61 -55
- package/cjs/components/AndOrController/AndOrController.js +44 -52
- package/cjs/components/ConditionController/ConditionController.js +35 -41
- package/cjs/components/DisplayOutput/DisplayOutput.js +38 -24
- package/cjs/components/DragContainerController/DragContainerController.js +16 -18
- package/cjs/components/DragControllerRow/DragControllerRow.js +12 -8
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +22 -22
- package/cjs/components/Nestable/Nestable.js +54 -40
- package/cjs/components/Nestable/NestableItem.js +24 -16
- package/cjs/components/Nestable/actions/events.js +7 -2
- package/cjs/components/Nestable/actions/getPaths.js +11 -1
- package/cjs/components/Nestable/actions/moveItem.js +15 -8
- package/cjs/components/Nestable/actions/paths.js +15 -3
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +1 -1
- package/cjs/components/QueryBuilderImpl.js +44 -38
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +30 -22
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +64 -49
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +7 -2
- 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 +62 -37
- package/cjs/components/helpers/dependencies.js +19 -12
- package/cjs/components/helpers/store.js +39 -40
- package/cjs/index.js +2 -1
- package/cjs/propTypes.js +1 -0
- package/esm/DSQueryBuilder.js +60 -55
- package/esm/components/AndOrController/AndOrController.js +21 -24
- package/esm/components/ConditionController/ConditionController.js +21 -23
- package/esm/components/DisplayOutput/DisplayOutput.js +32 -15
- 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 +38 -32
- 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 -0
- package/package.json +14 -7
- package/types/DSQueryBuilder.d.ts +172 -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 -22
- package/cjs/package.json +0 -7
- package/esm/package.json +0 -7
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
11
|
import React, { Component } from 'react';
|
|
4
|
-
import AlertsDetail from '@elliemae/ds-icons
|
|
5
|
-
import {
|
|
12
|
+
import { AlertsDetail } from '@elliemae/ds-icons';
|
|
13
|
+
import { DSTooltipV3 } from '@elliemae/ds-tooltip';
|
|
6
14
|
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
7
15
|
import { resolveDependencies } from '../helpers/dependencies.js';
|
|
8
16
|
import ConditionController from '../ConditionController/ConditionController.js';
|
|
@@ -13,25 +21,26 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
13
21
|
|
|
14
22
|
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(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; }
|
|
15
23
|
|
|
16
|
-
const RenderField =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const RenderField = _ref => {
|
|
25
|
+
let {
|
|
26
|
+
target,
|
|
27
|
+
component,
|
|
28
|
+
valueProp,
|
|
29
|
+
additionalInfo,
|
|
30
|
+
handleMouseEnterInput,
|
|
31
|
+
handleMouseLeaveInput,
|
|
32
|
+
onChangeHandler,
|
|
33
|
+
hasError
|
|
34
|
+
} = _ref;
|
|
26
35
|
const ref = React.useRef();
|
|
27
|
-
const id = React.useMemo(() =>
|
|
36
|
+
const id = React.useMemo(() => "el_".concat(String.fromCharCode(65 + Math.floor(Math.random() * 26))), []);
|
|
28
37
|
return /*#__PURE__*/_jsx("div", {
|
|
29
|
-
className:
|
|
38
|
+
className: "em-ds-query-builder-row-input child-type-".concat(target, " ").concat(hasError && hasError.error ? 'row-input-error' : ''),
|
|
30
39
|
onMouseDownCapture: () => {
|
|
31
40
|
var _ref$current;
|
|
32
41
|
|
|
33
42
|
// eslint-disable-next-line no-underscore-dangle
|
|
34
|
-
const _refInput = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector(
|
|
43
|
+
const _refInput = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.querySelector("#".concat(id));
|
|
35
44
|
|
|
36
45
|
if (_refInput && _refInput.focus) setTimeout(_refInput.focus());
|
|
37
46
|
handleMouseEnterInput();
|
|
@@ -46,19 +55,26 @@ const RenderField = ({
|
|
|
46
55
|
onChange: (e, extraData) => onChangeHandler(e, target, extraData),
|
|
47
56
|
value: valueProp != null ? valueProp : '',
|
|
48
57
|
checked: valueProp === true,
|
|
49
|
-
additionalInfo: additionalInfo ? additionalInfo[target] : additionalInfo || {}
|
|
58
|
+
additionalInfo: additionalInfo ? additionalInfo[target] : additionalInfo || {},
|
|
59
|
+
'aria-invalid': Boolean(hasError)
|
|
50
60
|
})
|
|
51
|
-
}), hasError && hasError.errorMessage ? /*#__PURE__*/_jsx("
|
|
61
|
+
}), hasError && hasError.errorMessage ? /*#__PURE__*/_jsx("div", {
|
|
62
|
+
style: {
|
|
63
|
+
width: '40px'
|
|
64
|
+
}
|
|
65
|
+
}, void 0, /*#__PURE__*/_jsx(DSTooltipV3, {
|
|
66
|
+
text: hasError.errorMessage
|
|
67
|
+
}, void 0, /*#__PURE__*/_jsx("div", {
|
|
68
|
+
tabIndex: 0,
|
|
52
69
|
className: "row-icon-alert",
|
|
53
|
-
"data-testid": "qb-error-state-icon"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})) : null); // return React.useMemo(
|
|
70
|
+
"data-testid": "qb-error-state-icon",
|
|
71
|
+
role: "alert"
|
|
72
|
+
}, void 0, /*#__PURE__*/_jsx(AlertsDetail, {
|
|
73
|
+
width: 20,
|
|
74
|
+
height: 20,
|
|
75
|
+
color: ['danger', 900],
|
|
76
|
+
title: hasError.errorMessage
|
|
77
|
+
})))) : null); // return React.useMemo(
|
|
62
78
|
// () => (
|
|
63
79
|
// <div
|
|
64
80
|
// className={`em-ds-query-builder-row-input child-type-${target}`}
|
|
@@ -90,31 +106,31 @@ class QueryBuilderRow extends Component {
|
|
|
90
106
|
constructor(props) {
|
|
91
107
|
super(props);
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
this.handleMouseEnterRow = () => {};
|
|
94
110
|
|
|
95
|
-
|
|
111
|
+
this.handleMouseLeaveRow = () => {
|
|
96
112
|
this.handleTooltipRow(false);
|
|
97
|
-
}
|
|
113
|
+
};
|
|
98
114
|
|
|
99
|
-
|
|
115
|
+
this.handleMouseEnterInput = () => {
|
|
100
116
|
const {
|
|
101
117
|
setDraggableItems
|
|
102
118
|
} = this.props;
|
|
103
119
|
setDraggableItems(false);
|
|
104
|
-
}
|
|
120
|
+
};
|
|
105
121
|
|
|
106
|
-
|
|
122
|
+
this.handleMouseLeaveInput = () => {
|
|
107
123
|
const {
|
|
108
124
|
setDraggableItems
|
|
109
125
|
} = this.props;
|
|
110
126
|
setDraggableItems(true);
|
|
111
|
-
}
|
|
127
|
+
};
|
|
112
128
|
|
|
113
|
-
|
|
129
|
+
this.handleTooltipRow = isOpen => {
|
|
114
130
|
this.setState({
|
|
115
131
|
isOpen
|
|
116
132
|
});
|
|
117
|
-
}
|
|
133
|
+
};
|
|
118
134
|
|
|
119
135
|
this.state = {
|
|
120
136
|
isOpen: false
|
|
@@ -147,8 +163,8 @@ class QueryBuilderRow extends Component {
|
|
|
147
163
|
idGroup,
|
|
148
164
|
additionalInfo: _objectSpread(_objectSpread({}, additionalInfo), {}, {
|
|
149
165
|
[target]: extraData,
|
|
150
|
-
[
|
|
151
|
-
[
|
|
166
|
+
["".concat(target, "_error")]: hasError,
|
|
167
|
+
["".concat(target, "_touched")]: true
|
|
152
168
|
}),
|
|
153
169
|
target
|
|
154
170
|
});
|
|
@@ -203,7 +219,7 @@ class QueryBuilderRow extends Component {
|
|
|
203
219
|
const {
|
|
204
220
|
[target]: valueProp
|
|
205
221
|
} = this.props;
|
|
206
|
-
const isTouched = additionalInfo && additionalInfo[
|
|
222
|
+
const isTouched = additionalInfo && additionalInfo["".concat(target, "_touched")];
|
|
207
223
|
const hasError = renderField && renderField.validation ? renderField.validation(valueProp, {
|
|
208
224
|
field,
|
|
209
225
|
operator,
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
1
6
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
7
|
import { createElement } from 'react';
|
|
3
8
|
import GrowRight from '@elliemae/ds-shared/Animations/GrowRight';
|
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
1
|
import { sqlFormat } from './sqlFormat.js';
|
|
3
2
|
import { xmlFormat } from './xmlFormat.js';
|
|
4
3
|
import { sqlSafeFormat } from './sqlSafeFormat.js';
|
|
5
4
|
|
|
6
5
|
class QueryBuilderFormat {
|
|
7
6
|
constructor() {
|
|
8
|
-
|
|
7
|
+
this.format = {
|
|
9
8
|
defaultFormat: query => query,
|
|
10
9
|
sqlFormat,
|
|
11
10
|
xmlFormat,
|
|
12
11
|
sqlSafeFormat
|
|
13
|
-
}
|
|
12
|
+
};
|
|
13
|
+
this.currentFormat = 'sqlFormat';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "setDefaultFormat", formatName => {
|
|
15
|
+
this.setDefaultFormat = formatName => {
|
|
18
16
|
if (this.format[formatName]) this.currentFormat = formatName;
|
|
19
|
-
}
|
|
17
|
+
};
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
this.run = (query, formatName) => {
|
|
24
22
|
if (this.format[formatName]) return this.format[formatName](query);
|
|
25
23
|
return this.format[this.currentFormat](query);
|
|
26
|
-
}
|
|
24
|
+
};
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
1
3
|
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
2
4
|
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
|
|
5
5
|
const conditionSql = (condition, value) => {
|
|
6
6
|
const {
|
|
7
7
|
EQUAL,
|
|
@@ -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 " = '".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, "%'");
|
|
28
28
|
return condition;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -34,33 +34,35 @@ const renderFilterSQl = filter => {
|
|
|
34
34
|
operator,
|
|
35
35
|
value
|
|
36
36
|
} = filter.element;
|
|
37
|
-
return
|
|
37
|
+
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const sqlFormat =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const sqlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
45
47
|
const groupSql = (item, idGroup) => {
|
|
46
48
|
if (idGroup === main) {
|
|
47
49
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
48
|
-
return
|
|
50
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
52
|
-
return
|
|
54
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
const filterSql = (filters, groupCondition) => {
|
|
56
58
|
const filterGroup = filters.map(filter => {
|
|
57
|
-
if (filter.element.type === 'filter') return
|
|
58
|
-
return
|
|
59
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
60
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
59
61
|
});
|
|
60
62
|
return filterGroup.join(groupCondition);
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
const sql =
|
|
65
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
64
66
|
return sql;
|
|
65
67
|
};
|
|
66
68
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
1
3
|
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
2
4
|
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
|
|
5
5
|
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
6
6
|
|
|
7
7
|
const conditionSql = (condition, value) => {
|
|
@@ -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) ? "'".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, "%'");
|
|
32
32
|
return condition;
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -40,34 +40,36 @@ 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) ? "\\\"".concat(field, "\\\"") : field;
|
|
44
|
+
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
const sqlSafeFormat =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const sqlSafeFormat = _ref => {
|
|
48
|
+
let {
|
|
49
|
+
main,
|
|
50
|
+
mapGroups,
|
|
51
|
+
items
|
|
52
|
+
} = _ref;
|
|
53
|
+
|
|
52
54
|
const groupSql = (item, idGroup) => {
|
|
53
55
|
if (idGroup === main) {
|
|
54
56
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
55
|
-
return
|
|
57
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
59
|
-
return
|
|
61
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
60
62
|
};
|
|
61
63
|
|
|
62
64
|
const filterSql = (filters, groupCondition) => {
|
|
63
65
|
const filterGroup = filters.map(filter => {
|
|
64
|
-
if (filter.element.type === 'filter') return
|
|
65
|
-
return
|
|
66
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
67
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
66
68
|
});
|
|
67
69
|
return filterGroup.join(groupCondition);
|
|
68
70
|
};
|
|
69
71
|
|
|
70
|
-
const sql =
|
|
72
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
71
73
|
return sql;
|
|
72
74
|
};
|
|
73
75
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
1
3
|
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
2
4
|
|
|
3
|
-
/* eslint-disable complexity */
|
|
4
|
-
|
|
5
5
|
const conditionSql = (condition, value) => {
|
|
6
6
|
const {
|
|
7
7
|
EQUAL,
|
|
@@ -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>".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>");
|
|
28
28
|
return condition;
|
|
29
29
|
};
|
|
30
30
|
|
|
@@ -34,33 +34,35 @@ const renderFilterSQl = filter => {
|
|
|
34
34
|
operator,
|
|
35
35
|
value
|
|
36
36
|
} = filter.element;
|
|
37
|
-
return
|
|
37
|
+
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const xmlFormat =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const xmlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
45
47
|
const groupXML = (item, idGroup) => {
|
|
46
48
|
if (idGroup === main) {
|
|
47
49
|
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
48
|
-
return
|
|
50
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
52
|
-
return
|
|
54
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
53
55
|
};
|
|
54
56
|
|
|
55
57
|
const filterXML = filters => {
|
|
56
58
|
const filterGroup = filters.map(filter => {
|
|
57
|
-
if (filter.element.type === 'filter') return
|
|
58
|
-
return
|
|
59
|
+
if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
|
|
60
|
+
return " ".concat(groupXML(filter), " ");
|
|
59
61
|
});
|
|
60
62
|
return filterGroup.join('');
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
const xml =
|
|
65
|
+
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
64
66
|
return xml;
|
|
65
67
|
};
|
|
66
68
|
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
5
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
2
11
|
import { QB_DRAG_TYPES, QB_GROUP_CONDITION_TYPES, QB_FIELD_SHARED_ACTIONS } from './types.js';
|
|
3
12
|
|
|
4
13
|
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; }
|
|
@@ -12,7 +21,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
12
21
|
*/
|
|
13
22
|
|
|
14
23
|
const createNewFilter = function (idGroup) {
|
|
15
|
-
const idFilter =
|
|
24
|
+
const idFilter = "filter_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
16
25
|
return {
|
|
17
26
|
idGroup,
|
|
18
27
|
field: '',
|
|
@@ -30,7 +39,7 @@ const createNewFilter = function (idGroup) {
|
|
|
30
39
|
*/
|
|
31
40
|
|
|
32
41
|
const createNewGroup = function (parentIdGroup) {
|
|
33
|
-
const idGroup =
|
|
42
|
+
const idGroup = "group_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
34
43
|
return {
|
|
35
44
|
parentIdGroup,
|
|
36
45
|
idGroup,
|
|
@@ -76,9 +85,12 @@ const addFilterToMainItem = function (items, newFilter) {
|
|
|
76
85
|
});
|
|
77
86
|
};
|
|
78
87
|
const findInChilds = function (childs, filterId) {
|
|
79
|
-
const found = childs.find(
|
|
80
|
-
|
|
81
|
-
|
|
88
|
+
const found = childs.find(_ref => {
|
|
89
|
+
let {
|
|
90
|
+
id
|
|
91
|
+
} = _ref;
|
|
92
|
+
return id === filterId;
|
|
93
|
+
});
|
|
82
94
|
|
|
83
95
|
if (!found) {
|
|
84
96
|
let findInChild;
|
|
@@ -94,9 +106,12 @@ const findItemFilterById = function (filterId) {
|
|
|
94
106
|
return findInChilds(this.items, filterId);
|
|
95
107
|
};
|
|
96
108
|
const findParentWithFilterId = function (childs, filterId) {
|
|
97
|
-
const found = childs.find(
|
|
98
|
-
|
|
99
|
-
|
|
109
|
+
const found = childs.find(_ref2 => {
|
|
110
|
+
let {
|
|
111
|
+
id
|
|
112
|
+
} = _ref2;
|
|
113
|
+
return id === filterId;
|
|
114
|
+
});
|
|
100
115
|
|
|
101
116
|
if (!found) {
|
|
102
117
|
let findInChild;
|
|
@@ -113,17 +128,23 @@ const findParentFilterById = function (filterId) {
|
|
|
113
128
|
};
|
|
114
129
|
const filterInChildren = function (childs, filterId, mainId) {
|
|
115
130
|
if (childs.children) {
|
|
116
|
-
childs.children = childs.children.filter(
|
|
117
|
-
|
|
118
|
-
|
|
131
|
+
childs.children = childs.children.filter(_ref3 => {
|
|
132
|
+
let {
|
|
133
|
+
id
|
|
134
|
+
} = _ref3;
|
|
135
|
+
return id !== filterId;
|
|
136
|
+
});
|
|
119
137
|
childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
|
|
120
138
|
return childs;
|
|
121
139
|
} // main
|
|
122
140
|
|
|
123
141
|
|
|
124
|
-
if (childs.length > 1) childs = childs.filter(
|
|
125
|
-
|
|
126
|
-
|
|
142
|
+
if (childs.length > 1) childs = childs.filter(_ref4 => {
|
|
143
|
+
let {
|
|
144
|
+
id
|
|
145
|
+
} = _ref4;
|
|
146
|
+
return id !== filterId;
|
|
147
|
+
}); // https://jira.elliemae.io/browse/PUI-1252
|
|
127
148
|
|
|
128
149
|
if (childs.length === 0 && mainId) {
|
|
129
150
|
const emptyFilter = createNewFilter.call(this, mainId);
|
|
@@ -186,19 +207,20 @@ const changeGroupOperator = function (idGroup, value) {
|
|
|
186
207
|
group.element.condition = value;
|
|
187
208
|
}
|
|
188
209
|
};
|
|
189
|
-
const changeFilterItem = function ({
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
210
|
+
const changeFilterItem = function (_ref5) {
|
|
211
|
+
let {
|
|
212
|
+
idFilter,
|
|
213
|
+
field,
|
|
214
|
+
value,
|
|
215
|
+
operator,
|
|
216
|
+
additionalInfo,
|
|
217
|
+
target,
|
|
218
|
+
fieldsSharedActions: {
|
|
219
|
+
onFieldChange,
|
|
220
|
+
onOperatorChange,
|
|
221
|
+
onValueChange
|
|
222
|
+
}
|
|
223
|
+
} = _ref5;
|
|
202
224
|
const child = findItemFilterById.call(this, idFilter);
|
|
203
225
|
if (field || field === '' || typeof field === 'boolean') child.element.field = field;
|
|
204
226
|
if (operator) child.element.operator = operator;
|
|
@@ -206,21 +228,24 @@ const changeFilterItem = function ({
|
|
|
206
228
|
if (additionalInfo) child.element.additionalInfo = additionalInfo; // shared fields actions
|
|
207
229
|
|
|
208
230
|
if (target === 'field') {
|
|
209
|
-
onFieldChange.forEach(
|
|
210
|
-
|
|
211
|
-
|
|
231
|
+
onFieldChange.forEach(_ref6 => {
|
|
232
|
+
let {
|
|
233
|
+
action
|
|
234
|
+
} = _ref6;
|
|
212
235
|
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
213
236
|
});
|
|
214
237
|
} else if (target === 'operator') {
|
|
215
|
-
onOperatorChange.forEach(
|
|
216
|
-
|
|
217
|
-
|
|
238
|
+
onOperatorChange.forEach(_ref7 => {
|
|
239
|
+
let {
|
|
240
|
+
action
|
|
241
|
+
} = _ref7;
|
|
218
242
|
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
219
243
|
});
|
|
220
244
|
} else if (target === 'value') {
|
|
221
|
-
onValueChange.forEach(
|
|
222
|
-
|
|
223
|
-
|
|
245
|
+
onValueChange.forEach(_ref8 => {
|
|
246
|
+
let {
|
|
247
|
+
action
|
|
248
|
+
} = _ref8;
|
|
224
249
|
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
225
250
|
});
|
|
226
251
|
}
|