@gisce/ooui 2.27.0 → 2.28.0-alpha.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/ooui",
3
- "version": "2.27.0",
3
+ "version": "2.28.0-alpha.1",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
@@ -114,14 +114,18 @@ const evaluateFieldComparison = ({
114
114
  ) {
115
115
  result.modifiedExpectedValue = undefined;
116
116
  } else {
117
- result.modifiedValueInObject =
118
- result.modifiedValueInObject === undefined
119
- ? false
120
- : result.modifiedValueInObject;
121
- result.modifiedValueInObject =
122
- result.modifiedValueInObject === null
123
- ? false
124
- : result.modifiedValueInObject;
117
+ if (result.modifiedValueInObject === undefined) {
118
+ result.modifiedValueInObject = false;
119
+ } else if (
120
+ Array.isArray(result.modifiedValueInObject) &&
121
+ result.modifiedValueInObject[0] !== undefined
122
+ ) {
123
+ result.modifiedValueInObject = result.modifiedValueInObject[0];
124
+ }
125
+
126
+ if (result.modifiedValueInObject === null) {
127
+ result.modifiedValueInObject = false;
128
+ }
125
129
  }
126
130
 
127
131
  if (
@@ -274,15 +278,6 @@ const evaluateAttributes = ({
274
278
  fallbackMode?: boolean;
275
279
  }) => {
276
280
  let finalTagAttributes = {};
277
- let oldTagAttributes = {};
278
- if (tagAttributes.attrs) {
279
- oldTagAttributes = parseAttributes({
280
- attrs: tagAttributes.attrs,
281
- values,
282
- fields,
283
- widgetType,
284
- });
285
- }
286
281
 
287
282
  if (tagAttributes.json_attrs) {
288
283
  try {
@@ -294,13 +289,23 @@ const evaluateAttributes = ({
294
289
  });
295
290
  } catch (error) {
296
291
  if (fallbackMode && tagAttributes.attrs) {
297
- finalTagAttributes = oldTagAttributes;
292
+ finalTagAttributes = parseAttributes({
293
+ attrs: tagAttributes.attrs,
294
+ values,
295
+ fields,
296
+ widgetType,
297
+ });
298
298
  } else {
299
299
  throw error;
300
300
  }
301
301
  }
302
302
  } else if (tagAttributes.attrs) {
303
- finalTagAttributes = oldTagAttributes;
303
+ finalTagAttributes = parseAttributes({
304
+ attrs: tagAttributes.attrs,
305
+ values,
306
+ fields,
307
+ widgetType,
308
+ });
304
309
  }
305
310
 
306
311
  return {
@@ -479,6 +479,20 @@ describe("An Attribute Parser", () => {
479
479
  });
480
480
  expect(evaluatedAttrs.invisible).toBeTruthy();
481
481
  });
482
+ it("should properly use the id of a many2one value", () => {
483
+ const tagAttributes = {
484
+ json_attrs:
485
+ '{"invisible":{"condition":"AND","rules":[{"field":"autoconsum_id","operator":"=","value":10}]}}',
486
+ };
487
+ const values = { autoconsum_id: [10, "Autoconsum"] };
488
+ const evaluatedAttrs = evaluateAttributes({
489
+ tagAttributes,
490
+ values,
491
+ fields,
492
+ fallbackMode: false,
493
+ });
494
+ expect(evaluatedAttrs.invisible).toBeTruthy();
495
+ });
482
496
  it("should properly parse a many2one attribute with undefined value", () => {
483
497
  const tagAttributes = {
484
498
  json_attrs: