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
Rework itemMetadataWidget #945
Conversation
Job #21: Bundle Size — 10.88MB (~-0.01%). |
https://github.com/openhab/openhab-webui/blame/main/bundles/org.openhab.ui/web/src/components/item/metadata/item-metadata-widget.vue |
Ah ok, I actually thought it could be something like this, but seems I didn't stay on it enough. |
Ok, so I examined this further and I now know why skipped the idea this might be to override an action default value to "none": It simply doesn't work for me! 😮 When you select no action (empty option), whose resulting select option value is falsy, the config parameter gets fully deleted in configSheet, and thus in itemMetadataWidget's metadata.config. And with the parameter not being present in metadata.config, it can't be iterated over as key. Meaning: for me that line is actually never executed as intended. But this would mean that the fix never worked, which I can barely believe. So, where's my fault? 🤔 |
You're right it doesn't seem to work (anymore?).
Maybe it could be set in this case? |
I struggled to try and finally have a jest test for this, like this one: Turns out you have to mock the Vuex store, and the SSE connection API, but you still don't have a |
I think tests can be very helpful and are high level coding, but unfortunately setting them up and maintaining them can cost an awful lot of time 😃 I was also looking for a fix for this and now I'm struggling with YAML: { config: { action: null } } gets stringified to that: config:
? action while the other way round (with correct yaml) it works just fine 🤨 Edit: |
Signed-off-by: Hubert Nusser <hubsif@gmx.de>
ok, so enabling
And of course it would be nicer to be able to display a "no action" or "none" for the empty string. Best would be to have a consistent standard throughout the API and the UI for these things, so that all widgets could simply rely on the configuration components. But then, ... it works 😃 . And maybe someday there'll be time to beautify things like these. |
👍 The option is to modify the core to allow nulls in metadata config parameters, but I don't know if it makes sense/could lead to side effects.
¯\(ツ)/¯ Btw - I noticed a small bug when testing this, when you click on "Remove metadata", the dirty flag has to be cleared, because now you get the confirmation dialog... while the metadata is deleted in the background. But since it's not strictly related to this PR, it can be addressed separately. |
Hi Yannick,
With this commit I addressed issue #678. I did quite a lot more than I had to, so here some notes:
I completely removed following code:
I tried real hard to find out what you added this for, there surely must have been a reason - but couldn't.
If by
!this.metadata.config[key]
you meant "if that key does not exist": that doesn't make sense when iterating through the keys. If you meant "if the config value is falsy and the default truthy": I can't see how it makes sense to set the value to an empty string (or from the comment the originally desired 'null'). Perhaps you remember what it's for, if it's not just some weird leftover.With this removed, values like the slider scale, which defaults to true, can be set to false again. Also, values now can have a
0
, e.g. for the scaleSubsteps value.The second major change is to make the preview widget dynamically update.
I then wanted to address another issue, which is that default values get reset to default when you empty its input field. Try e.g. to set another value for "Highlight Color" for cells. It defaults to
blue
and whenever you delete the last character (b
), the value gets set toblue
again.At first I thought that comes from the many computed values. Later on I realized that this issue seems to lie in configSheet instead.
But while analyzing this, I discovered that with each keypress the many code for computed values is executed. As this seemed unnecesary, I reworked it - actually quite radically, I hope you like it.
Additionally, I streamlined the standard widget arrays and the ordered standard widget arrays into one.
personalWidgets
still gets computed, since like this it's updated automatically when loaded.And I removed the
viewMode
, since it actually never changes. ThecomponentSelectKey
also seemed redundant.