Skip to content

Commit 788d3f1

Browse files
authored
Readme changes. Small changes to last PR. Update "vite" (#1258)
* nit * lf * Upd vite * lock * es2017 * . * es2020 * nit comment
1 parent 15b15f2 commit 788d3f1

File tree

21 files changed

+63
-42
lines changed

21 files changed

+63
-42
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
- Fix incorrect using of "$not" as top-level operator in output to MongoDb (PR #1254) (issue #1250)
1010
- Fix using incorrect date format in output to MongoDb (PR #1254)
1111
- Added date/datetime functions: `TODAY`, `START_OF_TODAY`, `RELATIVE_DATE`, `TRUNCATE_DATETIME` (PR #1256) (issue #1237)
12-
- Fix datetime functions: fix `NOW`, `RELATIVE_DATETIME` for MongoDb (PR #1256)
12+
- Fixed datetime functions `NOW`, `RELATIVE_DATETIME` for MongoDb (PR #1256)
1313
- Fixed comparing of dates with `==` and `!=` in JsonLogic by using new ops `date==`, `date!=`, `datetime==`, `datetime!=`. Added `fixJsonLogicDateCompareOp` to `config.setings` (false by default) (PR #1256)
14+
- Now `Utils.JsonLogicUtils.addRequiredJsonLogicOperations(jl)` can be used for instance of `json-logic-js` to add custom operators (PR #1256)
1415
- 6.6.14
1516
- Fixed import from JsonLogic when like op is used inside group with some group op (PR #1225) (issue #1221)
1617
- Support React 19 (PR #1229) (issue #1205)

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,14 @@ Wrapping in `div.query-builder-container` is necessary for correct drag-n-drop s
514514
#### `jsonLogicFormat`
515515
`Utils.Export.jsonLogicFormat (immutableValue, config) -> {logic, data, errors}`
516516
Convert query value to [JsonLogic](http://jsonlogic.com) format.
517-
If there are no `errors`, `logic` will be rule object and `data` will contain all used fields with null values ("template" data).
517+
If there are no `errors`, `logic` will be rule object and `data` will contain all used fields with null values ("template" data).
518+
**Note:** You can set `config.settings.fixJsonLogicDateCompareOp = true` to fix the comparison of dates with `==` and `!=` in JsonLogic by using custom ops `date==`, `date!=`, `datetime==`, `datetime!=`.
519+
**Note:** If you import custom version of `json-logic-js` please add [custom operators](/packages/core/modules/utils/jsonLogicUtils.js#L12) with:
520+
```js
521+
import JL from "json-logic-js";
522+
Utils.JsonLogicUtils.addRequiredJsonLogicOperations(JL);
523+
// console.log(JL.apply({ "now": [] }));
524+
```
518525

519526
### Import utils
520527

packages/antd/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "esnext",
55
"jsx": "preserve",
66
"lib": [
7-
"es2016",
7+
"es2020",
88
"dom",
99
"dom.iterable"
1010
],

packages/bootstrap/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "esnext",
55
"jsx": "preserve",
66
"lib": [
7-
"es2016",
7+
"es2020",
88
"dom",
99
"dom.iterable"
1010
],

packages/core/modules/export/jsonLogic.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ const formatGroup = (item, config, meta, _not = false, isRoot = false, parentFie
101101
let groupOperator = properties.get("operator");
102102
let groupOperatorDef = groupOperator && getOperatorConfig(config, groupOperator, field) || null;
103103
const formattedValue = formatItemValue(config, properties, meta, groupOperator, parentField);
104+
// Tip: for demo app isGroup0 is true for "Results" and "Cars" with group op in "some", "all", "none"
105+
// If isGroup0 is false, we should use "reduce"
104106
const isGroup0 = isRuleGroup && (!groupOperator || groupOperatorDef?.cardinality == 0);
105107
const isRuleGroupWithChildren = isRuleGroup && children?.size > 0;
106108
const isRuleGroupWithoutChildren = isRuleGroup && !children?.size;
@@ -171,17 +173,19 @@ const formatGroup = (item, config, meta, _not = false, isRoot = false, parentFie
171173
});
172174
}
173175

174-
let resultQuery = {};
176+
let filterQuery = {};
175177
if (preserveSingleRuleGroup)
176-
resultQuery[conj] = list.toList().toJS();
178+
filterQuery[conj] = list.toList().toJS();
177179
else
178-
resultQuery = list.first();
179-
180+
filterQuery = list.first();
181+
180182
// reverse filter
181183
if (filterNot) {
182-
resultQuery = { "!": resultQuery };
184+
filterQuery = { "!": filterQuery };
183185
}
184186

187+
let resultQuery = filterQuery;
188+
185189
// rule_group (issue #246)
186190
if (isRuleGroupArray) {
187191
const formattedField = formatField(meta, config, field, parentField);
@@ -193,7 +197,7 @@ const formatGroup = (item, config, meta, _not = false, isRoot = false, parentFie
193197
: {
194198
"filter": [
195199
formattedField,
196-
resultQuery
200+
filterQuery
197201
]
198202
};
199203
reduceQuery = {
@@ -206,7 +210,7 @@ const formatGroup = (item, config, meta, _not = false, isRoot = false, parentFie
206210
}
207211
const formattedLhs = reduceQuery ?? formattedField;
208212
const optionsMap = new Map({
209-
having: resultQuery,
213+
having: filterQuery,
210214
reduce: reduceQuery,
211215
groupField: field,
212216
groupFieldFormatted: formattedField,
@@ -222,7 +226,7 @@ const formatGroup = (item, config, meta, _not = false, isRoot = false, parentFie
222226
resultQuery = {
223227
[op]: [
224228
formattedField,
225-
resultQuery
229+
filterQuery
226230
]
227231
};
228232
} else {

packages/core/modules/export/spel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ const formatRule = (item, config, meta, parentField = null) => {
316316
const {value: formattedField, valueSrc: _fieldSrc, valueType: fieldType} = formatLhs(meta, config, field, fieldSrc, parentField) ?? {};
317317
if (formattedField === undefined)
318318
return undefined;
319-
319+
320320
// format expression
321321
let res = formatExpression(
322-
meta, config, properties, formattedField, formattedValue, realOp, valueSrc, valueType, isRev
322+
meta, config, properties, formattedField, formattedValue, realOp, valueSrc, valueType ?? fieldType, isRev
323323
);
324324
return res;
325325
};

packages/core/modules/import/jsonLogic.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const buildConv = (config) => {
9797
template = opConfig.jsonLogic(jlFieldMarker, opKey, jlArgsMarker, opConfig, new Immutable.Map({
9898
having: jlHavingMarker,
9999
groupField: jlRawFieldMarker,
100+
// reduce: undefined,
101+
// groupFieldFormatted: undefined,
100102
}));
101103
} catch(e) {
102104
console.warn(`Error while running JsonLogic template for op ${opKey}`, e);

packages/core/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"target": "es6",
44
"module": "esnext",
55
"lib": [
6-
"es2015"
6+
"es2020"
77
],
88
"allowJs": true,
99
"outDir": "ts_out",

packages/examples/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "esnext",
55
"jsx": "preserve",
66
"lib": [
7-
"es2016",
7+
"es2020",
88
"dom",
99
"dom.iterable"
1010
],

packages/fluent/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"module": "esnext",
55
"jsx": "preserve",
66
"lib": [
7-
"es2016",
7+
"es2020",
88
"dom",
99
"dom.iterable"
1010
],

0 commit comments

Comments
 (0)