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

[MainUI] Extend default standalone/item/cell widget selection #1558

Merged
merged 4 commits into from
Dec 11, 2022

Conversation

flo-mic
Copy link
Contributor

@flo-mic flo-mic commented Dec 2, 2022

This PR extends the default widget selection for standalone, cell and item default widgets to provide better default widgets on DateTime and Number items as requested here #399 and here #1494

Basically the PR adds the following default widgets:

  • oh-input for datetime on items of type DateTime (standalone, list)
  • oh-input for numbers on items of type Number (standalone, list)
  • oh-stepper on Number:Temperature items as well as for items with the semantic class Control or SetPoint with semantic property Temperature (standalone, list)
  • oh-slider on Number:* items with the semantic class Control or SetPoint and a semantic property from ColorTemperature, Level, SoundVolume (standalone, list, cell)
  • oh-toggle on Number* items with the semantic class Control or SetPoint and a semantic property from Light, Power, Energy (standalone, list, cell)
  • oh-toggle on Number* items with the semantic class Switch (standalone, list, cell)

Signed-off-by: Florian Michel <florianmichel@hotmail.de>
Signed-off-by: Florian Michel <florianmichel@hotmail.de>
@flo-mic flo-mic requested a review from a team as a code owner December 2, 2022 13:16
@ghys
Copy link
Member

ghys commented Dec 4, 2022

This looks great, I'll have a look shortly so we can eventually have it in the next release 👍

@relativeci
Copy link

relativeci bot commented Dec 10, 2022

Job #640: Bundle Size — 15.96MiB (~+0.01%).

44ac583(current) vs 3311fb2 main#639(baseline)

Metrics (no changes)
                 Current
Job #640
     Baseline
Job #639
Initial JS 1.73MiB 1.73MiB
Initial CSS 608.3KiB 608.3KiB
Cache Invalidation 83.71% 83.71%
Chunks 218 218
Assets 688 688
Modules 2007 2007
Duplicate Modules 108 108
Duplicate Code 1.8% 1.8%
Packages 133 133
Duplicate Packages 15 15
Total size by type (2 changes)
                 Current
Job #640
     Baseline
Job #639
CSS 856.34KiB 856.34KiB
Fonts 1.08MiB 1.08MiB
HTML 1.21KiB 1.21KiB
IMG 140.74KiB 140.74KiB
JS 9.03MiB (~+0.01%) 9.03MiB
Media 295.6KiB 295.6KiB
Other 4.59MiB (~-0.01%) 4.59MiB

View job #640 reportView main branch activity

@ghys
Copy link
Member

ghys commented Dec 10, 2022

Having second thoughts:

oh-input for datetime on items of type DateTime (standalone, list)
oh-input for numbers on items of type Number (standalone, list)

I think most DateTime and Number items are really statuses, even if they're not readonly (the default), and it would be wrong to display an input UI in those cases as well as have adverse side effects (like the state description's pattern being ignored).
I'd offer the input widget by default only if the item has a Control or Setpoint semantic class - the tags are easy to add.

oh-toggle on Number* items with the semantic class Control or SetPoint and a semantic property from Light, Power, Energy (standalone, list, cell)
oh-toggle on Number* items with the semantic class Switch (standalone, list, cell)

Not sure about the rationale for these two, especially the first one. Their state wouldn't be displayed at all because the toggle doesn't allow it. If their class is Switch then it could make sense to display a toggle in all cases (not only numbers but other types accepting OnOff commands too, like Color).

Signed-off-by: Yannick Schaus <github@schaus.net>
@ghys
Copy link
Member

ghys commented Dec 11, 2022

Ok so I modified it as follows:

Cards, list items

  • if the semantic class is Control or Setpoint AND the item is not read only

    • if the type is DateTime => input

      image

    • if the type is Number => input

      image

    • if the type is Number:Temperature OR the semantic property is Temperature => stepper

      image

    • if the semantic property is ColorTemperature, Level or SoundVolume => slider

      image

  • if the semantic class is Switch (whatever its type but the tag should only be applied to items compatible with OnOff commands) AND the item is not read only => toggle

    image

  • else, no changes, fallback to a label with an appropriate action or others depending on the type

    image

    image

Cells

  • if the semantic class is Control or Setpoint AND the item is not read only
    • if the type is Number:Temperature OR the semantic property is Temperature => knob
    • if the semantic property is ColorTemperature, Level or SoundVolume => slider
    • (nothing else because there are no input cells)
  • if the semantic class is Switch (whatever its type but the tag should only be applied to items compatible with OnOff commands) AND the item is not read only => toggle
  • else, no changes, fallback to a label cell with the appropriate action or others depending on the type

Signed-off-by: Yannick Schaus <github@schaus.net>
@ghys ghys added rebuild trigger a new Jenkins job enhancement New feature or request main ui Main UI and removed rebuild trigger a new Jenkins job labels Dec 11, 2022
@ghys ghys added this to the 3.4 milestone Dec 11, 2022
Copy link
Member

@ghys ghys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's satisfactory now, and (I hope) won't cause many regressions unless the model is wrong.

@ghys ghys merged commit 73d4935 into openhab:main Dec 11, 2022
@kaikreuzer kaikreuzer changed the title [MainUI] extend default standalone/item/cell widget selection [MainUI] Extend default standalone/item/cell widget selection Dec 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants