From 8340e680642baf6540b06c761fc42abece44b644 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 3 May 2023 18:30:37 +0200 Subject: [PATCH 1/4] default-list-item: Only enable dynamic icons for some types by default Follow-up for #1849. Signed-off-by: Florian Hotze --- .../src/components/widgets/standard/list/default-list-item.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js b/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js index 538deec59c..95918291bf 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js +++ b/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js @@ -166,7 +166,9 @@ export default function itemDefaultListComponent (item, footer) { if (!component.config.item) component.config.item = item.name if (!component.config.title) component.config.title = item.label || item.name if (item.category && !component.config.icon) component.config.icon = item.category - if (item.category && component.config.iconUseState === undefined && !['Call', 'Image', 'Location'].includes(item.type)) component.config.iconUseState = true + // Only enable dynamic icon by default for Item types with good support for dynamic icons and "predictable" states + const discreteItemTypes = ['Contact', 'Dimmer', 'Rollershutter', 'Switch'] + if (item.category && component.config.iconUseState === undefined && (discreteItemTypes.includes(item.type) || (item.type === 'Groups' && discreteItemTypes.included(item.groupType)))) component.config.iconUseState = true if (item.label && footer && footer.contextLabelSource) { let text = itemContextLabel(item, footer) if (text) component.config.footer = text From 49a65304babefa2921613009d86d859698b2d3d0 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 3 May 2023 18:31:11 +0200 Subject: [PATCH 2/4] Update component docs Signed-off-by: Florian Hotze --- .../web/src/assets/definitions/widgets/plan/index.js | 2 +- .../web/src/assets/definitions/widgets/standard/cards.js | 2 +- .../web/src/assets/definitions/widgets/standard/listitems.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/plan/index.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/plan/index.js index 6a21b99b4f..d4515fe168 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/plan/index.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/plan/index.js @@ -34,7 +34,7 @@ export const OhPlanMarkerDefinition = () => new WidgetDefinition('oh-plan-marker ]) .paramGroup(pg('icon', 'Icon', 'You can customize the styles further with CSS attributes in the iconStyle parameter (in YAML only)'), [ pt('icon', 'Icon', 'Use oh:iconName (openHAB icon), f7:iconName (Framework7 icon), material:iconName (Material icon) or iconify:iconSet:iconName (Iconify icon, requires being online if not in cache)'), - pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only)').a(), + pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only)'), pn('iconSize', 'Icon Size', 'Size of the icon in pixels (40 by default)'), pn('iconWidth', 'Icon Width', 'Width of the icon in pixels (for openHAB icons only, 40 by default)').a(), pn('iconHeight', 'Icon Height', 'Height of the icon in pixels (for openHAB icons only, 40 by default)').a(), diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/cards.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/cards.js index 2577feec1c..4f5238c432 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/cards.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/cards.js @@ -28,7 +28,7 @@ export const OhLabelCardDefinition = () => new WidgetDefinition('oh-label-card', pt('icon', 'Icon', 'Use oh:iconName (openHAB icon), f7:iconName (Framework7 icon), material:iconName (Material icon) or iconify:iconSet:iconName (Iconify icon, requires being online if not in cache)'), pt('iconColor', 'Icon Color', 'Not applicable to openHAB icons').a(), pn('iconSize', 'Icon Size', 'Size of the icon in px').a(), - pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only)').a(), + pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only)'), pb('vertical', 'Vertical arrangement', 'Display label below icon') ]) .paramGroup(pg('trend', 'Trend Line', 'Show a trend line in the background'), TrendParameters()) diff --git a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/listitems.js b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/listitems.js index f8018236d7..5e3d434519 100644 --- a/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/listitems.js +++ b/bundles/org.openhab.ui/web/src/assets/definitions/widgets/standard/listitems.js @@ -11,7 +11,7 @@ export const ListItemParameters = () => [ pt('after', 'After', 'Text to display on the opposite side of the item (set either this or a badge)').a(), pt('icon', 'Icon', 'Use oh:iconName (openHAB icon), f7:iconName (Framework7 icon), material:iconName (Material icon) or iconify:iconSet:iconName (Iconify icon, requires being online if not in cache)'), pt('iconColor', 'Icon Color', 'Not applicable to openHAB icons').a(), - pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only)').a() + pb('iconUseState', 'Icon depends on state', 'Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only)') ] // OhListItem From 28948882a3498cb68c002148e5ead362b239907f Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Wed, 3 May 2023 18:32:49 +0200 Subject: [PATCH 3/4] Fix typos in code Signed-off-by: Florian Hotze --- .../src/components/widgets/standard/list/default-list-item.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js b/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js index 95918291bf..76225e20b6 100644 --- a/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js +++ b/bundles/org.openhab.ui/web/src/components/widgets/standard/list/default-list-item.js @@ -168,7 +168,7 @@ export default function itemDefaultListComponent (item, footer) { if (item.category && !component.config.icon) component.config.icon = item.category // Only enable dynamic icon by default for Item types with good support for dynamic icons and "predictable" states const discreteItemTypes = ['Contact', 'Dimmer', 'Rollershutter', 'Switch'] - if (item.category && component.config.iconUseState === undefined && (discreteItemTypes.includes(item.type) || (item.type === 'Groups' && discreteItemTypes.included(item.groupType)))) component.config.iconUseState = true + if (item.category && component.config.iconUseState === undefined && (discreteItemTypes.includes(item.type) || (item.type === 'Group' && discreteItemTypes.includes(item.groupType)))) component.config.iconUseState = true if (item.label && footer && footer.contextLabelSource) { let text = itemContextLabel(item, footer) if (text) component.config.footer = text From 522d5a6e16e5e8637746e55ad24cf7bc073416e9 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Sat, 6 May 2023 23:01:59 +0200 Subject: [PATCH 4/4] Regenerate component docs Signed-off-by: Florian Hotze --- bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-input-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-label-card.md | 2 +- bundles/org.openhab.ui/doc/components/oh-label-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-list-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-plan-marker.md | 2 +- bundles/org.openhab.ui/doc/components/oh-player-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-rollershutter-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-slider-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-stepper-item.md | 2 +- bundles/org.openhab.ui/doc/components/oh-toggle-item.md | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md b/bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md index 6ffd5e7fb9..e4256929ad 100644 --- a/bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-colorpicker-item.md @@ -56,7 +56,7 @@ Display a color picker in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-input-item.md b/bundles/org.openhab.ui/doc/components/oh-input-item.md index 97e61c504c..1dd45d6da5 100644 --- a/bundles/org.openhab.ui/doc/components/oh-input-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-input-item.md @@ -56,7 +56,7 @@ Display an input field in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-label-card.md b/bundles/org.openhab.ui/doc/components/oh-label-card.md index c948c99e06..f65b109943 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-card.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-card.md @@ -421,7 +421,7 @@ Display the state of an item in a card - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-label-item.md b/bundles/org.openhab.ui/doc/components/oh-label-item.md index 64514e259a..8d4c216ed8 100644 --- a/bundles/org.openhab.ui/doc/components/oh-label-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-label-item.md @@ -67,7 +67,7 @@ Display the state of an item in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-list-item.md b/bundles/org.openhab.ui/doc/components/oh-list-item.md index fa81c11b3c..9dbdb5ca6d 100644 --- a/bundles/org.openhab.ui/doc/components/oh-list-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-list-item.md @@ -56,7 +56,7 @@ A list item - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md index 468cb41757..23f35483bb 100644 --- a/bundles/org.openhab.ui/doc/components/oh-plan-marker.md +++ b/bundles/org.openhab.ui/doc/components/oh-plan-marker.md @@ -62,7 +62,7 @@ A marker on a floor plan - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-player-item.md b/bundles/org.openhab.ui/doc/components/oh-player-item.md index 51409f06d3..49e0043454 100644 --- a/bundles/org.openhab.ui/doc/components/oh-player-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-player-item.md @@ -56,7 +56,7 @@ Display player controls in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-rollershutter-item.md b/bundles/org.openhab.ui/doc/components/oh-rollershutter-item.md index 18f57d2aec..8e9bd2b67e 100644 --- a/bundles/org.openhab.ui/doc/components/oh-rollershutter-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-rollershutter-item.md @@ -56,7 +56,7 @@ Display rollershutter controls in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-slider-item.md b/bundles/org.openhab.ui/doc/components/oh-slider-item.md index c4d9936073..362f6122cd 100644 --- a/bundles/org.openhab.ui/doc/components/oh-slider-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-slider-item.md @@ -56,7 +56,7 @@ Display a slider control in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-stepper-item.md b/bundles/org.openhab.ui/doc/components/oh-stepper-item.md index 7b8a229372..d0252aa575 100644 --- a/bundles/org.openhab.ui/doc/components/oh-stepper-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-stepper-item.md @@ -56,7 +56,7 @@ Display a stepper control in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only) diff --git a/bundles/org.openhab.ui/doc/components/oh-toggle-item.md b/bundles/org.openhab.ui/doc/components/oh-toggle-item.md index 400e685e8a..71676da9f5 100644 --- a/bundles/org.openhab.ui/doc/components/oh-toggle-item.md +++ b/bundles/org.openhab.ui/doc/components/oh-toggle-item.md @@ -56,7 +56,7 @@ Display a toggle switch in a list - Use the state of the Item to get a dynamic icon (enabled by default for all Item types except Call, Image & Location) (for openHAB icons only) + Use the state of the Item to get a dynamic icon (enabled by default for Contact, Dimmer, Rollershutter & Switch Item types) (for openHAB icons only)