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 ModelAndView showAlert(ModelAndView mav, AlertType alertType, String alertMessage, Object...args) {
|
||||
// TODO alerts with args?
|
||||
Map<String, String> alerts = (Map<String, String>) mav.getModelMap().getAttribute("alerts");
|
||||
Map<String, Object> alerts = (Map<String, Object>) mav.getModelMap().getAttribute("alerts");
|
||||
if (alerts == null) {
|
||||
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);
|
||||
return mav;
|
||||
}
|
||||
|
@ -16,9 +16,14 @@
|
||||
</#macro>
|
||||
|
||||
<#macro normalAlert alertType>
|
||||
<#assign message=alerts[alertType]>
|
||||
<#assign message=alerts[alertType]["message"]>
|
||||
<#assign args=alerts[alertType]["args"]>
|
||||
<#if message??>
|
||||
<@spring.message message />
|
||||
<#if args??>
|
||||
<@spring.messageArgs message args />
|
||||
<#else>
|
||||
<@spring.message message />
|
||||
</#if>
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user