Skip to content
Snippets Groups Projects
Commit ed1d8913 authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#585 - dynamically show chart display type buttons

parent 82960314
Branches
Tags
No related merge requests found
...@@ -66,6 +66,7 @@ public class ChartController extends BaseController ...@@ -66,6 +66,7 @@ public class ChartController extends BaseController
model.addAttribute("chartSettings", defaultChartSettings); model.addAttribute("chartSettings", defaultChartSettings);
model.addAttribute("charts", charts); model.addAttribute("charts", charts);
model.addAttribute("displayTypes", ChartDisplayType.values());
return "charts/charts"; return "charts/charts";
} }
......
...@@ -4,18 +4,30 @@ import de.deadlocker8.budgetmaster.utils.LocalizedEnum; ...@@ -4,18 +4,30 @@ import de.deadlocker8.budgetmaster.utils.LocalizedEnum;
public enum ChartDisplayType implements LocalizedEnum public enum ChartDisplayType implements LocalizedEnum
{ {
PIE("pie"), PIE("fas fa-chart-pie", "pie"),
BAR("bar"), BAR("fas fa-chart-bar", "bar"),
LINE("line"), LINE("fas fa-chart-line", "line"),
CUSTOM("custom"); CUSTOM("insights", "custom");
private final String icon;
private final String localizationKey; private final String localizationKey;
ChartDisplayType(String localizationKey) ChartDisplayType(String icon, String localizationKey)
{ {
this.icon = icon;
this.localizationKey = localizationKey; this.localizationKey = localizationKey;
} }
public boolean hasFontAwesomeIcon()
{
return icon.startsWith("fa");
}
public String getIcon()
{
return icon;
}
@Override @Override
public String getLocalizationKey() public String getLocalizationKey()
{ {
......
...@@ -565,3 +565,8 @@ import.entity.image=Icons werden automatisch mit den zugehörigen Konten, Vorlag ...@@ -565,3 +565,8 @@ import.entity.image=Icons werden automatisch mit den zugehörigen Konten, Vorlag
import.entity.chart=Es werden nur die benutzerdefinierten Diagramme importiert.<br>Der Import von Diagrammen ist optional. import.entity.chart=Es werden nur die benutzerdefinierten Diagramme importiert.<br>Der Import von Diagrammen ist optional.
copied=Kopiert! copied=Kopiert!
chart.display.type.pie=Torte
chart.display.type.bar=Balken
chart.display.type.line=Linien
chart.display.type.custom=Benutzerdefiniert
...@@ -564,3 +564,8 @@ import.entity.image=Icons are automatically imported with their associated accou ...@@ -564,3 +564,8 @@ import.entity.image=Icons are automatically imported with their associated accou
import.entity.chart=Only user-defined charts will be imported.<br>The import of charts is optional. import.entity.chart=Only user-defined charts will be imported.<br>The import of charts is optional.
copied=Copied! copied=Copied!
chart.display.type.pie=Pie
chart.display.type.bar=Bar
chart.display.type.line=Line
chart.display.type.custom=Custom
...@@ -32,23 +32,9 @@ ...@@ -32,23 +32,9 @@
<div class="container"> <div class="container">
<div class="row hide-on-small-and-down"> <div class="row hide-on-small-and-down">
<div class="col s12 center-align"> <div class="col s12 center-align">
<a class="waves-effect waves-light btn-large background-grey text-black"><i class="fas fa-chart-pie left"></i> Pie</a> <#list displayTypes as displayType>
<a class="waves-effect waves-light btn-large background-green text-black"><i class="fas fa-chart-bar left"></i> Bar</a> <@chartDisplayTypeButton displayType/>
<a class="waves-effect waves-light btn-large background-grey text-black"><i class="fas fa-chart-line left"></i> Line</a> </#list>
<a class="waves-effect waves-light btn-large background-grey text-black"><i class="material-icons left">insights</i> Custom</a>
</div>
</div>
<div class="row hide-on-med-and-up">
<div class="col s12 center-align">
<a class="waves-effect waves-light btn background-grey text-black"><i class="fas fa-chart-pie left"></i> Pie</a>
<a class="waves-effect waves-light btn background-green text-black"><i class="fas fa-chart-bar left"></i> Bar</a>
</div>
</div>
<div class="row hide-on-med-and-up">
<div class="col s12 center-align">
<a class="waves-effect waves-light btn background-grey text-black"><i class="fas fa-chart-line left"></i> Line</a>
<a class="waves-effect waves-light btn background-grey text-black"><i class="material-icons left">insights</i> Custom</a>
</div> </div>
</div> </div>
</div> </div>
...@@ -325,3 +311,13 @@ ...@@ -325,3 +311,13 @@
</div> </div>
</@stepCollapsible> </@stepCollapsible>
</#macro> </#macro>
<#macro chartDisplayTypeButton displayType>
<a class="waves-effect waves-light btn-large background-grey text-black">
<#if displayType.hasFontAwesomeIcon()>
<i class="${displayType.getIcon()} left"></i> ${locale.getString(displayType.getLocalizationKey())}
<#else>
<i class="material-icons left">${displayType.getIcon()}</i> ${locale.getString(displayType.getLocalizationKey())}
</#if>
</a>
</#macro>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment