Skip to content

Commit 6143c97

Browse files
authored
Fix export of not in some!group into JsonLogic (#484)
* Fix export of not in some!group into JsonLogic * chlog * repro app * Revert "repro app" This reverts commit 9dd3d9a.
1 parent cea08ed commit 6143c97

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
2-
- latest
2+
- 4.4.3
33
- babel: use "@babel/plugin-transform-runtime" to avoid globally defined regenerator runtime (PR #480)
4+
- Fix export of not in some!group into JsonLogic (issue #476) (PR #484)
45
- Fixed issue with default import/export in Vite build (PR #481)
56
- 4.4.2
67
- Added support of autocomplete for multiselect widget in MUI (PR #475)

modules/import/jsonLogic.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,22 @@ const convertOp = (op, vals, conv, config, not, meta, parentField = null) => {
539539
const parseRes = parseRule(op, arity, vals, parentField, conv, config, meta);
540540
if (!parseRes) return undefined;
541541
let {field, fieldConfig, opKey, args, having} = parseRes;
542-
543542
let opConfig = config.operators[opKey];
544-
const canRev = !(fieldConfig.type == "!group");
543+
544+
// Group component in array mode can show NOT checkbox, so do nothing in this case
545+
// Otherwise try to revert
546+
const showNot = fieldConfig.showNot !== undefined ? fieldConfig.showNot : config.settings.showNot;
547+
let canRev = true;
548+
if (fieldConfig.type == "!group" && fieldConfig.mode == "array" && showNot)
549+
canRev = false;
550+
551+
// Fix "some ! in"
552+
if (fieldConfig.type == "!group" && having && Object.keys(having)[0] == "!") {
553+
not = !not;
554+
having = having["!"];
555+
}
556+
557+
// Use reversed op
545558
if (not && canRev && opConfig.reversedOp) {
546559
not = false;
547560
opKey = opConfig.reversedOp;
@@ -573,7 +586,7 @@ const convertOp = (op, vals, conv, config, not, meta, parentField = null) => {
573586
}
574587
Object.assign(res.properties, {
575588
mode: fieldConfig.mode,
576-
not: not,
589+
not: (canRev ? false : not),
577590
operator: opKey,
578591
});
579592
if (fieldConfig.mode == "array") {
@@ -590,7 +603,7 @@ const convertOp = (op, vals, conv, config, not, meta, parentField = null) => {
590603
children1: {},
591604
properties: {
592605
conjunction: defaultGroupConjunction(config, fieldConfig),
593-
not: not,
606+
not: (canRev ? false : not),
594607
mode: fieldConfig.mode,
595608
field: field,
596609
operator: opKey,

0 commit comments

Comments
 (0)