@elliemae/ds-query-builder 2.2.0 → 2.3.0-alpha.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 +117 -97
- package/cjs/DSQueryBuilder.js.map +7 -0
- package/cjs/components/AndOrController/AndOrController.js +148 -162
- package/cjs/components/AndOrController/AndOrController.js.map +7 -0
- package/cjs/components/ConditionController/ConditionController.js +88 -72
- package/cjs/components/ConditionController/ConditionController.js.map +7 -0
- package/cjs/components/DisplayOutput/DisplayOutput.js +67 -64
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/cjs/components/DragContainerController/DragContainerController.js +61 -41
- package/cjs/components/DragContainerController/DragContainerController.js.map +7 -0
- package/cjs/components/DragControllerRow/DragControllerRow.js +50 -46
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +54 -32
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/cjs/components/Nestable/Nestable.js +143 -209
- package/cjs/components/Nestable/Nestable.js.map +7 -0
- package/cjs/components/Nestable/NestableItem.js +98 -90
- package/cjs/components/Nestable/NestableItem.js.map +7 -0
- package/cjs/components/Nestable/actions/events.js +72 -95
- package/cjs/components/Nestable/actions/events.js.map +7 -0
- package/cjs/components/Nestable/actions/getItemOptions.js +36 -15
- package/cjs/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/cjs/components/Nestable/actions/getPaths.js +46 -51
- package/cjs/components/Nestable/actions/getPaths.js.map +7 -0
- package/cjs/components/Nestable/actions/index.js +42 -28
- package/cjs/components/Nestable/actions/index.js.map +7 -0
- package/cjs/components/Nestable/actions/moveItem.js +44 -42
- package/cjs/components/Nestable/actions/moveItem.js.map +7 -0
- package/cjs/components/Nestable/actions/paths.js +48 -55
- package/cjs/components/Nestable/actions/paths.js.map +7 -0
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +39 -23
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +39 -26
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/index.js +36 -7
- package/cjs/components/Nestable/index.js.map +7 -0
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +36 -13
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/cjs/components/QueryBuilderImpl.js +118 -202
- package/cjs/components/QueryBuilderImpl.js.map +7 -0
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +80 -78
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -211
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +39 -26
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/cjs/components/format/format.js +48 -22
- package/cjs/components/format/format.js.map +7 -0
- package/cjs/components/format/sqlFormat.js +69 -48
- package/cjs/components/format/sqlFormat.js.map +7 -0
- package/cjs/components/format/sqlSafeFormat.js +72 -55
- package/cjs/components/format/sqlSafeFormat.js.map +7 -0
- package/cjs/components/format/xmlFormat.js +71 -50
- package/cjs/components/format/xmlFormat.js.map +7 -0
- package/cjs/components/helpers/actions.js +151 -186
- package/cjs/components/helpers/actions.js.map +7 -0
- package/cjs/components/helpers/constants.js +36 -8
- package/cjs/components/helpers/constants.js.map +7 -0
- package/cjs/components/helpers/dependencies.js +49 -64
- package/cjs/components/helpers/dependencies.js.map +7 -0
- package/cjs/components/helpers/selectors.js +161 -101
- package/cjs/components/helpers/selectors.js.map +7 -0
- package/cjs/components/helpers/store.js +86 -104
- package/cjs/components/helpers/store.js.map +7 -0
- package/cjs/components/helpers/types.js +72 -44
- package/cjs/components/helpers/types.js.map +7 -0
- package/cjs/index.js +36 -29
- package/cjs/index.js.map +7 -0
- package/cjs/propTypes.js +102 -94
- package/cjs/propTypes.js.map +7 -0
- package/esm/DSQueryBuilder.js +103 -72
- package/esm/DSQueryBuilder.js.map +7 -0
- package/esm/components/AndOrController/AndOrController.js +113 -147
- package/esm/components/AndOrController/AndOrController.js.map +7 -0
- package/esm/components/ConditionController/ConditionController.js +57 -62
- package/esm/components/ConditionController/ConditionController.js.map +7 -0
- package/esm/components/DisplayOutput/DisplayOutput.js +35 -55
- package/esm/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/esm/components/DragContainerController/DragContainerController.js +32 -35
- package/esm/components/DragContainerController/DragContainerController.js.map +7 -0
- package/esm/components/DragControllerRow/DragControllerRow.js +21 -38
- package/esm/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/esm/components/FieldControllerRow/FieldControllerRow.js +25 -26
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/esm/components/Nestable/Nestable.js +115 -186
- package/esm/components/Nestable/Nestable.js.map +7 -0
- package/esm/components/Nestable/NestableItem.js +69 -82
- package/esm/components/Nestable/NestableItem.js.map +7 -0
- package/esm/components/Nestable/actions/events.js +45 -79
- package/esm/components/Nestable/actions/events.js.map +7 -0
- package/esm/components/Nestable/actions/getItemOptions.js +7 -11
- package/esm/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/esm/components/Nestable/actions/getPaths.js +17 -43
- package/esm/components/Nestable/actions/getPaths.js.map +7 -0
- package/esm/components/Nestable/actions/index.js +13 -6
- package/esm/components/Nestable/actions/index.js.map +7 -0
- package/esm/components/Nestable/actions/moveItem.js +13 -31
- package/esm/components/Nestable/actions/moveItem.js.map +7 -0
- package/esm/components/Nestable/actions/paths.js +19 -47
- package/esm/components/Nestable/actions/paths.js.map +7 -0
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +10 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +10 -22
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/esm/components/Nestable/index.js +7 -2
- package/esm/components/Nestable/index.js.map +7 -0
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +7 -5
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/esm/components/QueryBuilderImpl.js +82 -187
- package/esm/components/QueryBuilderImpl.js.map +7 -0
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +50 -70
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +123 -201
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +10 -17
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/esm/components/format/format.js +16 -17
- package/esm/components/format/format.js.map +7 -0
- package/esm/components/format/sqlFormat.js +39 -43
- package/esm/components/format/sqlFormat.js.map +7 -0
- package/esm/components/format/sqlSafeFormat.js +43 -50
- package/esm/components/format/sqlSafeFormat.js.map +7 -0
- package/esm/components/format/xmlFormat.js +41 -45
- package/esm/components/format/xmlFormat.js.map +7 -0
- package/esm/components/helpers/actions.js +123 -160
- package/esm/components/helpers/actions.js.map +7 -0
- package/esm/components/helpers/constants.js +7 -2
- package/esm/components/helpers/constants.js.map +7 -0
- package/esm/components/helpers/dependencies.js +19 -39
- package/esm/components/helpers/dependencies.js.map +7 -0
- package/esm/components/helpers/selectors.js +132 -93
- package/esm/components/helpers/selectors.js.map +7 -0
- package/esm/components/helpers/store.js +54 -82
- package/esm/components/helpers/store.js.map +7 -0
- package/esm/components/helpers/types.js +44 -33
- package/esm/components/helpers/types.js.map +7 -0
- package/esm/index.js +7 -4
- package/esm/index.js.map +7 -0
- package/esm/propTypes.js +55 -72
- package/esm/propTypes.js.map +7 -0
- package/package.json +12 -12
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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));
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
QB_DRAG_TYPES,
|
|
4
|
+
QB_GROUP_CONDITION_TYPES,
|
|
5
|
+
QB_FIELD_SHARED_ACTIONS
|
|
6
|
+
} from "./types";
|
|
7
|
+
const createNewFilter = function(idGroup) {
|
|
8
|
+
const idFilter = `filter_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
25
9
|
return {
|
|
26
10
|
idGroup,
|
|
27
|
-
field:
|
|
28
|
-
condition:
|
|
29
|
-
value:
|
|
11
|
+
field: "",
|
|
12
|
+
condition: "",
|
|
13
|
+
value: "",
|
|
30
14
|
idFilter,
|
|
31
15
|
type: QB_DRAG_TYPES.FILTER
|
|
32
16
|
};
|
|
33
17
|
};
|
|
34
|
-
|
|
35
|
-
|
|
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));
|
|
18
|
+
const createNewGroup = function(parentIdGroup) {
|
|
19
|
+
const idGroup = `group_${new Date().getTime()}_${Math.random().toString(36).substring(7)}`;
|
|
43
20
|
return {
|
|
44
21
|
parentIdGroup,
|
|
45
22
|
idGroup,
|
|
@@ -47,140 +24,106 @@ const createNewGroup = function (parentIdGroup) {
|
|
|
47
24
|
type: QB_DRAG_TYPES.GROUP
|
|
48
25
|
};
|
|
49
26
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* @param {*} newFilter
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
const addFilterToMap = function (newFilter) {
|
|
57
|
-
this.mapFilters = _objectSpread(_objectSpread({}, this.mapFilters), {}, {
|
|
27
|
+
const addFilterToMap = function(newFilter) {
|
|
28
|
+
this.mapFilters = {
|
|
29
|
+
...this.mapFilters,
|
|
58
30
|
[newFilter.idFilter]: newFilter
|
|
59
|
-
}
|
|
31
|
+
};
|
|
60
32
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const addGroupToMap = function (newGroup) {
|
|
69
|
-
this.mapGroups = _objectSpread(_objectSpread({}, this.mapGroups), {}, {
|
|
70
|
-
[newGroup.idGroup]: _objectSpread({}, newGroup)
|
|
71
|
-
});
|
|
33
|
+
const addGroupToMap = function(newGroup) {
|
|
34
|
+
this.mapGroups = {
|
|
35
|
+
...this.mapGroups,
|
|
36
|
+
[newGroup.idGroup]: {
|
|
37
|
+
...newGroup
|
|
38
|
+
}
|
|
39
|
+
};
|
|
72
40
|
};
|
|
73
|
-
const addFilterToItem = function
|
|
41
|
+
const addFilterToItem = function(item, newFilter) {
|
|
74
42
|
item.children.push({
|
|
75
43
|
id: newFilter.idFilter,
|
|
76
44
|
element: newFilter,
|
|
77
45
|
children: []
|
|
78
46
|
});
|
|
79
47
|
};
|
|
80
|
-
const addFilterToMainItem = function
|
|
48
|
+
const addFilterToMainItem = function(items, newFilter) {
|
|
81
49
|
items.push({
|
|
82
50
|
id: newFilter.idFilter,
|
|
83
51
|
element: newFilter,
|
|
84
52
|
children: []
|
|
85
53
|
});
|
|
86
54
|
};
|
|
87
|
-
const findInChilds = function
|
|
88
|
-
const found = childs.find(
|
|
89
|
-
let {
|
|
90
|
-
id
|
|
91
|
-
} = _ref;
|
|
92
|
-
return id === filterId;
|
|
93
|
-
});
|
|
94
|
-
|
|
55
|
+
const findInChilds = function(childs, filterId) {
|
|
56
|
+
const found = childs.find(({ id }) => id === filterId);
|
|
95
57
|
if (!found) {
|
|
96
58
|
let findInChild;
|
|
97
|
-
childs.forEach(item => {
|
|
98
|
-
if (!findInChild)
|
|
59
|
+
childs.forEach((item) => {
|
|
60
|
+
if (!findInChild)
|
|
61
|
+
findInChild = findInChilds(item.children, filterId);
|
|
99
62
|
});
|
|
100
|
-
if (findInChild)
|
|
63
|
+
if (findInChild)
|
|
64
|
+
return findInChild;
|
|
101
65
|
}
|
|
102
|
-
|
|
103
66
|
return found;
|
|
104
67
|
};
|
|
105
|
-
const findItemFilterById = function
|
|
68
|
+
const findItemFilterById = function(filterId) {
|
|
106
69
|
return findInChilds(this.items, filterId);
|
|
107
70
|
};
|
|
108
|
-
const findParentWithFilterId = function
|
|
109
|
-
const found = childs.find(
|
|
110
|
-
let {
|
|
111
|
-
id
|
|
112
|
-
} = _ref2;
|
|
113
|
-
return id === filterId;
|
|
114
|
-
});
|
|
115
|
-
|
|
71
|
+
const findParentWithFilterId = function(childs, filterId) {
|
|
72
|
+
const found = childs.find(({ id }) => id === filterId);
|
|
116
73
|
if (!found) {
|
|
117
74
|
let findInChild;
|
|
118
|
-
childs.forEach(item => {
|
|
119
|
-
if (!findInChild)
|
|
75
|
+
childs.forEach((item) => {
|
|
76
|
+
if (!findInChild)
|
|
77
|
+
findInChild = findParentWithFilterId(item.children, filterId);
|
|
120
78
|
});
|
|
121
|
-
if (findInChild)
|
|
79
|
+
if (findInChild)
|
|
80
|
+
return findInChild;
|
|
122
81
|
}
|
|
123
|
-
|
|
124
82
|
return childs;
|
|
125
83
|
};
|
|
126
|
-
const findParentFilterById = function
|
|
84
|
+
const findParentFilterById = function(filterId) {
|
|
127
85
|
return findParentWithFilterId(this.items, filterId);
|
|
128
86
|
};
|
|
129
|
-
const filterInChildren = function
|
|
87
|
+
const filterInChildren = function(childs, filterId, mainId) {
|
|
130
88
|
if (childs.children) {
|
|
131
|
-
childs.children = childs.children.filter(
|
|
132
|
-
|
|
133
|
-
id
|
|
134
|
-
} = _ref3;
|
|
135
|
-
return id !== filterId;
|
|
136
|
-
});
|
|
137
|
-
childs.children = childs.children.forEach(item => filterInChildren(item.children, filterId));
|
|
89
|
+
childs.children = childs.children.filter(({ id }) => id !== filterId);
|
|
90
|
+
childs.children = childs.children.forEach((item) => filterInChildren(item.children, filterId));
|
|
138
91
|
return childs;
|
|
139
|
-
}
|
|
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
|
-
|
|
92
|
+
}
|
|
93
|
+
if (childs.length > 1)
|
|
94
|
+
childs = childs.filter(({ id }) => id !== filterId);
|
|
149
95
|
if (childs.length === 0 && mainId) {
|
|
150
96
|
const emptyFilter = createNewFilter.call(this, mainId);
|
|
151
97
|
addFilterToMainItem.call(this, childs, emptyFilter);
|
|
152
98
|
}
|
|
153
|
-
|
|
154
|
-
childs.forEach(item => item.children = filterInChildren(item.children, filterId));
|
|
99
|
+
childs.forEach((item) => item.children = filterInChildren(item.children, filterId));
|
|
155
100
|
return childs;
|
|
156
101
|
};
|
|
157
|
-
const removeFilterItem = function
|
|
102
|
+
const removeFilterItem = function(filterId) {
|
|
158
103
|
this.items = filterInChildren(this.items, filterId, this.main);
|
|
159
104
|
};
|
|
160
|
-
const addGroupFilterToItem = function
|
|
105
|
+
const addGroupFilterToItem = function(idGroup, idFilter, newGroup) {
|
|
161
106
|
const child = findItemFilterById.call(this, idFilter);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (copy.element.type ===
|
|
107
|
+
const copy = {
|
|
108
|
+
...child
|
|
109
|
+
};
|
|
110
|
+
if (copy.element.type === "group") {
|
|
166
111
|
copy.element.parentIdGroup = newGroup.idGroup;
|
|
167
112
|
} else {
|
|
168
113
|
copy.element.idGroup = newGroup.idGroup;
|
|
169
114
|
}
|
|
170
|
-
|
|
171
115
|
child.id = newGroup.idGroup;
|
|
172
116
|
child.element = newGroup;
|
|
173
117
|
child.children = [copy];
|
|
174
118
|
};
|
|
175
|
-
const unGroupFilterToItem = function
|
|
119
|
+
const unGroupFilterToItem = function(idGroup) {
|
|
176
120
|
const group = findItemFilterById.call(this, idGroup);
|
|
177
|
-
|
|
178
121
|
if (group.element.parentIdGroup === this.main) {
|
|
179
|
-
const index = this.items.map(item => item.id).indexOf(idGroup);
|
|
122
|
+
const index = this.items.map((item) => item.id).indexOf(idGroup);
|
|
180
123
|
const tmp = [];
|
|
181
124
|
tmp.splice.apply(this.items, [index, 1].concat(group.children));
|
|
182
|
-
this.items.forEach(item => {
|
|
183
|
-
if (item.element.type ===
|
|
125
|
+
this.items.forEach((item) => {
|
|
126
|
+
if (item.element.type === "group") {
|
|
184
127
|
item.element.parentIdGroup = this.main;
|
|
185
128
|
} else {
|
|
186
129
|
item.element.idGroup = this.main;
|
|
@@ -188,11 +131,11 @@ const unGroupFilterToItem = function (idGroup) {
|
|
|
188
131
|
});
|
|
189
132
|
} else {
|
|
190
133
|
const parent = findItemFilterById.call(this, group.element.parentIdGroup);
|
|
191
|
-
const index = parent.children.map(item => item.id).indexOf(idGroup);
|
|
134
|
+
const index = parent.children.map((item) => item.id).indexOf(idGroup);
|
|
192
135
|
const tmp = [];
|
|
193
136
|
tmp.splice.apply(parent.children, [index, 1].concat(group.children));
|
|
194
|
-
parent.children.forEach(item => {
|
|
195
|
-
if (item.element.type ===
|
|
137
|
+
parent.children.forEach((item) => {
|
|
138
|
+
if (item.element.type === "group") {
|
|
196
139
|
item.element.parentIdGroup = parent.id;
|
|
197
140
|
} else {
|
|
198
141
|
item.element.idGroup = parent.id;
|
|
@@ -200,55 +143,75 @@ const unGroupFilterToItem = function (idGroup) {
|
|
|
200
143
|
});
|
|
201
144
|
}
|
|
202
145
|
};
|
|
203
|
-
const changeGroupOperator = function
|
|
146
|
+
const changeGroupOperator = function(idGroup, value) {
|
|
204
147
|
const group = findItemFilterById.call(this, idGroup);
|
|
205
|
-
|
|
206
148
|
if (idGroup !== this.main) {
|
|
207
149
|
group.element.condition = value;
|
|
208
150
|
}
|
|
209
151
|
};
|
|
210
|
-
const changeFilterItem = function
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
onFieldChange,
|
|
220
|
-
onOperatorChange,
|
|
221
|
-
onValueChange
|
|
222
|
-
}
|
|
223
|
-
} = _ref5;
|
|
152
|
+
const changeFilterItem = function({
|
|
153
|
+
idFilter,
|
|
154
|
+
field,
|
|
155
|
+
value,
|
|
156
|
+
operator,
|
|
157
|
+
additionalInfo,
|
|
158
|
+
target,
|
|
159
|
+
fieldsSharedActions: { onFieldChange, onOperatorChange, onValueChange }
|
|
160
|
+
}) {
|
|
224
161
|
const child = findItemFilterById.call(this, idFilter);
|
|
225
|
-
if (field || field ===
|
|
226
|
-
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)
|
|
162
|
+
if (field || field === "" || typeof field === "boolean")
|
|
163
|
+
child.element.field = field;
|
|
164
|
+
if (operator)
|
|
165
|
+
child.element.operator = operator;
|
|
166
|
+
if (value || value === "" || typeof value === "boolean")
|
|
167
|
+
child.element.value = value;
|
|
168
|
+
if (additionalInfo)
|
|
169
|
+
child.element.additionalInfo = additionalInfo;
|
|
170
|
+
if (target === "field") {
|
|
171
|
+
onFieldChange.forEach(({ action }) => {
|
|
172
|
+
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)
|
|
173
|
+
child.element.field = null;
|
|
174
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)
|
|
175
|
+
child.element.operator = null;
|
|
176
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)
|
|
177
|
+
child.element.value = null;
|
|
236
178
|
});
|
|
237
|
-
} else if (target ===
|
|
238
|
-
onOperatorChange.forEach(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
179
|
+
} else if (target === "operator") {
|
|
180
|
+
onOperatorChange.forEach(({ action }) => {
|
|
181
|
+
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)
|
|
182
|
+
child.element.field = null;
|
|
183
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)
|
|
184
|
+
child.element.operator = null;
|
|
185
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)
|
|
186
|
+
child.element.value = null;
|
|
243
187
|
});
|
|
244
|
-
} else if (target ===
|
|
245
|
-
onValueChange.forEach(
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
188
|
+
} else if (target === "value") {
|
|
189
|
+
onValueChange.forEach(({ action }) => {
|
|
190
|
+
if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)
|
|
191
|
+
child.element.field = null;
|
|
192
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)
|
|
193
|
+
child.element.operator = null;
|
|
194
|
+
else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)
|
|
195
|
+
child.element.value = null;
|
|
250
196
|
});
|
|
251
197
|
}
|
|
252
198
|
};
|
|
253
|
-
|
|
254
|
-
|
|
199
|
+
export {
|
|
200
|
+
addFilterToItem,
|
|
201
|
+
addFilterToMainItem,
|
|
202
|
+
addFilterToMap,
|
|
203
|
+
addGroupFilterToItem,
|
|
204
|
+
addGroupToMap,
|
|
205
|
+
changeFilterItem,
|
|
206
|
+
changeGroupOperator,
|
|
207
|
+
createNewFilter,
|
|
208
|
+
createNewGroup,
|
|
209
|
+
filterInChildren,
|
|
210
|
+
findInChilds,
|
|
211
|
+
findItemFilterById,
|
|
212
|
+
findParentFilterById,
|
|
213
|
+
findParentWithFilterId,
|
|
214
|
+
removeFilterItem,
|
|
215
|
+
unGroupFilterToItem
|
|
216
|
+
};
|
|
217
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/helpers/actions.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport {\n QB_DRAG_TYPES,\n QB_GROUP_CONDITION_TYPES,\n QB_FIELD_SHARED_ACTIONS,\n} from './types';\n\n/**\n * this is injected. instance of QBStore\n *\n * @param {*} idGroup: UUID\n * @param idGroup\n */\nexport const createNewFilter = function(idGroup) {\n const idFilter = `filter_${new Date().getTime()}_${Math.random()\n .toString(36)\n .substring(7)}`;\n return {\n idGroup,\n field: '',\n condition: '',\n value: '',\n idFilter,\n type: QB_DRAG_TYPES.FILTER,\n };\n};\n\n/**\n * this is injected. instance of QBStore\n *\n * @param {*} parentIdGroup: UUID\n * @param parentIdGroup\n */\nexport const createNewGroup = function(parentIdGroup) {\n const idGroup = `group_${new Date().getTime()}_${Math.random()\n .toString(36)\n .substring(7)}`;\n return {\n parentIdGroup,\n idGroup,\n condition: QB_GROUP_CONDITION_TYPES.AND,\n type: QB_DRAG_TYPES.GROUP,\n };\n};\n\n/**\n * this is injected. instance of QBStore\n *\n * @param {*} newFilter\n */\nexport const addFilterToMap = function(newFilter) {\n this.mapFilters = {\n ...this.mapFilters,\n [newFilter.idFilter]: newFilter,\n };\n};\n\n/**\n * this is injected. instance of QBStore\n *\n * @param {*} newFilter\n * @param newGroup\n */\nexport const addGroupToMap = function(newGroup) {\n this.mapGroups = {\n ...this.mapGroups,\n [newGroup.idGroup]: {\n ...newGroup,\n },\n };\n};\n\nexport const addFilterToItem = function(item, newFilter) {\n item.children.push({\n id: newFilter.idFilter,\n element: newFilter,\n children: [],\n });\n};\n\nexport const addFilterToMainItem = function(items, newFilter) {\n items.push({\n id: newFilter.idFilter,\n element: newFilter,\n children: [],\n });\n};\n\nexport const findInChilds = function(childs, filterId) {\n const found = childs.find(({ id }) => id === filterId);\n if (!found) {\n let findInChild;\n childs.forEach(item => {\n if (!findInChild) findInChild = findInChilds(item.children, filterId);\n });\n if (findInChild) return findInChild;\n }\n return found;\n};\nexport const findItemFilterById = function(filterId) {\n return findInChilds(this.items, filterId);\n};\n\nexport const findParentWithFilterId = function(childs, filterId) {\n const found = childs.find(({ id }) => id === filterId);\n if (!found) {\n let findInChild;\n childs.forEach(item => {\n if (!findInChild)\n findInChild = findParentWithFilterId(item.children, filterId);\n });\n if (findInChild) return findInChild;\n }\n return childs;\n};\nexport const findParentFilterById = function(filterId) {\n return findParentWithFilterId(this.items, filterId);\n};\n\nexport const filterInChildren = function(childs, filterId, mainId) {\n if (childs.children) {\n childs.children = childs.children.filter(({ id }) => id !== filterId);\n childs.children = childs.children.forEach(item =>\n filterInChildren(item.children, filterId),\n );\n return childs;\n }\n // main\n if (childs.length > 1) childs = childs.filter(({ id }) => id !== filterId); // https://jira.elliemae.io/browse/PUI-1252\n if (childs.length === 0 && mainId) {\n const emptyFilter = createNewFilter.call(this, mainId);\n addFilterToMainItem.call(this, childs, emptyFilter);\n }\n childs.forEach(\n item => (item.children = filterInChildren(item.children, filterId)),\n );\n return childs;\n};\nexport const removeFilterItem = function(filterId) {\n this.items = filterInChildren(this.items, filterId, this.main);\n};\n\nexport const addGroupFilterToItem = function(idGroup, idFilter, newGroup) {\n const child = findItemFilterById.call(this, idFilter);\n const copy = {\n ...child,\n };\n if (copy.element.type === 'group') {\n copy.element.parentIdGroup = newGroup.idGroup;\n } else {\n copy.element.idGroup = newGroup.idGroup;\n }\n child.id = newGroup.idGroup;\n child.element = newGroup;\n child.children = [copy];\n};\n\nexport const unGroupFilterToItem = function(idGroup) {\n const group = findItemFilterById.call(this, idGroup);\n if (group.element.parentIdGroup === this.main) {\n const index = this.items.map(item => item.id).indexOf(idGroup);\n const tmp = [];\n tmp.splice.apply(this.items, [index, 1].concat(group.children));\n this.items.forEach(item => {\n if (item.element.type === 'group') {\n item.element.parentIdGroup = this.main;\n } else {\n item.element.idGroup = this.main;\n }\n });\n } else {\n const parent = findItemFilterById.call(this, group.element.parentIdGroup);\n const index = parent.children.map(item => item.id).indexOf(idGroup);\n const tmp = [];\n tmp.splice.apply(parent.children, [index, 1].concat(group.children));\n parent.children.forEach(item => {\n if (item.element.type === 'group') {\n item.element.parentIdGroup = parent.id;\n } else {\n item.element.idGroup = parent.id;\n }\n });\n }\n};\n\nexport const changeGroupOperator = function(idGroup, value) {\n const group = findItemFilterById.call(this, idGroup);\n if (idGroup !== this.main) {\n group.element.condition = value;\n }\n};\n\nexport const changeFilterItem = function({\n idFilter,\n field,\n value,\n operator,\n additionalInfo,\n target,\n fieldsSharedActions: { onFieldChange, onOperatorChange, onValueChange },\n}) {\n const child = findItemFilterById.call(this, idFilter);\n if (field || field === '' || typeof field === 'boolean')\n child.element.field = field;\n if (operator) child.element.operator = operator;\n if (value || value === '' || typeof value === 'boolean')\n child.element.value = value;\n if (additionalInfo) child.element.additionalInfo = additionalInfo;\n\n // shared fields actions\n if (target === 'field') {\n onFieldChange.forEach(({ action }) => {\n if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)\n child.element.field = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)\n child.element.operator = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)\n child.element.value = null;\n });\n } else if (target === 'operator') {\n onOperatorChange.forEach(({ action }) => {\n if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)\n child.element.field = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)\n child.element.operator = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)\n child.element.value = null;\n });\n } else if (target === 'value') {\n onValueChange.forEach(({ action }) => {\n if (action === QB_FIELD_SHARED_ACTIONS.RESET_FIELD)\n child.element.field = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_OPERATOR)\n child.element.operator = null;\n else if (action === QB_FIELD_SHARED_ACTIONS.RESET_VALUE)\n child.element.value = null;\n });\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAAA;AAAA;AAAA;AAAA;AAYO,MAAM,kBAAkB,SAAS,SAAS;AAC/C,QAAM,WAAW,UAAU,IAAI,OAAO,aAAa,KAAK,SACrD,SAAS,IACT,UAAU;AACb,SAAO;AAAA,IACL;AAAA,IACA,OAAO;AAAA,IACP,WAAW;AAAA,IACX,OAAO;AAAA,IACP;AAAA,IACA,MAAM,cA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wBAAwB;AACrC,cAAM,QAAQ,QAAQ;AAAA,eACf,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,WAAW;AAAA,eAClB,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,QAAQ;AAAA;AAAA,aAEjB,WAAW,YAAY;AAChC,qBAAiB,QAAQ,CAAC,EAAE,aAAa;AACvC,UAAI,WAAW,wBAAwB;AACrC,cAAM,QAAQ,QAAQ;AAAA,eACf,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,WAAW;AAAA,eAClB,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,QAAQ;AAAA;AAAA,aAEjB,WAAW,SAAS;AAC7B,kBAAc,QAAQ,CAAC,EAAE,aAAa;AACpC,UAAI,WAAW,wBAAwB;AACrC,cAAM,QAAQ,QAAQ;AAAA,eACf,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,WAAW;AAAA,eAClB,WAAW,wBAAwB;AAC1C,cAAM,QAAQ,QAAQ;AAAA;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
const DELAY_CLOSE = 0.1;
|
|
2
3
|
const DELAY_OPEN = 0.1;
|
|
3
4
|
const TOOLBAR_ANIMATION_DURATION = 50;
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
export {
|
|
6
|
+
DELAY_CLOSE,
|
|
7
|
+
DELAY_OPEN,
|
|
8
|
+
TOOLBAR_ANIMATION_DURATION
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/helpers/constants.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const DELAY_CLOSE = 0.1;\nexport const DELAY_OPEN = 0.1;\nexport const TOOLBAR_ANIMATION_DURATION = 50;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,6BAA6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,32 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { get } from "lodash";
|
|
3
|
+
import * as operators from "@elliemae/ds-utilities/operators";
|
|
4
|
+
import { QB_GROUP_CONDITION_TYPES } from "./types";
|
|
5
|
+
const resolveCondition = (condition, state, resolveBy = QB_GROUP_CONDITION_TYPES.AND) => {
|
|
6
|
+
if (condition.length === 0 || !condition)
|
|
7
|
+
return true;
|
|
16
8
|
if (resolveBy) {
|
|
17
|
-
return condition.every(rule => {
|
|
9
|
+
return condition.every((rule) => {
|
|
18
10
|
const {
|
|
19
11
|
source: sourceRule,
|
|
20
12
|
operator: operatorRule,
|
|
21
13
|
value: valueRule
|
|
22
14
|
} = rule;
|
|
23
|
-
if (typeof operatorRule === "function")
|
|
15
|
+
if (typeof operatorRule === "function")
|
|
16
|
+
return operatorRule(get(state, sourceRule), valueRule);
|
|
24
17
|
return operators[operatorRule](get(state, sourceRule), valueRule);
|
|
25
18
|
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return condition.some(rule => {
|
|
19
|
+
}
|
|
20
|
+
return condition.some((rule) => {
|
|
30
21
|
const {
|
|
31
22
|
source: sourceRule,
|
|
32
23
|
operator: operatorRule,
|
|
@@ -35,26 +26,15 @@ const resolveCondition = function (condition, state) {
|
|
|
35
26
|
return operators[operatorRule](state[sourceRule], valueRule);
|
|
36
27
|
});
|
|
37
28
|
};
|
|
38
|
-
|
|
39
29
|
const resolveDependencies = (state, fields) => {
|
|
40
|
-
const fieldsToRender = fields.reduce((result,
|
|
41
|
-
|
|
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
|
-
});
|
|
30
|
+
const fieldsToRender = fields.reduce((result, { target, component, condition, resolveBy, validation, handleWidth }) => {
|
|
31
|
+
if (resolveCondition(condition, state, resolveBy))
|
|
32
|
+
result.push({ target, component, validation, handleWidth });
|
|
55
33
|
return result;
|
|
56
34
|
}, []);
|
|
57
35
|
return fieldsToRender;
|
|
58
36
|
};
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
export {
|
|
38
|
+
resolveDependencies
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=dependencies.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/helpers/dependencies.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { get } from 'lodash';\nimport * as operators from '@elliemae/ds-utilities/operators';\nimport { QB_GROUP_CONDITION_TYPES } from './types';\n\nconst resolveCondition = (\n condition,\n state,\n resolveBy = QB_GROUP_CONDITION_TYPES.AND,\n) => {\n if (condition.length === 0 || !condition) return true;\n // resolve by AND: all the conditions must be true\n if (resolveBy) {\n return condition.every((rule) => {\n const {\n source: sourceRule,\n operator: operatorRule,\n value: valueRule,\n } = rule;\n if (typeof operatorRule === \"function\") return operatorRule(get(state, sourceRule), valueRule);\n return operators[operatorRule](get(state, sourceRule), valueRule);\n });\n }\n // resolve by OR: at least one condition must be true\n return condition.some((rule) => {\n const {\n source: sourceRule,\n operator: operatorRule,\n value: valueRule,\n } = rule;\n return operators[operatorRule](state[sourceRule], valueRule);\n });\n};\n\nexport const resolveDependencies = (state, fields) => {\n const fieldsToRender = fields.reduce(\n (result, { target, component, condition, resolveBy, validation, handleWidth }) => {\n if (resolveCondition(condition, state, resolveBy))\n result.push({ target, component, validation, handleWidth });\n return result;\n },\n [],\n );\n return fieldsToRender;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,mBAAmB,CACvB,WACA,OACA,YAAY,yBAAyB,QAClC;AACH,MAAI,UAAU,WAAW,KAAK,CAAC;AAAW,WAAO;AAEjD,MAAI,WAAW;AACb,WAAO,UAAU,MAAM,CAAC,SAAS;AAC/B,YAAM;AAAA,QACJ,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,OAAO;AAAA,UACL;AACJ,UAAI,OAAO,iBAAiB;AAAY,eAAO,aAAa,IAAI,OAAO,aAAa;AACpF,aAAO,UAAU,cAAc,IAAI,OAAO,aAAa;AAAA;AAAA;AAI3D,SAAO,UAAU,KAAK,CAAC,SAAS;AAC9B,UAAM;AAAA,MACJ,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,OAAO;AAAA,QACL;AACJ,WAAO,UAAU,cAAc,MAAM,aAAa;AAAA;AAAA;AAI/C,MAAM,sBAAsB,CAAC,OAAO,WAAW;AACpD,QAAM,iBAAiB,OAAO,OAC5B,CAAC,QAAQ,EAAE,QAAQ,WAAW,WAAW,WAAW,YAAY,kBAAkB;AAChF,QAAI,iBAAiB,WAAW,OAAO;AACrC,aAAO,KAAK,EAAE,QAAQ,WAAW,YAAY;AAC/C,WAAO;AAAA,KAET;AAEF,SAAO;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|