mirror of
https://github.com/HangarMC/Hangar.git
synced 2024-12-21 06:51:19 +08:00
added the option to have arguments with the alerts
This commit is contained in:
parent
2ed3100550
commit
db9cb04792
@ -21,12 +21,14 @@ public class AlertUtil {
|
|||||||
public static final String ARGS = "alertArgs";
|
public static final String ARGS = "alertArgs";
|
||||||
|
|
||||||
public static ModelAndView showAlert(ModelAndView mav, AlertType alertType, String alertMessage, Object...args) {
|
public static ModelAndView showAlert(ModelAndView mav, AlertType alertType, String alertMessage, Object...args) {
|
||||||
// TODO alerts with args?
|
Map<String, Object> alerts = (Map<String, Object>) mav.getModelMap().getAttribute("alerts");
|
||||||
Map<String, String> alerts = (Map<String, String>) mav.getModelMap().getAttribute("alerts");
|
|
||||||
if (alerts == null) {
|
if (alerts == null) {
|
||||||
alerts = new HashMap<>();
|
alerts = new HashMap<>();
|
||||||
}
|
}
|
||||||
alerts.put(alertType.name().toLowerCase(), alertMessage);
|
Map<String, Object> thisAlert = new HashMap<>();
|
||||||
|
thisAlert.put("message", alertMessage);
|
||||||
|
thisAlert.put("args", args);
|
||||||
|
alerts.put(alertType.name().toLowerCase(), thisAlert);
|
||||||
mav.addObject("alerts", alerts);
|
mav.addObject("alerts", alerts);
|
||||||
return mav;
|
return mav;
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,15 @@
|
|||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro normalAlert alertType>
|
<#macro normalAlert alertType>
|
||||||
<#assign message=alerts[alertType]>
|
<#assign message=alerts[alertType]["message"]>
|
||||||
|
<#assign args=alerts[alertType]["args"]>
|
||||||
<#if message??>
|
<#if message??>
|
||||||
|
<#if args??>
|
||||||
|
<@spring.messageArgs message args />
|
||||||
|
<#else>
|
||||||
<@spring.message message />
|
<@spring.message message />
|
||||||
</#if>
|
</#if>
|
||||||
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro numAlert alertType>
|
<#macro numAlert alertType>
|
||||||
|
Loading…
Reference in New Issue
Block a user