package com.perforce.spark; import java.util.HashMap; import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; public class NavBar { private SortedMap<String, NavBarItem> map = new TreeMap<>(); public void add(NavBarItem item) { String id = item.getPage(); map.put(id, item); } public Map<String, Object> getAttributes(String selected) { Map<String, Object> attributes = new HashMap<>(); attributes.put("navBar", navBar(selected)); attributes.put("title", title(selected)); attributes.put("pageTemplate", selected + ".ftl"); return attributes; } private String navBar(String selected) { StringBuilder form = new StringBuilder(); form.append("<ul class=\"nav navbar-nav\">"); for (String id : map.keySet()) { NavBarItem nav = map.get(id); if (id.equals(selected)) { form.append("<li class=\"active\">"); } else { form.append("<li>"); } form.append("<a href=\"/"); form.append(nav.getPage()); form.append("\">"); form.append(nav.getTitle()); form.append("</a>"); } form.append("</ul>"); return form.toString(); } private String title(String id) { String title = ""; if (map.containsKey(id)) { title = map.get(id).getTitle(); } return title; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 14181 | Paul Allen | Lots of updates and refactoring. | ||
#5 | 13869 | Paul Allen |
- Fix logout when testing cookie. - Refactor ftl->html - Add local bootstrap |
||
#4 | 13798 | Paul Allen | Basic file upload and login/logout cookie tidyup | ||
#3 | 13728 | Paul Allen | Error support | ||
#2 | 13722 | Paul Allen | Login UX | ||
#1 | 13720 | Paul Allen | Perforce Asset Manager (PAM or P4AM) -- ideas |