Skip to content

Commit

Permalink
MID-8294: fix for definition of background color for icon of dashboar…
Browse files Browse the repository at this point in the history
…d widget
  • Loading branch information
skublik committed Dec 5, 2022
1 parent 7a85781 commit 84195b5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ protected void onComponentTag(final ComponentTag tag) {
if (link.getIcon() != null) {
cssClass = link.getIcon().getCssClass();
}
tag.put("class", "info-box-icon " + (link.getColor() != null ?
(link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " "
+ cssClass);
tag.put("class", "info-box-icon " + " " + cssClass);
tag.put("style", link.getColor() != null ?
("background-color: " + link.getColor() + " !important") : "");
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ protected void onComponentTag(final ComponentTag tag) {
if (link.getIcon() != null) {
cssClass = link.getIcon().getCssClass();
}
tag.put("class", "info-box-icon " + (link.getColor() != null ?
(link.getColor().startsWith("bg-") ? link.getColor() : "bg-" + link.getColor()) : "") + " "
+ cssClass);
tag.put("class", "info-box-icon " + " " + cssClass);
tag.put("style", link.getColor() != null ? ("background-color: " + link.getColor() + " !important") : "");
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void onClick() {

Label icon = new Label(ID_IMAGE);
icon.add(AttributeAppender.append("class", getIconClassModel()));
icon.add(AttributeAppender.append("style", getIconStyleModel()));
linkItem.add(icon);

linkItem.add(new Label(ID_LABEL, () -> {
Expand All @@ -97,15 +98,14 @@ public void onClick() {
linkItem.add(statisticData);
}


private IModel<String> getIconClassModel() {
return () -> {
ContainerPanelConfigurationType panel = StatisticDashboardWidget.this.getModelObject();
String cssClass = GuiDisplayTypeUtil.getIconCssClass(panel.getDisplay());
if (StringUtils.isEmpty(cssClass)) {
cssClass = ICON_DEFAULT_CSS_CLASS;
}
return "info-box-icon " + getIconColor() + cssClass;
return "info-box-icon " + cssClass;
};
}

Expand Down Expand Up @@ -139,12 +139,14 @@ private CompiledObjectCollectionView getObjectCollectionView() {
return getPageBase().getCompiledGuiProfile().findObjectCollectionView(view.getType(), viewIdentifier);
}

private String getIconColor() {
String iconColor = GuiDisplayTypeUtil.getIconColor(getModelObject().getDisplay());
if (StringUtils.isNotEmpty(iconColor)) {
return iconColor.startsWith("bg-") ? iconColor : "bg-" + iconColor + " ";
}
return "";
private IModel<String> getIconStyleModel() {
return () -> {
String iconColor = GuiDisplayTypeUtil.getIconColor(getModelObject().getDisplay());
if (StringUtils.isNotEmpty(iconColor)) {
return "background-color: " + iconColor + " !important";
}
return "";
};
}

private boolean isExternalLink() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,7 @@
<help>PageSelfDashboard.profile.description</help>
<cssClass>col-md-3</cssClass>
<icon>
<cssClass>fa fa-user</cssClass>
<color>green</color>
<cssClass>bg-green fa fa-user</cssClass>
</icon>
</display>
<panelType>linkWidget</panelType>
Expand All @@ -366,8 +365,7 @@
<help>PageSelfDashboard.credentials.description</help>
<cssClass>col-md-3</cssClass>
<icon>
<cssClass>fa fa-shield-alt</cssClass>
<color>blue</color>
<cssClass>bg-blue fa fa-shield-alt</cssClass>
</icon>
</display>
<panelType>linkWidget</panelType>
Expand All @@ -389,8 +387,7 @@
</label>
<cssClass>col-md-3</cssClass>
<icon>
<cssClass>fa fa-database</cssClass>
<color>purple</color>
<cssClass>bg-purple fa fa-database</cssClass>
</icon>
</display>
<panelType>linkWidget</panelType>
Expand All @@ -412,8 +409,7 @@
</label>
<cssClass>col-md-3</cssClass>
<icon>
<cssClass>fa fa-user</cssClass>
<color>red</color>
<cssClass>bg-red fa fa-user</cssClass>
</icon>
</display>
<panelType>linkWidget</panelType>
Expand Down

0 comments on commit 84195b5

Please sign in to comment.