From a5a85e79cbcf054c9533ec95679a1bc747d52c41 Mon Sep 17 00:00:00 2001 From: Eduard Carreras Date: Fri, 13 Dec 2024 14:00:11 +0100 Subject: [PATCH 01/10] feat(group): add height (#160) --- src/Group.ts | 17 +++++++++++++++++ src/spec/Group.spec.ts | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/src/Group.ts b/src/Group.ts index c792454..7dc9045 100644 --- a/src/Group.ts +++ b/src/Group.ts @@ -10,12 +10,29 @@ class Group extends Spinner { this._icon = value; } + _height: number | undefined; + get height(): number | undefined { + return this._height; + } + + set height(value: number | undefined) { + this._height = value; + } + constructor(props: any) { super(props); if (props) { if (props.icon) { this._icon = props.icon; } + if (props.height) { + try { + this._height = parseInt(props.height); + } catch (e) { + console.log("Error parsing height"); + this._height = undefined; + } + } } } } diff --git a/src/spec/Group.spec.ts b/src/spec/Group.spec.ts index 91133cc..1f4f074 100644 --- a/src/spec/Group.spec.ts +++ b/src/spec/Group.spec.ts @@ -58,5 +58,14 @@ describe("A Group", () => { const widget = widgetFactory.createWidget("group", props); expect(widget.loading).toBe(true); }); + it("should allow to set height", () => { + const widgetFactory = new WidgetFactory(); + const props = { + string: "A group", + height: 100, + }; + const widget = widgetFactory.createWidget("group", props); + expect(widget.height).toBe(100); + }); }); }); From e4ab1e5342594d9a751ae9ad2872373aceb12701 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 13 Dec 2024 13:01:03 +0000 Subject: [PATCH 02/10] chore(release): 2.26.0 [skip ci] # [2.26.0](https://github.com/gisce/ooui/compare/v2.25.0...v2.26.0) (2024-12-13) ### Features * **group:** add height ([#160](https://github.com/gisce/ooui/issues/160)) ([a5a85e7](https://github.com/gisce/ooui/commit/a5a85e79cbcf054c9533ec95679a1bc747d52c41)) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index eae5336..589f45a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/ooui", - "version": "2.25.0", + "version": "2.26.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/ooui", - "version": "2.25.0", + "version": "2.26.0", "dependencies": { "@gisce/conscheck": "1.0.9", "html-entities": "^2.3.3", diff --git a/package.json b/package.json index f32f698..2bacc50 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/ooui", - "version": "2.25.0", + "version": "2.26.0", "engines": { "node": "20.5.0" }, From 67cd6304cf6a4497605dc03a9970e4662c505e7d Mon Sep 17 00:00:00 2001 From: Eduard Carrerars Date: Tue, 24 Dec 2024 11:12:20 +0100 Subject: [PATCH 03/10] feat(colorPicker): add new component colorPicker --- src/ColorPicker.ts | 9 +++++ src/WidgetFactory.ts | 4 +++ src/index.ts | 2 ++ src/spec/ColorPicker.spec.ts | 64 ++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 src/ColorPicker.ts create mode 100644 src/spec/ColorPicker.spec.ts diff --git a/src/ColorPicker.ts b/src/ColorPicker.ts new file mode 100644 index 0000000..d89c8ee --- /dev/null +++ b/src/ColorPicker.ts @@ -0,0 +1,9 @@ +import Char from "./Char"; + +class ColorPicker extends Char { + get showText(): boolean { + return this.parsedWidgetProps.show_text ?? true; + } +} + +export default ColorPicker; diff --git a/src/WidgetFactory.ts b/src/WidgetFactory.ts index 73bfa34..24cd53f 100644 --- a/src/WidgetFactory.ts +++ b/src/WidgetFactory.ts @@ -42,6 +42,7 @@ import JSONField from "./JSONField"; import Email from "./Email"; import Spinner from "./Spinner"; import Carousel from "./Carousel"; +import ColorPicker from "./ColorPicker"; class WidgetFactory { /** @@ -188,6 +189,9 @@ class WidgetFactory { case "carousel": this._widgetClass = Carousel; break; + case "colorPicker": + this._widgetClass = ColorPicker; + break; default: break; } diff --git a/src/index.ts b/src/index.ts index 23041e0..b7f1927 100644 --- a/src/index.ts +++ b/src/index.ts @@ -54,6 +54,7 @@ import Comments from "./Comments"; import Email from "./Email"; import Spinner from "./Spinner"; import Carousel from "./Carousel"; +import ColorPicker from "./ColorPicker"; import { Graph, @@ -144,4 +145,5 @@ export { Email, Spinner, Carousel, + ColorPicker, }; diff --git a/src/spec/ColorPicker.spec.ts b/src/spec/ColorPicker.spec.ts new file mode 100644 index 0000000..3d3c37c --- /dev/null +++ b/src/spec/ColorPicker.spec.ts @@ -0,0 +1,64 @@ +// src/spec/ColorPicker.spec.ts +import WidgetFactory from "../WidgetFactory"; +import ColorPicker from "../ColorPicker"; +import { it, expect, describe } from "vitest"; + +describe("A ColorPicker", () => { + it("should have an id corresponding to field name", () => { + const widgetFactory = new WidgetFactory(); + const props = { + name: "colorPicker", + }; + + const widget = widgetFactory.createWidget("colorPicker", props); + expect(widget).toBeInstanceOf(ColorPicker); + }); + + it("should properly set label", () => { + const widgetFactory = new WidgetFactory(); + const props = { + name: "colorPicker", + string: "colorPicker caption", + }; + const widget = widgetFactory.createWidget("colorPicker", props); + + expect(widget.label).toBe("colorPicker caption"); + }); + + describe("showText property", () => { + it("should show text by default", () => { + const widgetFactory = new WidgetFactory(); + const props = { + name: "colorPicker", + }; + const widget = widgetFactory.createWidget("colorPicker", props); + + expect(widget.showText).toBe(true); + }); + it("should show text when widget_props.showText is true", () => { + const widgetFactory = new WidgetFactory(); + const props = { + name: "colorPicker", + widget_props: { + show_text: true, + }, + }; + const widget = widgetFactory.createWidget("colorPicker", props); + + expect(widget.showText).toBe(true); + }); + + it("should not show text when widget_props.showText is false", () => { + const widgetFactory = new WidgetFactory(); + const props = { + name: "colorPicker", + widget_props: { + show_text: false, + }, + }; + const widget = widgetFactory.createWidget("colorPicker", props); + + expect(widget.showText).toBe(false); + }); + }); +}); From cf45374487acfd692b13debd4731968ce2d28803 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 24 Dec 2024 14:42:04 +0000 Subject: [PATCH 04/10] chore(release): 2.27.0 [skip ci] # [2.27.0](https://github.com/gisce/ooui/compare/v2.26.0...v2.27.0) (2024-12-24) ### Features * **colorPicker:** add new component colorPicker ([67cd630](https://github.com/gisce/ooui/commit/67cd6304cf6a4497605dc03a9970e4662c505e7d)) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 589f45a..52fd89f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/ooui", - "version": "2.26.0", + "version": "2.27.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/ooui", - "version": "2.26.0", + "version": "2.27.0", "dependencies": { "@gisce/conscheck": "1.0.9", "html-entities": "^2.3.3", diff --git a/package.json b/package.json index 2bacc50..a604b80 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/ooui", - "version": "2.26.0", + "version": "2.27.0", "engines": { "node": "20.5.0" }, From 05ff98c562a4792e3805dcc9a950fd2cee3ee1a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Sat, 11 Jan 2025 11:25:02 +0100 Subject: [PATCH 05/10] chore: bump sync-pr version [skip ci] --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 0d0a3a4..dd26df9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -106,7 +106,7 @@ jobs: target: ['alpha', 'v2-develop'] steps: - name: Call create sync pr - uses: gisce/create-sync-pr@v0.0.6 + uses: gisce/create-sync-pr@v0.0.25 with: repository: ${{ env.LIBRARY_NAME }} targetBranch: ${{ matrix.target }} From 8ff865b8b59ae41c192d5d05fe1586c1aea58434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Mon, 20 Jan 2025 14:45:21 +0100 Subject: [PATCH 06/10] chore: adjust sync-pr version [skip ci] --- .github/workflows/release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index dd26df9..2eb6aec 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -106,7 +106,7 @@ jobs: target: ['alpha', 'v2-develop'] steps: - name: Call create sync pr - uses: gisce/create-sync-pr@v0.0.25 + uses: gisce/create-sync-pr@v0.0.26 with: repository: ${{ env.LIBRARY_NAME }} targetBranch: ${{ matrix.target }} From 17d7e86621e8d05bbae543a1024cb07e51ae90ce Mon Sep 17 00:00:00 2001 From: Eduard Carrerars Date: Wed, 22 Jan 2025 14:02:59 +0100 Subject: [PATCH 07/10] fix(attributeParse): evaluateFieldComparison use index 0 of many2one values --- src/helpers/attributeParser.ts | 3 +++ src/spec/attributeParser.spec.ts | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/helpers/attributeParser.ts b/src/helpers/attributeParser.ts index 691171a..69a257a 100644 --- a/src/helpers/attributeParser.ts +++ b/src/helpers/attributeParser.ts @@ -76,6 +76,9 @@ const evaluateFieldComparison = ({ expectedValue, fields = {}, }: FieldComparisonParams & { fields: any }): FieldComparisonResult => { + if (fields?.fieldName?.type !== "many2one" && valueInObject) { + valueInObject = valueInObject[0]; + } const result: FieldComparisonResult = { modifiedValueInObject: valueInObject, modifiedExpectedValue: null, diff --git a/src/spec/attributeParser.spec.ts b/src/spec/attributeParser.spec.ts index b6dc075..b9833d0 100644 --- a/src/spec/attributeParser.spec.ts +++ b/src/spec/attributeParser.spec.ts @@ -479,6 +479,20 @@ describe("An Attribute Parser", () => { }); expect(evaluatedAttrs.invisible).toBeTruthy(); }); + it("should properly use the id of a many2one value", () => { + const tagAttributes = { + json_attrs: + '{"invisible":{"condition":"AND","rules":[{"field":"autoconsum_id","operator":"=","value":10}]}}', + }; + const values = { autoconsum_id: [10, "Autoconsum"] }; + const evaluatedAttrs = evaluateAttributes({ + tagAttributes, + values, + fields, + fallbackMode: false, + }); + expect(evaluatedAttrs.invisible).toBeTruthy(); + }); it("should properly parse a many2one attribute with undefined value", () => { const tagAttributes = { json_attrs: From f65429e6d385daa72761e6fe3ef21722bb7c6e40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Wed, 22 Jan 2025 14:33:41 +0100 Subject: [PATCH 08/10] fix: change approach in order to pass all tests --- src/helpers/attributeParser.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/helpers/attributeParser.ts b/src/helpers/attributeParser.ts index 69a257a..daf396f 100644 --- a/src/helpers/attributeParser.ts +++ b/src/helpers/attributeParser.ts @@ -76,9 +76,6 @@ const evaluateFieldComparison = ({ expectedValue, fields = {}, }: FieldComparisonParams & { fields: any }): FieldComparisonResult => { - if (fields?.fieldName?.type !== "many2one" && valueInObject) { - valueInObject = valueInObject[0]; - } const result: FieldComparisonResult = { modifiedValueInObject: valueInObject, modifiedExpectedValue: null, @@ -117,14 +114,18 @@ const evaluateFieldComparison = ({ ) { result.modifiedExpectedValue = undefined; } else { - result.modifiedValueInObject = - result.modifiedValueInObject === undefined - ? false - : result.modifiedValueInObject; - result.modifiedValueInObject = - result.modifiedValueInObject === null - ? false - : result.modifiedValueInObject; + if (result.modifiedValueInObject === undefined) { + result.modifiedValueInObject = false; + } else if ( + Array.isArray(result.modifiedValueInObject) && + result.modifiedValueInObject[0] !== undefined + ) { + result.modifiedValueInObject = result.modifiedValueInObject[0]; + } + + if (result.modifiedValueInObject === null) { + result.modifiedValueInObject = false; + } } if ( From f38c39b1833837bf4fffc74f562d4e6244d29d52 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 22 Jan 2025 17:52:37 +0000 Subject: [PATCH 09/10] chore(release): 2.27.1 [skip ci] ## [2.27.1](https://github.com/gisce/ooui/compare/v2.27.0...v2.27.1) (2025-01-22) ### Bug Fixes * **attributeParse:** evaluateFieldComparison use index 0 of many2one values ([17d7e86](https://github.com/gisce/ooui/commit/17d7e86621e8d05bbae543a1024cb07e51ae90ce)) * change approach in order to pass all tests ([f65429e](https://github.com/gisce/ooui/commit/f65429e6d385daa72761e6fe3ef21722bb7c6e40)) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52fd89f..5558251 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gisce/ooui", - "version": "2.27.0", + "version": "2.27.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gisce/ooui", - "version": "2.27.0", + "version": "2.27.1", "dependencies": { "@gisce/conscheck": "1.0.9", "html-entities": "^2.3.3", diff --git a/package.json b/package.json index a604b80..a1fcfba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gisce/ooui", - "version": "2.27.0", + "version": "2.27.1", "engines": { "node": "20.5.0" }, From cf537cc44ba1448a5a6aa916fc78231bea17eb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Gu=CC=88ell=20Segarra?= Date: Thu, 23 Jan 2025 15:53:44 +0100 Subject: [PATCH 10/10] fix: if json_attrs present don't use attrs parsing https://github.com/gisce/webclient/issues/1690 --- src/helpers/attributeParser.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/helpers/attributeParser.ts b/src/helpers/attributeParser.ts index daf396f..cbd072d 100644 --- a/src/helpers/attributeParser.ts +++ b/src/helpers/attributeParser.ts @@ -278,15 +278,6 @@ const evaluateAttributes = ({ fallbackMode?: boolean; }) => { let finalTagAttributes = {}; - let oldTagAttributes = {}; - if (tagAttributes.attrs) { - oldTagAttributes = parseAttributes({ - attrs: tagAttributes.attrs, - values, - fields, - widgetType, - }); - } if (tagAttributes.json_attrs) { try { @@ -298,13 +289,23 @@ const evaluateAttributes = ({ }); } catch (error) { if (fallbackMode && tagAttributes.attrs) { - finalTagAttributes = oldTagAttributes; + finalTagAttributes = parseAttributes({ + attrs: tagAttributes.attrs, + values, + fields, + widgetType, + }); } else { throw error; } } } else if (tagAttributes.attrs) { - finalTagAttributes = oldTagAttributes; + finalTagAttributes = parseAttributes({ + attrs: tagAttributes.attrs, + values, + fields, + widgetType, + }); } return {