From 9ccc90a132ef0c326cdab7347a9e0d6368476b4a Mon Sep 17 00:00:00 2001 From: Laurent Garnier Date: Tue, 15 Aug 2023 02:26:42 +0200 Subject: [PATCH] Add a new data value in snippets Signed-off-by: Laurent Garnier --- .../ui/basic/internal/render/AbstractWidgetRenderer.java | 1 + .../src/main/resources/snippets/buttons.html | 1 + .../src/main/resources/snippets/colorpicker.html | 1 + .../src/main/resources/snippets/group.html | 1 + .../src/main/resources/snippets/icon_oh.html | 2 +- .../src/main/resources/snippets/icon_oh_no_state.html | 2 +- .../src/main/resources/snippets/input.html | 1 + .../src/main/resources/snippets/mapview.html | 1 + .../src/main/resources/snippets/rollerblind.html | 1 + .../src/main/resources/snippets/selection.html | 1 + .../src/main/resources/snippets/setpoint.html | 1 + .../src/main/resources/snippets/slider.html | 1 + .../src/main/resources/snippets/switch.html | 1 + .../src/main/resources/snippets/text.html | 1 + .../src/main/resources/snippets/text_link.html | 1 + .../src/main/resources/snippets/webview.html | 1 + bundles/org.openhab.ui.basic/web-src/smarthome.js | 6 +++--- 17 files changed, 19 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java index a00b63055d..3815f99069 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/AbstractWidgetRenderer.java @@ -128,6 +128,7 @@ protected String preprocessSnippet(String originalSnippet, Widget w, boolean ign snippet = snippet.replace("%cells%", String.valueOf(12 / config.getNbColsDesktop())); snippet = snippet.replace("%cells_tablet%", String.valueOf(8 / config.getNbColsTablet())); snippet = snippet.replace("%widget_id%", itemUIRegistry.getWidgetId(w)); + snippet = snippet.replace("%icon_with_state%", Boolean.valueOf(!ignoreStateForIcon).toString()); snippet = snippet.replace("%item%", w.getItem() != null ? w.getItem() : ""); // Optimization: avoid calling 3 times itemUIRegistry.getLabel(w) String text = itemUIRegistry.getLabel(w); diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html index 8ad90b5fd9..198a56e386 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/buttons.html @@ -15,6 +15,7 @@ data-has-value="%has_value%" data-count="%count%" data-widget-id="%widget_id%" + data-icon-with-state="%icon_with_state%" > %buttons% diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html index d0af3637ff..767ef95fd8 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/colorpicker.html @@ -11,6 +11,7 @@ data-item="%item%" data-value="%state%" data-widget-id="%widget_id%" + data-icon-with-state="%icon_with_state%" >