@gisce/ooui 2.28.0 → 2.29.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.28.0",
3
+ "version": "2.29.0-alpha.1",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
package/src/Field.ts CHANGED
@@ -147,6 +147,11 @@ class Field extends Widget {
147
147
  super.readOnly = value;
148
148
  }
149
149
 
150
+ _raw_props: any;
151
+ get raw_props(): any {
152
+ return this._raw_props;
153
+ }
154
+
150
155
  constructor(props: any) {
151
156
  super(props);
152
157
 
@@ -154,6 +159,7 @@ class Field extends Widget {
154
159
  this._activated = true;
155
160
 
156
161
  if (props) {
162
+ this._raw_props = props;
157
163
  if (props.name) {
158
164
  this._id = props.name;
159
165
  }
package/src/Tag.ts CHANGED
@@ -7,6 +7,10 @@ class Tag extends Selection {
7
7
  get colors(): any | "auto" {
8
8
  return this._parsedWidgetProps.colors || {};
9
9
  }
10
+
11
+ get colorField(): string | null {
12
+ return this._parsedWidgetProps?.colorField || null;
13
+ }
10
14
  }
11
15
 
12
16
  export default Tag;
@@ -278,15 +278,6 @@ const evaluateAttributes = ({
278
278
  fallbackMode?: boolean;
279
279
  }) => {
280
280
  let finalTagAttributes = {};
281
- let oldTagAttributes = {};
282
- if (tagAttributes.attrs) {
283
- oldTagAttributes = parseAttributes({
284
- attrs: tagAttributes.attrs,
285
- values,
286
- fields,
287
- widgetType,
288
- });
289
- }
290
281
 
291
282
  if (tagAttributes.json_attrs) {
292
283
  try {
@@ -298,13 +289,23 @@ const evaluateAttributes = ({
298
289
  });
299
290
  } catch (error) {
300
291
  if (fallbackMode && tagAttributes.attrs) {
301
- finalTagAttributes = oldTagAttributes;
292
+ finalTagAttributes = parseAttributes({
293
+ attrs: tagAttributes.attrs,
294
+ values,
295
+ fields,
296
+ widgetType,
297
+ });
302
298
  } else {
303
299
  throw error;
304
300
  }
305
301
  }
306
302
  } else if (tagAttributes.attrs) {
307
- finalTagAttributes = oldTagAttributes;
303
+ finalTagAttributes = parseAttributes({
304
+ attrs: tagAttributes.attrs,
305
+ values,
306
+ fields,
307
+ widgetType,
308
+ });
308
309
  }
309
310
 
310
311
  return {
@@ -44,4 +44,26 @@ describe("A Tag widget", () => {
44
44
  expect(widget.colors).toStrictEqual("auto");
45
45
  });
46
46
  });
47
+
48
+ describe("colorField property", () => {
49
+ it("should have default colorField to null", () => {
50
+ const widgetFactory = new WidgetFactory();
51
+ const props = {
52
+ name: "status",
53
+ };
54
+ const widget = widgetFactory.createWidget("tag", props);
55
+
56
+ expect(widget.colorField).toBeNull();
57
+ });
58
+ it("should parse colorField property", () => {
59
+ const widgetFactory = new WidgetFactory();
60
+ const props = {
61
+ name: "status",
62
+ widget_props: '{"colorField": "color"}',
63
+ };
64
+ const widget = widgetFactory.createWidget("tag", props);
65
+
66
+ expect(widget.colorField).toBe("color");
67
+ });
68
+ });
47
69
  });