VIVO-258 Add a "selected" flag to each Freemarker locale variable.

This commit is contained in:
j2blake 2013-08-22 10:56:49 -04:00
parent b0e0c773c9
commit 9d1fef76ea
2 changed files with 7 additions and 4 deletions

View file

@ -60,11 +60,11 @@ public class LocaleSelectionDataGetter implements DataGetter {
return Collections.emptyMap(); return Collections.emptyMap();
} }
Map<String, Object> result = new HashMap<String, Object>(); Map<String, Object> result = new HashMap<>();
result.put("selectLocaleUrl", UrlBuilder.getUrl("/selectLocale")); result.put("selectLocaleUrl", UrlBuilder.getUrl("/selectLocale"));
result.put("locales", buildLocalesList(selectables)); result.put("locales", buildLocalesList(selectables));
Map<String, Object> bodyMap = new HashMap<String, Object>(); Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("selectLocale", result); bodyMap.put("selectLocale", result);
log.debug("Sending these values: " + bodyMap); log.debug("Sending these values: " + bodyMap);
return bodyMap; return bodyMap;
@ -72,7 +72,7 @@ public class LocaleSelectionDataGetter implements DataGetter {
private List<Map<String, Object>> buildLocalesList(List<Locale> selectables) { private List<Map<String, Object>> buildLocalesList(List<Locale> selectables) {
Locale currentLocale = SelectedLocale.getCurrentLocale(vreq); Locale currentLocale = SelectedLocale.getCurrentLocale(vreq);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> list = new ArrayList<>();
for (Locale locale : selectables) { for (Locale locale : selectables) {
try { try {
list.add(buildLocaleMap(locale, currentLocale)); list.add(buildLocaleMap(locale, currentLocale));
@ -86,10 +86,12 @@ public class LocaleSelectionDataGetter implements DataGetter {
private Map<String, Object> buildLocaleMap(Locale locale, private Map<String, Object> buildLocaleMap(Locale locale,
Locale currentLocale) throws FileNotFoundException { Locale currentLocale) throws FileNotFoundException {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("code", locale.toString()); map.put("code", locale.toString());
map.put("label", locale.getDisplayName(currentLocale)); map.put("label", locale.getDisplayName(currentLocale));
map.put("imageUrl", LocaleSelectorUtilities.getImageUrl(vreq, locale)); map.put("imageUrl", LocaleSelectorUtilities.getImageUrl(vreq, locale));
map.put("selected", currentLocale.equals(locale));
return map; return map;
} }
} }

View file

@ -25,4 +25,5 @@
* -- code * -- code
* -- label (tooltip relative to the current Locale) * -- label (tooltip relative to the current Locale)
* -- imageUrl * -- imageUrl
* -- selected (boolean)
--> -->