Skip to content

Commit

Permalink
[BasicUI] Switch with buttons: value displayed if pattern on widget (#…
Browse files Browse the repository at this point in the history
…2579)

When a Switch widget leads to the rendering with buttons, the value
should not be by default also displayed at the left of the buttons
(redundant information), except if it is requested through a state
pattern defined on the widget.

Signed-off-by: Laurent Garnier <[email protected]>
  • Loading branch information
lolodomo authored May 18, 2024
1 parent 2fd4267 commit 37cfea2
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,27 @@ public EList<Widget> renderWidget(Widget w, StringBuilder sb, String sitemap) th
String snippet = getSnippet(snippetName);
State state = itemUIRegistry.getState(w);

snippet = preprocessSnippet(snippet, w);

if (nbButtons == 0) {
snippet = preprocessSnippet(snippet, w);

if (OnOffType.ON.equals(state)) {
snippet = snippet.replaceAll("%checked%", "checked=true");
} else {
snippet = snippet.replaceAll("%checked%", "");
}
} else {
// Show the value at left of all the buttons only if a state pattern is set on the sitemap widget
if (!hasValue(w.getLabel())) {
snippet = snippet.replace("%value%", "");
snippet = snippet.replace("%has_value%", "false");
}

snippet = preprocessSnippet(snippet, w);

snippet = snippet.replaceAll("%height_auto%", multiline ? "mdl-form__row--height-auto" : "");
snippet = snippet.replaceAll("%buttons_class%",
multiline ? "mdl-form__buttons-multiline" : "mdl-form__buttons");

StringBuilder buttons = new StringBuilder();
if (s.getMappings().isEmpty() && item != null) {
final CommandDescription commandDescription = item.getCommandDescription();
Expand Down

0 comments on commit 37cfea2

Please sign in to comment.