@gisce/ooui 2.26.0 → 2.27.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/dist/ColorPicker.d.ts +6 -0
- package/dist/ColorPicker.d.ts.map +1 -0
- package/dist/WidgetFactory.d.ts.map +1 -1
- package/dist/helpers/attributeParser.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/ooui.es.js +133 -124
- package/dist/ooui.es.js.map +1 -1
- package/package.json +1 -1
- package/src/ColorPicker.ts +9 -0
- package/src/WidgetFactory.ts +4 -0
- package/src/helpers/attributeParser.ts +12 -8
- package/src/index.ts +2 -0
- package/src/spec/ColorPicker.spec.ts +64 -0
- package/src/spec/attributeParser.spec.ts +14 -0
package/package.json
CHANGED
package/src/WidgetFactory.ts
CHANGED
|
@@ -42,6 +42,7 @@ import JSONField from "./JSONField";
|
|
|
42
42
|
import Email from "./Email";
|
|
43
43
|
import Spinner from "./Spinner";
|
|
44
44
|
import Carousel from "./Carousel";
|
|
45
|
+
import ColorPicker from "./ColorPicker";
|
|
45
46
|
|
|
46
47
|
class WidgetFactory {
|
|
47
48
|
/**
|
|
@@ -188,6 +189,9 @@ class WidgetFactory {
|
|
|
188
189
|
case "carousel":
|
|
189
190
|
this._widgetClass = Carousel;
|
|
190
191
|
break;
|
|
192
|
+
case "colorPicker":
|
|
193
|
+
this._widgetClass = ColorPicker;
|
|
194
|
+
break;
|
|
191
195
|
default:
|
|
192
196
|
break;
|
|
193
197
|
}
|
|
@@ -114,14 +114,18 @@ const evaluateFieldComparison = ({
|
|
|
114
114
|
) {
|
|
115
115
|
result.modifiedExpectedValue = undefined;
|
|
116
116
|
} else {
|
|
117
|
-
result.modifiedValueInObject
|
|
118
|
-
result.modifiedValueInObject
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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 (
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ import Comments from "./Comments";
|
|
|
54
54
|
import Email from "./Email";
|
|
55
55
|
import Spinner from "./Spinner";
|
|
56
56
|
import Carousel from "./Carousel";
|
|
57
|
+
import ColorPicker from "./ColorPicker";
|
|
57
58
|
|
|
58
59
|
import {
|
|
59
60
|
Graph,
|
|
@@ -144,4 +145,5 @@ export {
|
|
|
144
145
|
Email,
|
|
145
146
|
Spinner,
|
|
146
147
|
Carousel,
|
|
148
|
+
ColorPicker,
|
|
147
149
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/spec/ColorPicker.spec.ts
|
|
2
|
+
import WidgetFactory from "../WidgetFactory";
|
|
3
|
+
import ColorPicker from "../ColorPicker";
|
|
4
|
+
import { it, expect, describe } from "vitest";
|
|
5
|
+
|
|
6
|
+
describe("A ColorPicker", () => {
|
|
7
|
+
it("should have an id corresponding to field name", () => {
|
|
8
|
+
const widgetFactory = new WidgetFactory();
|
|
9
|
+
const props = {
|
|
10
|
+
name: "colorPicker",
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
14
|
+
expect(widget).toBeInstanceOf(ColorPicker);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should properly set label", () => {
|
|
18
|
+
const widgetFactory = new WidgetFactory();
|
|
19
|
+
const props = {
|
|
20
|
+
name: "colorPicker",
|
|
21
|
+
string: "colorPicker caption",
|
|
22
|
+
};
|
|
23
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
24
|
+
|
|
25
|
+
expect(widget.label).toBe("colorPicker caption");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("showText property", () => {
|
|
29
|
+
it("should show text by default", () => {
|
|
30
|
+
const widgetFactory = new WidgetFactory();
|
|
31
|
+
const props = {
|
|
32
|
+
name: "colorPicker",
|
|
33
|
+
};
|
|
34
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
35
|
+
|
|
36
|
+
expect(widget.showText).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
it("should show text when widget_props.showText is true", () => {
|
|
39
|
+
const widgetFactory = new WidgetFactory();
|
|
40
|
+
const props = {
|
|
41
|
+
name: "colorPicker",
|
|
42
|
+
widget_props: {
|
|
43
|
+
show_text: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
47
|
+
|
|
48
|
+
expect(widget.showText).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should not show text when widget_props.showText is false", () => {
|
|
52
|
+
const widgetFactory = new WidgetFactory();
|
|
53
|
+
const props = {
|
|
54
|
+
name: "colorPicker",
|
|
55
|
+
widget_props: {
|
|
56
|
+
show_text: false,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
const widget = widgetFactory.createWidget("colorPicker", props);
|
|
60
|
+
|
|
61
|
+
expect(widget.showText).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
@@ -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:
|