-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
[basicui] Use sitemap input hint #1787
Conversation
197008d
to
c5c66b9
Compare
Testing with following sitemap:
Shows at start of OH (using Chrome), no persisted data: |
Filling out a few fields: Notice the comma in the After entering 10 in the The unit is taken from the default, and then also set in the Quantity input number field. It cannot be overriden there. |
Entering a date in the Results in: A few notes on this: date, time and datetime will revert to text fields when the browser doesn't support this (very old browsers). The only supported text field date input format is |
I have tested this on Chrome and Firefox on Windows, and to a lesser extend on Edge. Here is an image on Firefox: And for Edge (with different browser locale settings): It also should look fine in dark theme and condensed mode. I did not test on mobile browsers so far (not sure how to easily do that when running from a development environment), but I do expect the controls will actually be more specific to the use. |
@lolodomo It is up to you how you want to proceed with this review. This PR already includes #1729, with all review adjustments from the PR. There is some extra refactoring in this one to properly accomodate support for the inputHint parameter, openhab/openhab-core#3418. |
This adds support for configuring the inputHint parameter of the Input sitemap element in the sitemap editor of MainUI. See openhab/openhab-core#3418 and the BasicUI implementation #1787. Also-by: Florian Hotze <[email protected]> Signed-off-by: Mark Herwege <[email protected]>
@mherwege : I let you rebase (the other PR is now merged) and then I will test and review this PR. |
ccd4d5f
to
6689d33
Compare
@lolodomo Rebase done. I struggled a bit as things had diverged a bit. |
@mherwege : can you please rebase it again, there is a conflict in _theming.scss. I will then start the tests and the review. |
5afac99
to
f33157f
Compare
@lolodomo Rebase done. |
@lolodomo In the review of the Android PR, a change in behaviour was made for dateTime type items.
I have not made a change to this PR (yet), but I am unsure if, and how, I can. 1: I need text input for datetime anyway to allows for browsers not supporting the HTML5 input types. |
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.
Partial review
...s/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/InputRenderer.java
Outdated
Show resolved
Hide resolved
...s/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/InputRenderer.java
Outdated
Show resolved
Hide resolved
...s/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/InputRenderer.java
Outdated
Show resolved
Hide resolved
} else if ("time".equals(inputHint)) { | ||
dataState = ((DateTimeType) state).format("%1$tT"); | ||
} else if ("datetime".equals(inputHint)) { | ||
dataState = ((DateTimeType) state).format("%1$tY-%1$tm-%1$tdT%1$tT"); |
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.
Why using a different format than when no hint is provided ?
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.
The HTML5 input types date, time and datetime-local expect a ISO formatted datetime string. This will not be visible to the user when these input types are used. If the inputHint is text (or none), not HTML5 input type will be used, only a plain text field. The pattern in that case removes the "T" separator.
In the Android app, we ultimately forced an input type when the itemType is DateTime, not leaving the option for a text input. For consistency, we could take this approach here as well.
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.
I have now forced a datetime inputHint for DateTime items, but still need to keep some of the code as older browsers may not support the input types and default to text.
...s/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/InputRenderer.java
Outdated
Show resolved
Hide resolved
Just because you removed the code that was providing this information. You have this information each time an item state is updated through the function |
First tests. For any kind of item, if I enter a value while the current state is NULL, the item state is updated in the server but "empty/NULL" values are restored in UI. For number with dimension, whatever input hint (unset, set to text or set to number), if I enter a number, I see the command correctly send, the item state updated in server but the value is restored to the previous value in UI. Edit: seems to work now ! Very strange. For number item without dimension with a state pattern set to For number item without dimension with a state pattern set to For date time item and input hint set to date, selecting a new date is correctly sent to the server but then the old date is restored. For date time item and input hint set to time, if I enter the hour, I see just after the hour disappearing and remains only 2 fields. More generally, all stuff with date time seems to not work at all in Firefox, I was not able to fill a proper date & time. |
I guess the biggest problem should be in function Edit: date seems to work better now, I am a little lost. Maybe the problem is when the initial item state is NULL. |
@lolodomo Not behind my computer at the moment, but for many of your tests, it looks like the SSE connection was not working properly. Values should be restored if the SSE connection does not send the final update. And it looks like that is what is happening. |
This is expected. The state pattern is not a unit, it could be anything. When inputHint is number, only number or number with dimension is allowed. For number with dimension, the unit is shown. Any state description beyond number formatting is ignored. I don’t see an easy way around this. State descriptions were meant for visualization, never for input patterns. |
But not when the servlet is initially created. |
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
Signed-off-by: Mark Herwege <[email protected]>
179cf66
to
cb248d8
Compare
As the relevant core PR openhab/openhab-core#3644 has now been merge, I also updated that one with the review feedback in this PR. It may be easier to check out that one instead. I didn't test yet, but I believe the issue with difference between UI config and file config impact would not appear there, as it is covered in core. |
Do you mean this PR should be closed in favor of #1923 ? |
So I let you close it. |
Replaced by #1923. |
This PR is a continuation of #1787, using the extra functionality provided by core if openhab/openhab-core#3644 gets merged in core. It would be an alternative to #1787 with the same functionality, but reduced complexity. Requires openhab/openhab-core#3644. --------- Signed-off-by: Mark Herwege <[email protected]>
This PR builds on #1729 and requires openhab/openhab-core#3418.
The PR will be rebased once the final version of #1729 has been merged. While it is feature complete from my perspective, testing and feedback are much appreciated.
This PR uses the sitemap Input widget's inputHint parameter to adjust the characteristics of the input field. The inputHint parameter will have the following impact:
number
: a QuantityType will be represented as a number field with a non-changeable unit field. Updates will be assumed to be in the unit of the old value.date
: a datepicker is provided. This datepicker uses the standard html input type=date parameter. Therefore behaviour will be browser specific. Older browsers may revert to a text field. Also the representation is dependent on system or browser (for Chrome) locale.time
: similarly a time picker is provided.datetime
: uses the html input type=datetime-local, provided a combined date and time picker, will also be browser dependent.The date and time pickers use standard html input type parameters. That restricts the formatting and will result in a browser dependent representation. This however, is the solution that can be achieved with least effort and least code. I also did not find good date/time pickers for Material Design Lite, that could easily be brought into the code.