Skip to content

Commit

Permalink
fix uom block output type (#2036)
Browse files Browse the repository at this point in the history
fixes #2008

Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
  • Loading branch information
stefan-hoehn authored Sep 5, 2023
1 parent 06f220f commit db103db
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down

0 comments on commit db103db

Please sign in to comment.