-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Use displayState in oh-input #1350
Conversation
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
Job #388: Bundle Size — 10.7MB (~+0.01%).Changed metrics (2/10)
|
Thanks, but there's no context provided so not sure what to make of this. What's the rationale here? It could be perfectly reasonable to think an input widget would rather be "fed" the actual state and not its displayState even if it exists (you could have another widget to show the displayState alongside the input). |
@ghys Thank you for your feedback. I mostly use oh-input for entering things like meter readings. An example: I have an official, non smart, meter for my solar production. I need to manually read the value and communicate the reading to the authorities to receive subsidies for my solar production. Every 1000kWh produced will give me a certificate. You are right this is a breaking change. But I still have to find a use case where displayState would not give me a better value than the raw state. Using a formatting on a free input beyond simple number formatting always will be tricky. E.g. I also use it to do text input to be able to name playlists. Such text does not have any formatting. A simple map transformation on a free form input value is also not likely, as it would be difficult to interpret all possible input values. I can investigate making this a parameter, but in my view, this adds complexity and the current proposed solution just makes things consistent across the UI. I expected to get the displayState when someting is shown, even in an input field. |
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@ghys I made displayState optional. While this would break backward compatibility, I would argue the inverse parameter 'forceRawState' would actually make more sense and be more consistent overall. But I am OK with the this solution as well. |
You can always find some. Imagine a scenario where you have a Number item for a scene and a state description mapping like 1=Morning, 2=Evening, 3=Night etc. In such a case for a state of "1" the displayState would be "Morning". |
I know and understand, but wouldn’t a list item be a much more appropriate input widget in this case? I personally only use an input type widget where there is no better way possible. After all, it is not the most practical widget type on a touch display. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a better example:
(regular DateTime item with a state description pattern: %1$tA, %1$td.%1$tm.%1$tY
)
Default standalone widget:
value: oh-input-card
config:
type: date
footer: =items.TestDate
sendButton: true
In this case the displayState
would probably not be parsed if set as the <input type="date">
value (depends on the pattern), whereas the state
always will.
Below are some wording suggestions for the new option.
bundles/org.openhab.ui/web/src/assets/definitions/widgets/system/input.js
Outdated
Show resolved
Hide resolved
bundles/org.openhab.ui/web/src/components/widgets/system/oh-input.vue
Outdated
Show resolved
Hide resolved
Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
@ghys Thank you for the example and the feedback. I have made the suggested adjustments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Signed-off-by: Mark Herwege mark.herwege@telenet.be