Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blockly] Add context block typing & Extend Qty block var type support #1948

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export default function defineOHBlocks_Scripts (f7, isGraalJs, scripts) {
['triggered event', 'event']
]),
'contextInfo')
this.contextInfo = this.getFieldValue('contextInfo')
this.setInputsInline(true)
this.setOutput(true, null)
this.setColour(0)
Expand All @@ -192,6 +193,19 @@ export default function defineOHBlocks_Scripts (f7, isGraalJs, scripts) {
return TIP[contextData]
})
this.setHelpUrl('https://www.openhab.org/docs/configuration/blockly/rules-blockly-run-and-process.html#retrieve-rule-context-information')
},
onchange: function (event) {
let contextInfo = this.getFieldValue('contextInfo')
if (this.contextInfo !== contextInfo) {
this.contextInfo = contextInfo
if (contextInfo === 'itemName') {
this.setOutput(true, 'oh_item')
console.log('type = oh_item')
} else {
this.setOutput(true, 'String')
console.log('type = State String')
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ function generateQuantityCode (block, inputName) {
code = `Quantity(${input})`
break
case 'oh_itemtype':
case '': // vars are expected to contain an item object
code = `${input}.quantityState`
case '': // vars are expected to contain an item object or the state itself
code = `Quantity(${input})`
break
case 'oh_item':
code = `items.getItem(${input}).quantityState`
Expand Down