@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
|
@@ -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
|
|
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
+
require('core-js/modules/esnext.async-iterator.find.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
+
require('core-js/modules/esnext.iterator.find.js');
|
|
9
|
+
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
10
|
+
require('core-js/modules/esnext.iterator.for-each.js');
|
|
11
|
+
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
12
|
+
require('core-js/modules/esnext.iterator.filter.js');
|
|
13
|
+
require('core-js/modules/esnext.async-iterator.map.js');
|
|
14
|
+
require('core-js/modules/esnext.iterator.map.js');
|
|
6
15
|
var types = require('./types.js');
|
|
7
16
|
|
|
8
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -11,7 +20,7 @@ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_definePropert
|
|
|
11
20
|
|
|
12
21
|
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; }
|
|
13
22
|
|
|
14
|
-
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[
|
|
23
|
+
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; }
|
|
15
24
|
/**
|
|
16
25
|
* this is injected. instance of QBStore
|
|
17
26
|
*
|
|
@@ -20,7 +29,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
20
29
|
*/
|
|
21
30
|
|
|
22
31
|
const createNewFilter = function (idGroup) {
|
|
23
|
-
const idFilter =
|
|
32
|
+
const idFilter = "filter_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
24
33
|
return {
|
|
25
34
|
idGroup,
|
|
26
35
|
field: '',
|
|
@@ -38,7 +47,7 @@ const createNewFilter = function (idGroup) {
|
|
|
38
47
|
*/
|
|
39
48
|
|
|
40
49
|
const createNewGroup = function (parentIdGroup) {
|
|
41
|
-
const idGroup =
|
|
50
|
+
const idGroup = "group_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
42
51
|
return {
|
|
43
52
|
parentIdGroup,
|
|
44
53
|
idGroup,
|
|
@@ -84,9 +93,12 @@ const addFilterToMainItem = function (items, newFilter) {
|
|
|
84
93
|
});
|
|
85
94
|
};
|
|
86
95
|
const findInChilds = function (childs, filterId) {
|
|
87
|
-
const found = childs.find(
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
const found = childs.find(_ref => {
|
|
97
|
+
let {
|
|
98
|
+
id
|
|
99
|
+
} = _ref;
|
|
100
|
+
return id === filterId;
|
|
101
|
+
});
|
|
90
102
|
|
|
91
103
|
if (!found) {
|
|
92
104
|
let findInChild;
|
|
@@ -102,9 +114,12 @@ const findItemFilterById = function (filterId) {
|
|
|
102
114
|
return findInChilds(this.items, filterId);
|
|
103
115
|
};
|
|
104
116
|
const findParentWithFilterId = function (childs, filterId) {
|
|
105
|
-
const found = childs.find(
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
const found = childs.find(_ref2 => {
|
|
118
|
+
let {
|
|
119
|
+
id
|
|
120
|
+
} = _ref2;
|
|
121
|
+
return id === filterId;
|
|
122
|
+
});
|
|
108
123
|
|
|
109
124
|
if (!found) {
|
|
110
125
|
let findInChild;
|
|
@@ -121,17 +136,23 @@ const findParentFilterById = function (filterId) {
|
|
|
121
136
|
};
|
|
122
137
|
const filterInChildren = function (childs, filterId, mainId) {
|
|
123
138
|
if (childs.children) {
|
|
124
|
-
childs.children = childs.children.filter(
|
|
125
|
-
|
|
126
|
-
|
|
139
|
+
childs.children = childs.children.filter(_ref3 => {
|
|
140
|
+
let {
|
|
141
|
+
id
|
|
142
|
+
} = _ref3;
|
|
143
|
+
return id !== filterId;
|
|
144
|
+
});
|
|
127
145
|
childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
|
|
128
146
|
return childs;
|
|
129
147
|
} // main
|
|
130
148
|
|
|
131
149
|
|
|
132
|
-
if (childs.length > 1) childs = childs.filter(
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
if (childs.length > 1) childs = childs.filter(_ref4 => {
|
|
151
|
+
let {
|
|
152
|
+
id
|
|
153
|
+
} = _ref4;
|
|
154
|
+
return id !== filterId;
|
|
155
|
+
}); // https://jira.elliemae.io/browse/PUI-1252
|
|
135
156
|
|
|
136
157
|
if (childs.length === 0 && mainId) {
|
|
137
158
|
const emptyFilter = createNewFilter.call(this, mainId);
|
|
@@ -194,19 +215,20 @@ const changeGroupOperator = function (idGroup, value) {
|
|
|
194
215
|
group.element.condition = value;
|
|
195
216
|
}
|
|
196
217
|
};
|
|
197
|
-
const changeFilterItem = function ({
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
218
|
+
const changeFilterItem = function (_ref5) {
|
|
219
|
+
let {
|
|
220
|
+
idFilter,
|
|
221
|
+
field,
|
|
222
|
+
value,
|
|
223
|
+
operator,
|
|
224
|
+
additionalInfo,
|
|
225
|
+
target,
|
|
226
|
+
fieldsSharedActions: {
|
|
227
|
+
onFieldChange,
|
|
228
|
+
onOperatorChange,
|
|
229
|
+
onValueChange
|
|
230
|
+
}
|
|
231
|
+
} = _ref5;
|
|
210
232
|
const child = findItemFilterById.call(this, idFilter);
|
|
211
233
|
if (field || field === '' || typeof field === 'boolean') child.element.field = field;
|
|
212
234
|
if (operator) child.element.operator = operator;
|
|
@@ -214,21 +236,24 @@ const changeFilterItem = function ({
|
|
|
214
236
|
if (additionalInfo) child.element.additionalInfo = additionalInfo; // shared fields actions
|
|
215
237
|
|
|
216
238
|
if (target === 'field') {
|
|
217
|
-
onFieldChange.forEach(
|
|
218
|
-
|
|
219
|
-
|
|
239
|
+
onFieldChange.forEach(_ref6 => {
|
|
240
|
+
let {
|
|
241
|
+
action
|
|
242
|
+
} = _ref6;
|
|
220
243
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
221
244
|
});
|
|
222
245
|
} else if (target === 'operator') {
|
|
223
|
-
onOperatorChange.forEach(
|
|
224
|
-
|
|
225
|
-
|
|
246
|
+
onOperatorChange.forEach(_ref7 => {
|
|
247
|
+
let {
|
|
248
|
+
action
|
|
249
|
+
} = _ref7;
|
|
226
250
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
227
251
|
});
|
|
228
252
|
} else if (target === 'value') {
|
|
229
|
-
onValueChange.forEach(
|
|
230
|
-
|
|
231
|
-
|
|
253
|
+
onValueChange.forEach(_ref8 => {
|
|
254
|
+
let {
|
|
255
|
+
action
|
|
256
|
+
} = _ref8;
|
|
232
257
|
if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_FIELD) child.element.field = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR) child.element.operator = null;else if (action === types.QB_FIELD_SHARED_ACTIONS.RESET_VALUE) child.element.value = null;
|
|
233
258
|
});
|
|
234
259
|
}
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
require('core-js/modules/esnext.async-iterator.every.js');
|
|
6
|
+
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
+
require('core-js/modules/esnext.iterator.every.js');
|
|
8
|
+
require('core-js/modules/esnext.async-iterator.some.js');
|
|
9
|
+
require('core-js/modules/esnext.iterator.some.js');
|
|
10
|
+
require('core-js/modules/esnext.async-iterator.reduce.js');
|
|
11
|
+
require('core-js/modules/esnext.iterator.reduce.js');
|
|
5
12
|
var lodash = require('lodash');
|
|
6
13
|
var operators = require('@elliemae/ds-utilities/operators');
|
|
7
14
|
var types = require('./types.js');
|
|
@@ -15,20 +22,19 @@ function _interopNamespace(e) {
|
|
|
15
22
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
23
|
Object.defineProperty(n, k, d.get ? d : {
|
|
17
24
|
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return e[k];
|
|
20
|
-
}
|
|
25
|
+
get: function () { return e[k]; }
|
|
21
26
|
});
|
|
22
27
|
}
|
|
23
28
|
});
|
|
24
29
|
}
|
|
25
|
-
n[
|
|
30
|
+
n["default"] = e;
|
|
26
31
|
return Object.freeze(n);
|
|
27
32
|
}
|
|
28
33
|
|
|
29
34
|
var operators__namespace = /*#__PURE__*/_interopNamespace(operators);
|
|
30
35
|
|
|
31
|
-
const resolveCondition = (condition, state
|
|
36
|
+
const resolveCondition = function (condition, state) {
|
|
37
|
+
let resolveBy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : types.QB_GROUP_CONDITION_TYPES.AND;
|
|
32
38
|
if (condition.length === 0 || !condition) return true; // resolve by AND: all the conditions must be true
|
|
33
39
|
|
|
34
40
|
if (resolveBy) {
|
|
@@ -55,13 +61,14 @@ const resolveCondition = (condition, state, resolveBy = types.QB_GROUP_CONDITION
|
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
const resolveDependencies = (state, fields) => {
|
|
58
|
-
const fieldsToRender = fields.reduce((result, {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const fieldsToRender = fields.reduce((result, _ref) => {
|
|
65
|
+
let {
|
|
66
|
+
target,
|
|
67
|
+
component,
|
|
68
|
+
condition,
|
|
69
|
+
resolveBy,
|
|
70
|
+
validation
|
|
71
|
+
} = _ref;
|
|
65
72
|
if (resolveCondition(condition, state, resolveBy)) result.push({
|
|
66
73
|
target,
|
|
67
74
|
component,
|