@evoke-platform/ui-components 1.0.0-dev.172 → 1.0.0-dev.173
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.
@@ -6,6 +6,7 @@ export declare type CriteriaInputProps = {
|
|
6
6
|
properties: ObjectProperty[];
|
7
7
|
setCriteria: Function;
|
8
8
|
criteria?: Record<string, any>;
|
9
|
+
originalCriteria?: Record<string, any>;
|
9
10
|
enablePresetValues?: boolean;
|
10
11
|
presetValues?: PresetValue[];
|
11
12
|
dynamicContentInput?: {
|
@@ -25,8 +25,6 @@ const ALL_OPERATORS = [
|
|
25
25
|
{ name: 'notNull', label: 'is not null' },
|
26
26
|
{ name: 'in', label: 'in' },
|
27
27
|
{ name: 'notIn', label: 'not in' },
|
28
|
-
{ name: 'between', label: 'between' },
|
29
|
-
{ name: 'notBetween', label: 'not between' },
|
30
28
|
];
|
31
29
|
const CustomRuleGroup = (props) => {
|
32
30
|
const rg = Object.assign(Object.assign({}, props), useRuleGroup(props));
|
@@ -136,11 +134,12 @@ export const valueEditor = (props) => {
|
|
136
134
|
return ValueEditor(props);
|
137
135
|
};
|
138
136
|
const CriteriaBuilder = (props) => {
|
139
|
-
const { properties, criteria, setCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, hideBorder, presetGroupLabel, } = props;
|
137
|
+
const { properties, criteria, setCriteria, originalCriteria, enablePresetValues, presetValues, operators, dynamicContentInput, disabled, hideBorder, presetGroupLabel, } = props;
|
140
138
|
const [query, setQuery] = useState(undefined);
|
141
139
|
useEffect(() => {
|
142
|
-
if (criteria) {
|
143
|
-
const
|
140
|
+
if (criteria || originalCriteria) {
|
141
|
+
const criteriaToParse = criteria || originalCriteria || {};
|
142
|
+
const updatedQuery = parseMongoDB(criteriaToParse);
|
144
143
|
setQuery(Object.assign(Object.assign({}, updatedQuery), { rules: updatedQuery.rules.map((rule) => {
|
145
144
|
var _a, _b;
|
146
145
|
const propertyType = (_a = properties.find((property) => property.id === rule.field)) === null || _a === void 0 ? void 0 : _a.type;
|
@@ -154,7 +153,7 @@ const CriteriaBuilder = (props) => {
|
|
154
153
|
else {
|
155
154
|
setQuery({ combinator: 'and', rules: [] });
|
156
155
|
}
|
157
|
-
}, []);
|
156
|
+
}, [originalCriteria]);
|
158
157
|
const handleQueryChange = (q) => {
|
159
158
|
setQuery(q);
|
160
159
|
const newCriteria = JSON.parse(formatQuery(q, 'mongodb'));
|
@@ -202,7 +201,7 @@ const CriteriaBuilder = (props) => {
|
|
202
201
|
},
|
203
202
|
} },
|
204
203
|
React.createElement(QueryBuilderMaterial, null,
|
205
|
-
React.createElement(QueryBuilder, { query: !criteria ? { combinator: 'and', rules: [] } : query, fields: fields, onQueryChange: (q) => {
|
204
|
+
React.createElement(QueryBuilder, { query: !criteria && !originalCriteria ? { combinator: 'and', rules: [] } : query, fields: fields, onQueryChange: (q) => {
|
206
205
|
handleQueryChange(q);
|
207
206
|
}, showCombinatorsBetweenRules: true, listsAsArrays: true, disabled: disabled, addRuleToNewGroups: true, controlElements: {
|
208
207
|
combinatorSelector: customCombinator,
|