From 8acaa6e9f94f19a0a33c2ed40494477916478867 Mon Sep 17 00:00:00 2001 From: stefan-hoehn Date: Tue, 5 Sep 2023 20:49:51 +0200 Subject: [PATCH] fix uom block output type (#2036) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #2008 Signed-off-by: Stefan Höhn --- .../definitions/blockly/blocks-scripts.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js b/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js index 4929a5de58..66250fb186 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js @@ -225,6 +225,28 @@ export default function defineOHBlocks_Scripts (f7, isGraalJs, scripts) { this.updateShape() } }, + mutationToDom: function () { + let container = Blockly.utils.xml.createElement('mutation') + container.setAttribute('asType', this.asType) + container.setAttribute('contextInfo', this.contextInfo) + return container + }, + domToMutation: function (xmlElement) { + this.contextInfo = xmlElement.getAttribute('contextInfo') + if (this.contextInfo === 'itemName') { + this.setOutput(true, 'oh_item') + } else { + this.setOutput(true, 'String') + } + this.asType = xmlElement.getAttribute('asType') + if (this.asType === 'asNumber') { + this.setOutput(true, 'Number') + } else if (this.asType === 'asQuantity') { + this.setOutput(true, 'oh_quantity') + } else { + this.setOutput(true, 'String') + } + }, updateShape: function () { if (this.methodName === 'itemState' || this.methodName === 'oldItemState' || this.methodName === 'itemCommand') { if (!this.getInput('asTypeInput')) {