[blockly] change event attributes, add return block#3376
[blockly] change event attributes, add return block#3376florian-h05 merged 2 commits intoopenhab:mainfrom
Conversation
#3495 Bundle Size — 11.38MiB (~+0.01%).5585292(current) vs f0117c8 main#3490(baseline) Warning Bundle contains 2 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
Bundle analysis report Branch stefan-hoehn:blockly_migrate_eve... Project dashboard Generated by RelativeCI Documentation Report issue |
|
When you add the docs, make sure to make it clear that return can only be used when the wrapper is enabled in the JS Scripting configs (MainUI -> Settings -> JS Scripting. |
|
Our idea was to make blockly automatically set the directive to enable the wrapper when return is used. |
|
you can actually see this in line 397 that creates "use wrapper" in the code. |
|
Is that something that can be done from a JS script? For example a rule template? I think I've found ways for my templates to work around that but knowing it's possible might prove helpful in the future. |
I haven't written docs for that yet, but the |
|
So I can enable the wrapper but not disable the wrapper? I'm not trying to argue about anything, just understand in case it's helpful to me in the rule templates and so I understand how it works in Blockly so I can help on the forum better. And don't you have actions and conditions backwards in your description. I thought the decision was to always enable it for Conditions and optionally enable it for Actions based on the add-on property. I could be remembering backwards, but that was what I thought. The reasoning was having the return statement in Conditions was worth keeping it always enabled, and doing so had minimal impact. |
|
Not sure if it helps. As soon as Blockly adds one of these blocks, it adds "'use wrapper'" to the top of the script that it generates. |
|
You can also disable it, there are three ways of using the wrapper:
The first two are equivalent.
I think you have to switch actions and conditions there. For actions, it is always enabled, since it has minimal to no impact, for conditions, there is the global add-on setting and the use wrapper directive to control the behaviour. |
Excellent! Thanks! |
bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js
Outdated
Show resolved
Hide resolved
bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js
Outdated
Show resolved
Hide resolved
bundles/org.openhab.ui/web/src/assets/definitions/blockly/blocks-scripts.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
Signed-off-by: Stefan Höhn <mail@stefanhoehn.com>
3902d38 to
5585292
Compare
Regression from openhab#3376. Signed-off-by: Florian Hotze <dev@florianhotze.com>
Regression from #3376. Also simplifies the generated code (the members of the event object are now JS strings). Signed-off-by: Florian Hotze <dev@florianhotze.com>
Depends on: openhab/openhab-addons#19443
The event object/attributes in script actions and conditions is now the same as in JSRule and Rule Builder.
Backwards compatibility will be retained for some time, though it is advised to adjust, which is done in this PR according to:
https://github.com/openhab/openhab-js/blob/51f164dc9f11a29e6223e24268848aa8f0be168f/src/rules/rules.js#L471
Additionally a new return block was added to the "Run & Process" category with return parameter.
which can implemented by using an inline blockly script that evaluates to true or false.