@elliemae/ds-query-builder 2.3.0-alpha.9 → 2.3.0-next.3
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 +98 -0
- package/cjs/components/AndOrController/AndOrController.js +222 -0
- package/cjs/components/ConditionController/ConditionController.js +100 -0
- package/cjs/components/DisplayOutput/DisplayOutput.js +93 -0
- package/cjs/components/DragContainerController/DragContainerController.js +45 -0
- package/cjs/components/DragControllerRow/DragControllerRow.js +47 -0
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +33 -0
- package/cjs/components/Nestable/Nestable.js +320 -0
- package/cjs/components/Nestable/NestableItem.js +111 -0
- package/cjs/components/Nestable/actions/events.js +166 -0
- package/cjs/components/Nestable/actions/getItemOptions.js +28 -0
- package/cjs/components/Nestable/actions/getPaths.js +124 -0
- package/cjs/components/Nestable/actions/index.js +28 -0
- package/cjs/components/Nestable/actions/moveItem.js +54 -0
- package/cjs/components/Nestable/actions/paths.js +126 -0
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +35 -0
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +38 -0
- package/cjs/components/Nestable/index.js +7 -0
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -0
- package/cjs/components/QueryBuilderImpl.js +309 -0
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +90 -0
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +276 -0
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +29 -0
- package/cjs/components/format/format.js +33 -0
- package/cjs/components/format/sqlFormat.js +73 -0
- package/cjs/components/format/sqlSafeFormat.js +81 -0
- package/cjs/components/format/xmlFormat.js +73 -0
- package/cjs/components/helpers/actions.js +277 -0
- package/cjs/components/helpers/constants.js +11 -0
- package/cjs/components/helpers/dependencies.js +84 -0
- package/cjs/components/helpers/selectors.js +101 -0
- package/cjs/components/helpers/store.js +177 -0
- package/cjs/components/helpers/types.js +64 -0
- package/cjs/index.js +29 -0
- package/cjs/propTypes.js +97 -0
- package/esm/DSQueryBuilder.js +74 -0
- package/esm/components/AndOrController/AndOrController.js +213 -0
- package/esm/components/ConditionController/ConditionController.js +92 -0
- package/esm/components/DisplayOutput/DisplayOutput.js +87 -0
- package/esm/components/DragContainerController/DragContainerController.js +39 -0
- package/esm/components/DragControllerRow/DragControllerRow.js +39 -0
- package/esm/components/FieldControllerRow/FieldControllerRow.js +27 -0
- package/esm/components/Nestable/Nestable.js +312 -0
- package/esm/components/Nestable/NestableItem.js +103 -0
- package/esm/components/Nestable/actions/events.js +153 -0
- package/{dist/esm → esm}/components/Nestable/actions/getItemOptions.js +11 -7
- package/{dist/esm → esm}/components/Nestable/actions/getPaths.js +43 -17
- package/esm/components/Nestable/actions/index.js +6 -0
- package/esm/components/Nestable/actions/moveItem.js +45 -0
- package/{dist/esm → esm}/components/Nestable/actions/paths.js +47 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +31 -0
- package/{dist/esm → esm}/components/Nestable/actions/tryIncreaseDepth.js +22 -10
- package/esm/components/Nestable/index.js +2 -0
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -0
- package/esm/components/QueryBuilderImpl.js +301 -0
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +83 -0
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +268 -0
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +20 -0
- package/esm/components/format/format.js +31 -0
- package/esm/components/format/sqlFormat.js +69 -0
- package/esm/components/format/sqlSafeFormat.js +76 -0
- package/esm/components/format/xmlFormat.js +69 -0
- package/esm/components/helpers/actions.js +254 -0
- package/esm/components/helpers/constants.js +5 -0
- package/esm/components/helpers/dependencies.js +60 -0
- package/esm/components/helpers/selectors.js +93 -0
- package/esm/components/helpers/store.js +171 -0
- package/esm/components/helpers/types.js +52 -0
- package/esm/index.js +4 -0
- package/esm/propTypes.js +93 -0
- package/package.json +95 -97
- package/{dist/types → types}/DSQueryBuilder.d.ts +0 -0
- package/{dist/types → types}/components/AndOrController/AndOrController.d.ts +0 -0
- package/{dist/types → types}/components/ConditionController/ConditionController.d.ts +0 -0
- package/{dist/types → types}/components/DisplayOutput/DisplayOutput.d.ts +0 -0
- package/{dist/types → types}/components/DragContainerController/DragContainerController.d.ts +0 -0
- package/{dist/types → types}/components/DragControllerRow/DragControllerRow.d.ts +0 -0
- package/{dist/types → types}/components/FieldControllerRow/FieldControllerRow.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/Nestable.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/NestableItem.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/events.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/getItemOptions.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/getPaths.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/index.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/moveItem.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/paths.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/tryDecreaseDepth.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/actions/tryIncreaseDepth.d.ts +0 -0
- package/{dist/types → types}/components/Nestable/index.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderContext/QueryBuilderContext.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderImpl.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderItem/QueryBuilderItem.d.ts +0 -0
- package/{dist/types → types}/components/QueryBuilderRow/QueryBuilderRow.d.ts +0 -0
- package/{dist/types → types}/components/ToolBarAnimation/ToolBarAnimation.d.ts +0 -0
- package/{dist/types → types}/components/format/format.d.ts +0 -0
- package/{dist/types → types}/components/format/sqlFormat.d.ts +0 -0
- package/{dist/types → types}/components/format/sqlSafeFormat.d.ts +0 -0
- package/{dist/types → types}/components/format/xmlFormat.d.ts +0 -0
- package/{dist/types → types}/components/helpers/actions.d.ts +0 -0
- package/{dist/types → types}/components/helpers/constants.d.ts +0 -0
- package/{dist/types → types}/components/helpers/dependencies.d.ts +0 -0
- package/{dist/types → types}/components/helpers/selectors.d.ts +0 -0
- package/{dist/types → types}/components/helpers/store.d.ts +0 -0
- package/{dist/types → types}/components/helpers/types.d.ts +0 -0
- package/{dist/types → types}/index.d.ts +0 -0
- package/{dist/types → types}/propTypes.d.ts +0 -0
- package/dist/cjs/DSQueryBuilder.js +0 -118
- package/dist/cjs/DSQueryBuilder.js.map +0 -7
- package/dist/cjs/components/AndOrController/AndOrController.js +0 -208
- package/dist/cjs/components/AndOrController/AndOrController.js.map +0 -7
- package/dist/cjs/components/ConditionController/ConditionController.js +0 -116
- package/dist/cjs/components/ConditionController/ConditionController.js.map +0 -7
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js +0 -92
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/dist/cjs/components/DragContainerController/DragContainerController.js +0 -65
- package/dist/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js +0 -51
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js +0 -55
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/dist/cjs/components/Nestable/Nestable.js +0 -254
- package/dist/cjs/components/Nestable/Nestable.js.map +0 -7
- package/dist/cjs/components/Nestable/NestableItem.js +0 -119
- package/dist/cjs/components/Nestable/NestableItem.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/events.js +0 -143
- package/dist/cjs/components/Nestable/actions/events.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/getItemOptions.js +0 -49
- package/dist/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/getPaths.js +0 -119
- package/dist/cjs/components/Nestable/actions/getPaths.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/index.js +0 -42
- package/dist/cjs/components/Nestable/actions/index.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/moveItem.js +0 -56
- package/dist/cjs/components/Nestable/actions/moveItem.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/paths.js +0 -119
- package/dist/cjs/components/Nestable/actions/paths.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js +0 -51
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js +0 -51
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/dist/cjs/components/Nestable/index.js +0 -36
- package/dist/cjs/components/Nestable/index.js.map +0 -7
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js +0 -36
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/dist/cjs/components/QueryBuilderImpl.js +0 -225
- package/dist/cjs/components/QueryBuilderImpl.js.map +0 -7
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js +0 -92
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js +0 -219
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js +0 -42
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/dist/cjs/components/format/format.js +0 -59
- package/dist/cjs/components/format/format.js.map +0 -7
- package/dist/cjs/components/format/sqlFormat.js +0 -94
- package/dist/cjs/components/format/sqlFormat.js.map +0 -7
- package/dist/cjs/components/format/sqlSafeFormat.js +0 -98
- package/dist/cjs/components/format/sqlSafeFormat.js.map +0 -7
- package/dist/cjs/components/format/xmlFormat.js +0 -94
- package/dist/cjs/components/format/xmlFormat.js.map +0 -7
- package/dist/cjs/components/helpers/actions.js +0 -242
- package/dist/cjs/components/helpers/actions.js.map +0 -7
- package/dist/cjs/components/helpers/constants.js +0 -39
- package/dist/cjs/components/helpers/constants.js.map +0 -7
- package/dist/cjs/components/helpers/dependencies.js +0 -69
- package/dist/cjs/components/helpers/dependencies.js.map +0 -7
- package/dist/cjs/components/helpers/selectors.js +0 -161
- package/dist/cjs/components/helpers/selectors.js.map +0 -7
- package/dist/cjs/components/helpers/store.js +0 -159
- package/dist/cjs/components/helpers/store.js.map +0 -7
- package/dist/cjs/components/helpers/types.js +0 -92
- package/dist/cjs/components/helpers/types.js.map +0 -7
- package/dist/cjs/index.js +0 -36
- package/dist/cjs/index.js.map +0 -7
- package/dist/cjs/propTypes.js +0 -105
- package/dist/cjs/propTypes.js.map +0 -7
- package/dist/esm/DSQueryBuilder.js +0 -105
- package/dist/esm/DSQueryBuilder.js.map +0 -7
- package/dist/esm/components/AndOrController/AndOrController.js +0 -179
- package/dist/esm/components/AndOrController/AndOrController.js.map +0 -7
- package/dist/esm/components/ConditionController/ConditionController.js +0 -87
- package/dist/esm/components/ConditionController/ConditionController.js.map +0 -7
- package/dist/esm/components/DisplayOutput/DisplayOutput.js +0 -63
- package/dist/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/dist/esm/components/DragContainerController/DragContainerController.js +0 -36
- package/dist/esm/components/DragContainerController/DragContainerController.js.map +0 -7
- package/dist/esm/components/DragControllerRow/DragControllerRow.js +0 -22
- package/dist/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js +0 -26
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/dist/esm/components/Nestable/Nestable.js +0 -241
- package/dist/esm/components/Nestable/Nestable.js.map +0 -7
- package/dist/esm/components/Nestable/NestableItem.js +0 -90
- package/dist/esm/components/Nestable/NestableItem.js.map +0 -7
- package/dist/esm/components/Nestable/actions/events.js +0 -119
- package/dist/esm/components/Nestable/actions/events.js.map +0 -7
- package/dist/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/dist/esm/components/Nestable/actions/getPaths.js.map +0 -7
- package/dist/esm/components/Nestable/actions/index.js +0 -13
- package/dist/esm/components/Nestable/actions/index.js.map +0 -7
- package/dist/esm/components/Nestable/actions/moveItem.js +0 -27
- package/dist/esm/components/Nestable/actions/moveItem.js.map +0 -7
- package/dist/esm/components/Nestable/actions/paths.js.map +0 -7
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js +0 -22
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/dist/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/dist/esm/components/Nestable/index.js +0 -7
- package/dist/esm/components/Nestable/index.js.map +0 -7
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js +0 -7
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/dist/esm/components/QueryBuilderImpl.js +0 -196
- package/dist/esm/components/QueryBuilderImpl.js.map +0 -7
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js +0 -63
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js +0 -190
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js +0 -13
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/dist/esm/components/format/format.js +0 -30
- package/dist/esm/components/format/format.js.map +0 -7
- package/dist/esm/components/format/sqlFormat.js +0 -65
- package/dist/esm/components/format/sqlFormat.js.map +0 -7
- package/dist/esm/components/format/sqlSafeFormat.js +0 -69
- package/dist/esm/components/format/sqlSafeFormat.js.map +0 -7
- package/dist/esm/components/format/xmlFormat.js +0 -65
- package/dist/esm/components/format/xmlFormat.js.map +0 -7
- package/dist/esm/components/helpers/actions.js +0 -217
- package/dist/esm/components/helpers/actions.js.map +0 -7
- package/dist/esm/components/helpers/constants.js +0 -10
- package/dist/esm/components/helpers/constants.js.map +0 -7
- package/dist/esm/components/helpers/dependencies.js +0 -40
- package/dist/esm/components/helpers/dependencies.js.map +0 -7
- package/dist/esm/components/helpers/selectors.js +0 -132
- package/dist/esm/components/helpers/selectors.js.map +0 -7
- package/dist/esm/components/helpers/store.js +0 -143
- package/dist/esm/components/helpers/store.js.map +0 -7
- package/dist/esm/components/helpers/types.js +0 -63
- package/dist/esm/components/helpers/types.js.map +0 -7
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/esm/propTypes.js +0 -76
- package/dist/esm/propTypes.js.map +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { sqlFormat } from './sqlFormat.js';
|
|
2
|
+
import { xmlFormat } from './xmlFormat.js';
|
|
3
|
+
import { sqlSafeFormat } from './sqlSafeFormat.js';
|
|
4
|
+
|
|
5
|
+
class QueryBuilderFormat {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.format = {
|
|
8
|
+
defaultFormat: query => query,
|
|
9
|
+
sqlFormat,
|
|
10
|
+
xmlFormat,
|
|
11
|
+
sqlSafeFormat
|
|
12
|
+
};
|
|
13
|
+
this.currentFormat = 'sqlFormat';
|
|
14
|
+
|
|
15
|
+
this.setDefaultFormat = formatName => {
|
|
16
|
+
if (this.format[formatName]) this.currentFormat = formatName;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.addFormat = (formatName, format) => this.format[formatName] = format;
|
|
20
|
+
|
|
21
|
+
this.run = (query, formatName) => {
|
|
22
|
+
if (this.format[formatName]) return this.format[formatName](query);
|
|
23
|
+
return this.format[this.currentFormat](query);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var QueryBuilderFormat$1 = new QueryBuilderFormat();
|
|
30
|
+
|
|
31
|
+
export { QueryBuilderFormat$1 as default };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
5
|
+
const conditionSql = (condition, value) => {
|
|
6
|
+
const {
|
|
7
|
+
EQUAL,
|
|
8
|
+
NOT_EQUAL,
|
|
9
|
+
GREATER_THAN,
|
|
10
|
+
LESS_THAN,
|
|
11
|
+
CONTAINS,
|
|
12
|
+
NOT_CONTAINS,
|
|
13
|
+
BETWEEN,
|
|
14
|
+
GREATER_THAN_OR_EQUAL,
|
|
15
|
+
LESS_THAN_OR_EQUAL,
|
|
16
|
+
START_WITH
|
|
17
|
+
} = QB_OPERATOR_TYPES;
|
|
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
|
+
return condition;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const renderFilterSQl = filter => {
|
|
32
|
+
const {
|
|
33
|
+
field,
|
|
34
|
+
operator,
|
|
35
|
+
value
|
|
36
|
+
} = filter.element;
|
|
37
|
+
return "".concat(field, " ").concat(conditionSql(operator, value) || '');
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const sqlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
47
|
+
const groupSql = (item, idGroup) => {
|
|
48
|
+
if (idGroup === main) {
|
|
49
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const filterSql = (filters, groupCondition) => {
|
|
58
|
+
const filterGroup = filters.map(filter => {
|
|
59
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
60
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
61
|
+
});
|
|
62
|
+
return filterGroup.join(groupCondition);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
66
|
+
return sql;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { sqlFormat };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
5
|
+
const specialChar = /[ !@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/;
|
|
6
|
+
|
|
7
|
+
const conditionSql = (condition, value) => {
|
|
8
|
+
const {
|
|
9
|
+
EQUAL,
|
|
10
|
+
NOT_EQUAL,
|
|
11
|
+
GREATER_THAN,
|
|
12
|
+
LESS_THAN,
|
|
13
|
+
CONTAINS,
|
|
14
|
+
NOT_CONTAINS,
|
|
15
|
+
BETWEEN,
|
|
16
|
+
GREATER_THAN_OR_EQUAL,
|
|
17
|
+
LESS_THAN_OR_EQUAL,
|
|
18
|
+
START_WITH
|
|
19
|
+
} = QB_OPERATOR_TYPES; // eslint-disable-next-line no-restricted-globals
|
|
20
|
+
|
|
21
|
+
const valueDisplay = isNaN(value) ? "'".concat(value, "'") : value;
|
|
22
|
+
if (condition === EQUAL) return " = ".concat(valueDisplay);
|
|
23
|
+
if (condition === NOT_EQUAL) return " <> ".concat(valueDisplay);
|
|
24
|
+
if (condition === GREATER_THAN) return " > ".concat(valueDisplay);
|
|
25
|
+
if (condition === LESS_THAN) return " < ".concat(valueDisplay);
|
|
26
|
+
if (condition === CONTAINS) return " LIKE '%".concat(value, "%'");
|
|
27
|
+
if (condition === NOT_CONTAINS) return " NOT LIKE '%".concat(value, "%'");
|
|
28
|
+
if (condition === BETWEEN) return " BETWEEN ".concat(value[0], " AND ").concat(value[1], " ");
|
|
29
|
+
if (condition === GREATER_THAN_OR_EQUAL) return " >= ".concat(value);
|
|
30
|
+
if (condition === LESS_THAN_OR_EQUAL) return " <= ".concat(value);
|
|
31
|
+
if (condition === START_WITH) return " LIKE '".concat(value, "%'");
|
|
32
|
+
return condition;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const renderFilterSQl = filter => {
|
|
36
|
+
const {
|
|
37
|
+
field,
|
|
38
|
+
operator,
|
|
39
|
+
value
|
|
40
|
+
} = filter.element; // eslint-disable-next-line no-restricted-globals
|
|
41
|
+
|
|
42
|
+
const fieldDisplay = // eslint-disable-next-line no-restricted-globals
|
|
43
|
+
/[.]/.test(field) || !isNaN(field) ? "\\\"".concat(field, "\\\"") : field;
|
|
44
|
+
return "".concat(fieldDisplay, " ").concat(conditionSql(operator, value) || '');
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const sqlSafeFormat = _ref => {
|
|
48
|
+
let {
|
|
49
|
+
main,
|
|
50
|
+
mapGroups,
|
|
51
|
+
items
|
|
52
|
+
} = _ref;
|
|
53
|
+
|
|
54
|
+
const groupSql = (item, idGroup) => {
|
|
55
|
+
if (idGroup === main) {
|
|
56
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
57
|
+
return " ( ".concat(filterSql(item, groupCondition), " ) "); // eslint-disable-line
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
61
|
+
return " ( ".concat(filterSql(item.children, groupCondition), " ) "); // eslint-disable-line
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const filterSql = (filters, groupCondition) => {
|
|
65
|
+
const filterGroup = filters.map(filter => {
|
|
66
|
+
if (filter.element.type === 'filter') return " ".concat(renderFilterSQl(filter), " ");
|
|
67
|
+
return " ".concat(groupSql(filter) || '', " ");
|
|
68
|
+
});
|
|
69
|
+
return filterGroup.join(groupCondition);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const sql = " FROM [TABLE_NAME] WHERE ".concat(groupSql(items, main) || '', " ");
|
|
73
|
+
return sql;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { specialChar, sqlSafeFormat };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
+
import { QB_OPERATOR_TYPES } from '../helpers/types.js';
|
|
4
|
+
|
|
5
|
+
const conditionSql = (condition, value) => {
|
|
6
|
+
const {
|
|
7
|
+
EQUAL,
|
|
8
|
+
NOT_EQUAL,
|
|
9
|
+
GREATER_THAN,
|
|
10
|
+
LESS_THAN,
|
|
11
|
+
CONTAINS,
|
|
12
|
+
NOT_CONTAINS,
|
|
13
|
+
BETWEEN,
|
|
14
|
+
GREATER_THAN_OR_EQUAL,
|
|
15
|
+
LESS_THAN_OR_EQUAL,
|
|
16
|
+
START_WITH
|
|
17
|
+
} = QB_OPERATOR_TYPES;
|
|
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
|
+
return condition;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const renderFilterSQl = filter => {
|
|
32
|
+
const {
|
|
33
|
+
field,
|
|
34
|
+
operator,
|
|
35
|
+
value
|
|
36
|
+
} = filter.element;
|
|
37
|
+
return "<filter><field>".concat(field, "</field>").concat(conditionSql(operator, value) || '', "</filter>");
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const xmlFormat = _ref => {
|
|
41
|
+
let {
|
|
42
|
+
main,
|
|
43
|
+
mapGroups,
|
|
44
|
+
items
|
|
45
|
+
} = _ref;
|
|
46
|
+
|
|
47
|
+
const groupXML = (item, idGroup) => {
|
|
48
|
+
if (idGroup === main) {
|
|
49
|
+
const groupCondition = mapGroups[idGroup].condition === true ? 'AND' : 'OR';
|
|
50
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item), "</group>"); // eslint-disable-line
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const groupCondition = item.element.condition === true ? 'AND' : 'OR';
|
|
54
|
+
return "<group value=\"".concat(groupCondition, "\">").concat(filterXML(item.children), "</group>"); // eslint-disable-line
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const filterXML = filters => {
|
|
58
|
+
const filterGroup = filters.map(filter => {
|
|
59
|
+
if (filter.element.type === 'filter') return "".concat(renderFilterSQl(filter) || '', " ");
|
|
60
|
+
return " ".concat(groupXML(filter), " ");
|
|
61
|
+
});
|
|
62
|
+
return filterGroup.join('');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const xml = "<xml><query>".concat(groupXML(items, main) || '', "</query></xml>");
|
|
66
|
+
return xml;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { xmlFormat };
|
|
@@ -0,0 +1,254 @@
|
|
|
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';
|
|
11
|
+
import { QB_DRAG_TYPES, QB_GROUP_CONDITION_TYPES, QB_FIELD_SHARED_ACTIONS } from './types.js';
|
|
12
|
+
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
/**
|
|
17
|
+
* this is injected. instance of QBStore
|
|
18
|
+
*
|
|
19
|
+
* @param {*} idGroup: UUID
|
|
20
|
+
* @param idGroup
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const createNewFilter = function (idGroup) {
|
|
24
|
+
const idFilter = "filter_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
25
|
+
return {
|
|
26
|
+
idGroup,
|
|
27
|
+
field: '',
|
|
28
|
+
condition: '',
|
|
29
|
+
value: '',
|
|
30
|
+
idFilter,
|
|
31
|
+
type: QB_DRAG_TYPES.FILTER
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* this is injected. instance of QBStore
|
|
36
|
+
*
|
|
37
|
+
* @param {*} parentIdGroup: UUID
|
|
38
|
+
* @param parentIdGroup
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const createNewGroup = function (parentIdGroup) {
|
|
42
|
+
const idGroup = "group_".concat(new Date().getTime(), "_").concat(Math.random().toString(36).substring(7));
|
|
43
|
+
return {
|
|
44
|
+
parentIdGroup,
|
|
45
|
+
idGroup,
|
|
46
|
+
condition: QB_GROUP_CONDITION_TYPES.AND,
|
|
47
|
+
type: QB_DRAG_TYPES.GROUP
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* this is injected. instance of QBStore
|
|
52
|
+
*
|
|
53
|
+
* @param {*} newFilter
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
const addFilterToMap = function (newFilter) {
|
|
57
|
+
this.mapFilters = _objectSpread(_objectSpread({}, this.mapFilters), {}, {
|
|
58
|
+
[newFilter.idFilter]: newFilter
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* this is injected. instance of QBStore
|
|
63
|
+
*
|
|
64
|
+
* @param {*} newFilter
|
|
65
|
+
* @param newGroup
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
const addGroupToMap = function (newGroup) {
|
|
69
|
+
this.mapGroups = _objectSpread(_objectSpread({}, this.mapGroups), {}, {
|
|
70
|
+
[newGroup.idGroup]: _objectSpread({}, newGroup)
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const addFilterToItem = function (item, newFilter) {
|
|
74
|
+
item.children.push({
|
|
75
|
+
id: newFilter.idFilter,
|
|
76
|
+
element: newFilter,
|
|
77
|
+
children: []
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
const addFilterToMainItem = function (items, newFilter) {
|
|
81
|
+
items.push({
|
|
82
|
+
id: newFilter.idFilter,
|
|
83
|
+
element: newFilter,
|
|
84
|
+
children: []
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const findInChilds = function (childs, filterId) {
|
|
88
|
+
const found = childs.find(_ref => {
|
|
89
|
+
let {
|
|
90
|
+
id
|
|
91
|
+
} = _ref;
|
|
92
|
+
return id === filterId;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (!found) {
|
|
96
|
+
let findInChild;
|
|
97
|
+
childs.forEach(item => {
|
|
98
|
+
if (!findInChild) findInChild = findInChilds(item.children, filterId);
|
|
99
|
+
});
|
|
100
|
+
if (findInChild) return findInChild;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return found;
|
|
104
|
+
};
|
|
105
|
+
const findItemFilterById = function (filterId) {
|
|
106
|
+
return findInChilds(this.items, filterId);
|
|
107
|
+
};
|
|
108
|
+
const findParentWithFilterId = function (childs, filterId) {
|
|
109
|
+
const found = childs.find(_ref2 => {
|
|
110
|
+
let {
|
|
111
|
+
id
|
|
112
|
+
} = _ref2;
|
|
113
|
+
return id === filterId;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
if (!found) {
|
|
117
|
+
let findInChild;
|
|
118
|
+
childs.forEach(item => {
|
|
119
|
+
if (!findInChild) findInChild = findParentWithFilterId(item.children, filterId);
|
|
120
|
+
});
|
|
121
|
+
if (findInChild) return findInChild;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return childs;
|
|
125
|
+
};
|
|
126
|
+
const findParentFilterById = function (filterId) {
|
|
127
|
+
return findParentWithFilterId(this.items, filterId);
|
|
128
|
+
};
|
|
129
|
+
const filterInChildren = function (childs, filterId, mainId) {
|
|
130
|
+
if (childs.children) {
|
|
131
|
+
childs.children = childs.children.filter(_ref3 => {
|
|
132
|
+
let {
|
|
133
|
+
id
|
|
134
|
+
} = _ref3;
|
|
135
|
+
return id !== filterId;
|
|
136
|
+
});
|
|
137
|
+
childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
|
|
138
|
+
return childs;
|
|
139
|
+
} // main
|
|
140
|
+
|
|
141
|
+
|
|
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
|
|
148
|
+
|
|
149
|
+
if (childs.length === 0 && mainId) {
|
|
150
|
+
const emptyFilter = createNewFilter.call(this, mainId);
|
|
151
|
+
addFilterToMainItem.call(this, childs, emptyFilter);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
childs.forEach(item => item.children = filterInChildren(item.children, filterId));
|
|
155
|
+
return childs;
|
|
156
|
+
};
|
|
157
|
+
const removeFilterItem = function (filterId) {
|
|
158
|
+
this.items = filterInChildren(this.items, filterId, this.main);
|
|
159
|
+
};
|
|
160
|
+
const addGroupFilterToItem = function (idGroup, idFilter, newGroup) {
|
|
161
|
+
const child = findItemFilterById.call(this, idFilter);
|
|
162
|
+
|
|
163
|
+
const copy = _objectSpread({}, child);
|
|
164
|
+
|
|
165
|
+
if (copy.element.type === 'group') {
|
|
166
|
+
copy.element.parentIdGroup = newGroup.idGroup;
|
|
167
|
+
} else {
|
|
168
|
+
copy.element.idGroup = newGroup.idGroup;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
child.id = newGroup.idGroup;
|
|
172
|
+
child.element = newGroup;
|
|
173
|
+
child.children = [copy];
|
|
174
|
+
};
|
|
175
|
+
const unGroupFilterToItem = function (idGroup) {
|
|
176
|
+
const group = findItemFilterById.call(this, idGroup);
|
|
177
|
+
|
|
178
|
+
if (group.element.parentIdGroup === this.main) {
|
|
179
|
+
const index = this.items.map(item => item.id).indexOf(idGroup);
|
|
180
|
+
const tmp = [];
|
|
181
|
+
tmp.splice.apply(this.items, [index, 1].concat(group.children));
|
|
182
|
+
this.items.forEach(item => {
|
|
183
|
+
if (item.element.type === 'group') {
|
|
184
|
+
item.element.parentIdGroup = this.main;
|
|
185
|
+
} else {
|
|
186
|
+
item.element.idGroup = this.main;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
} else {
|
|
190
|
+
const parent = findItemFilterById.call(this, group.element.parentIdGroup);
|
|
191
|
+
const index = parent.children.map(item => item.id).indexOf(idGroup);
|
|
192
|
+
const tmp = [];
|
|
193
|
+
tmp.splice.apply(parent.children, [index, 1].concat(group.children));
|
|
194
|
+
parent.children.forEach(item => {
|
|
195
|
+
if (item.element.type === 'group') {
|
|
196
|
+
item.element.parentIdGroup = parent.id;
|
|
197
|
+
} else {
|
|
198
|
+
item.element.idGroup = parent.id;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const changeGroupOperator = function (idGroup, value) {
|
|
204
|
+
const group = findItemFilterById.call(this, idGroup);
|
|
205
|
+
|
|
206
|
+
if (idGroup !== this.main) {
|
|
207
|
+
group.element.condition = value;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
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;
|
|
224
|
+
const child = findItemFilterById.call(this, idFilter);
|
|
225
|
+
if (field || field === '' || typeof field === 'boolean') child.element.field = field;
|
|
226
|
+
if (operator) child.element.operator = operator;
|
|
227
|
+
if (value || value === '' || typeof value === 'boolean') child.element.value = value;
|
|
228
|
+
if (additionalInfo) child.element.additionalInfo = additionalInfo; // shared fields actions
|
|
229
|
+
|
|
230
|
+
if (target === 'field') {
|
|
231
|
+
onFieldChange.forEach(_ref6 => {
|
|
232
|
+
let {
|
|
233
|
+
action
|
|
234
|
+
} = _ref6;
|
|
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;
|
|
236
|
+
});
|
|
237
|
+
} else if (target === 'operator') {
|
|
238
|
+
onOperatorChange.forEach(_ref7 => {
|
|
239
|
+
let {
|
|
240
|
+
action
|
|
241
|
+
} = _ref7;
|
|
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;
|
|
243
|
+
});
|
|
244
|
+
} else if (target === 'value') {
|
|
245
|
+
onValueChange.forEach(_ref8 => {
|
|
246
|
+
let {
|
|
247
|
+
action
|
|
248
|
+
} = _ref8;
|
|
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;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export { addFilterToItem, addFilterToMainItem, addFilterToMap, addGroupFilterToItem, addGroupToMap, changeFilterItem, changeGroupOperator, createNewFilter, createNewGroup, filterInChildren, findInChilds, findItemFilterById, findParentFilterById, findParentWithFilterId, removeFilterItem, unGroupFilterToItem };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.every.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.every.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.some.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import * as operators from '@elliemae/ds-utilities/operators';
|
|
10
|
+
import { QB_GROUP_CONDITION_TYPES } from './types.js';
|
|
11
|
+
|
|
12
|
+
const resolveCondition = function (condition, state) {
|
|
13
|
+
let resolveBy = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : QB_GROUP_CONDITION_TYPES.AND;
|
|
14
|
+
if (condition.length === 0 || !condition) return true; // resolve by AND: all the conditions must be true
|
|
15
|
+
|
|
16
|
+
if (resolveBy) {
|
|
17
|
+
return condition.every(rule => {
|
|
18
|
+
const {
|
|
19
|
+
source: sourceRule,
|
|
20
|
+
operator: operatorRule,
|
|
21
|
+
value: valueRule
|
|
22
|
+
} = rule;
|
|
23
|
+
if (typeof operatorRule === "function") return operatorRule(get(state, sourceRule), valueRule);
|
|
24
|
+
return operators[operatorRule](get(state, sourceRule), valueRule);
|
|
25
|
+
});
|
|
26
|
+
} // resolve by OR: at least one condition must be true
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
return condition.some(rule => {
|
|
30
|
+
const {
|
|
31
|
+
source: sourceRule,
|
|
32
|
+
operator: operatorRule,
|
|
33
|
+
value: valueRule
|
|
34
|
+
} = rule;
|
|
35
|
+
return operators[operatorRule](state[sourceRule], valueRule);
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const resolveDependencies = (state, fields) => {
|
|
40
|
+
const fieldsToRender = fields.reduce((result, _ref) => {
|
|
41
|
+
let {
|
|
42
|
+
target,
|
|
43
|
+
component,
|
|
44
|
+
condition,
|
|
45
|
+
resolveBy,
|
|
46
|
+
validation,
|
|
47
|
+
handleWidth
|
|
48
|
+
} = _ref;
|
|
49
|
+
if (resolveCondition(condition, state, resolveBy)) result.push({
|
|
50
|
+
target,
|
|
51
|
+
component,
|
|
52
|
+
validation,
|
|
53
|
+
handleWidth
|
|
54
|
+
});
|
|
55
|
+
return result;
|
|
56
|
+
}, []);
|
|
57
|
+
return fieldsToRender;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { resolveDependencies };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { QB_FIELD_TYPES, QB_OPERATOR_TYPES } from './types.js';
|
|
2
|
+
|
|
3
|
+
const QB_DEFAULT_VALUES_OPTIONS = [{
|
|
4
|
+
label: 'Choose a Field',
|
|
5
|
+
value: ''
|
|
6
|
+
}];
|
|
7
|
+
const QB_SUBJECT_VALUES_OPTIONS = [{
|
|
8
|
+
label: 'Condominium',
|
|
9
|
+
value: 'Condominium'
|
|
10
|
+
}, {
|
|
11
|
+
label: 'Single Family Home',
|
|
12
|
+
value: 'Single Family Home'
|
|
13
|
+
}, {
|
|
14
|
+
label: 'Co-Operative',
|
|
15
|
+
value: 'Co-Operative'
|
|
16
|
+
}, {
|
|
17
|
+
label: 'Detached',
|
|
18
|
+
value: 'Detached'
|
|
19
|
+
}, {
|
|
20
|
+
label: 'High Rise Condominium',
|
|
21
|
+
value: 'High Rise Condominium'
|
|
22
|
+
}, {
|
|
23
|
+
label: 'Manufactured Housing',
|
|
24
|
+
value: 'Manufactured Housing'
|
|
25
|
+
}, {
|
|
26
|
+
label: 'Other',
|
|
27
|
+
value: 'Other'
|
|
28
|
+
}];
|
|
29
|
+
const QB_LOAN_VALUES_OPTIONS = [{
|
|
30
|
+
label: 'Conventional',
|
|
31
|
+
value: 'Conventional'
|
|
32
|
+
}, {
|
|
33
|
+
label: 'VA',
|
|
34
|
+
value: 'VA'
|
|
35
|
+
}, {
|
|
36
|
+
label: 'FHA',
|
|
37
|
+
value: 'FHA'
|
|
38
|
+
}, {
|
|
39
|
+
label: 'USAD-RHS',
|
|
40
|
+
value: 'USAD-RHS'
|
|
41
|
+
}, {
|
|
42
|
+
label: 'HELOC',
|
|
43
|
+
value: 'HELOC'
|
|
44
|
+
}, {
|
|
45
|
+
label: 'Other',
|
|
46
|
+
value: 'Other'
|
|
47
|
+
}];
|
|
48
|
+
const QB_FIELD_OPTIONS = [{
|
|
49
|
+
label: 'Select',
|
|
50
|
+
value: ''
|
|
51
|
+
}, {
|
|
52
|
+
label: 'Loan Type',
|
|
53
|
+
value: QB_FIELD_TYPES.LOAN_VALUES
|
|
54
|
+
}, {
|
|
55
|
+
label: 'Loan To Value (LTV)',
|
|
56
|
+
value: QB_FIELD_TYPES.LTV_VALUES
|
|
57
|
+
}, {
|
|
58
|
+
label: 'Subject Property Type',
|
|
59
|
+
value: QB_FIELD_TYPES.SUBJECT_VALUES
|
|
60
|
+
}, {
|
|
61
|
+
label: 'Last Finished Milestone',
|
|
62
|
+
value: QB_FIELD_TYPES.LAST_VALUES
|
|
63
|
+
}, {
|
|
64
|
+
label: 'Credit Score',
|
|
65
|
+
value: QB_FIELD_TYPES.CREDIT_VALUES
|
|
66
|
+
}];
|
|
67
|
+
const QB_OPERATOR_OPTIONS = [{
|
|
68
|
+
label: 'Select',
|
|
69
|
+
value: ''
|
|
70
|
+
}, {
|
|
71
|
+
label: 'Is',
|
|
72
|
+
value: QB_OPERATOR_TYPES.EQUAL
|
|
73
|
+
}, {
|
|
74
|
+
label: 'Is not',
|
|
75
|
+
value: QB_OPERATOR_TYPES.NOT_EQUAL
|
|
76
|
+
}, {
|
|
77
|
+
label: 'Greater than',
|
|
78
|
+
value: QB_OPERATOR_TYPES.GREATER_THAN
|
|
79
|
+
}, {
|
|
80
|
+
label: 'Less than',
|
|
81
|
+
value: QB_OPERATOR_TYPES.LESS_THAN
|
|
82
|
+
}, {
|
|
83
|
+
label: 'Contains',
|
|
84
|
+
value: QB_OPERATOR_TYPES.CONTAINS
|
|
85
|
+
}, {
|
|
86
|
+
label: "Doesn't Contain",
|
|
87
|
+
value: QB_OPERATOR_TYPES.NOT_CONTAINS
|
|
88
|
+
}, {
|
|
89
|
+
label: 'Between',
|
|
90
|
+
value: QB_OPERATOR_TYPES.BETWEEN
|
|
91
|
+
}];
|
|
92
|
+
|
|
93
|
+
export { QB_DEFAULT_VALUES_OPTIONS, QB_FIELD_OPTIONS, QB_LOAN_VALUES_OPTIONS, QB_OPERATOR_OPTIONS, QB_SUBJECT_VALUES_OPTIONS };
|