# HG changeset patch # User Mike Becker # Date 1598106303 -7200 # Node ID b7b685f31e3903c1f4864eafa6c84a31f9bf22b4 # Parent 0552cc5755f376af3b19ba9c754adf27586f8cf2 breadcrumb menu is now a sidebar navigation menu diff -r 0552cc5755f3 -r b7b685f31e39 pom.xml --- a/pom.xml Sun Jun 21 12:38:15 2020 +0200 +++ b/pom.xml Sat Aug 22 16:25:03 2020 +0200 @@ -4,7 +4,7 @@ 4.0.0 de.uapcore lightpit - 0.3 + 0.4-SNAPSHOT war UTF-8 diff -r 0552cc5755f3 -r b7b685f31e39 src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java --- a/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sun Jun 21 12:38:15 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java Sat Aug 22 16:25:03 2020 +0200 @@ -228,14 +228,14 @@ } /** - * Sets the breadcrumbs menu. + * Sets the navigation menu. * - * @param req the servlet request object - * @param breadcrumbs the menu entries for the breadcrumbs menu - * @see Constants#REQ_ATTR_BREADCRUMBS + * @param req the servlet request object + * @param navigationItems the menu entries for the navigation menu + * @see Constants#REQ_ATTR_NAVIGATION */ - protected void setBreadcrumbs(HttpServletRequest req, List breadcrumbs) { - req.setAttribute(Constants.REQ_ATTR_BREADCRUMBS, breadcrumbs); + protected void setNavItems(HttpServletRequest req, List navigationItems) { + req.setAttribute(Constants.REQ_ATTR_NAVIGATION, navigationItems); } /** diff -r 0552cc5755f3 -r b7b685f31e39 src/main/java/de/uapcore/lightpit/Constants.java --- a/src/main/java/de/uapcore/lightpit/Constants.java Sun Jun 21 12:38:15 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/Constants.java Sat Aug 22 16:25:03 2020 +0200 @@ -72,9 +72,9 @@ public static final String REQ_ATTR_MENU = fqn(AbstractLightPITServlet.class, "mainMenu"); /** - * Key for the request attribute containing the breadcrumb menu. + * Key for the request attribute containing the navigation menu. */ - public static final String REQ_ATTR_BREADCRUMBS = fqn(AbstractLightPITServlet.class, "breadcrumbs"); + public static final String REQ_ATTR_NAVIGATION = fqn(AbstractLightPITServlet.class, "navMenu"); /** * Key for the request attribute containing the base href. diff -r 0552cc5755f3 -r b7b685f31e39 src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java --- a/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sun Jun 21 12:38:15 2020 +0200 +++ b/src/main/java/de/uapcore/lightpit/modules/ProjectsModule.java Sat Aug 22 16:25:03 2020 +0200 @@ -202,27 +202,27 @@ } - private static final int BREADCRUMB_LEVEL_ROOT = 0; - private static final int BREADCRUMB_LEVEL_PROJECT = 1; - private static final int BREADCRUMB_LEVEL_VERSION = 2; - private static final int BREADCRUMB_LEVEL_ISSUE_LIST = 3; - private static final int BREADCRUMB_LEVEL_ISSUE = 4; + private static final int NAV_LEVEL_ROOT = 0; + private static final int NAV_LEVEL_PROJECT = 1; + private static final int NAV_LEVEL_VERSION = 2; + private static final int NAV_LEVEL_ISSUE_LIST = 3; + private static final int NAV_LEVEL_ISSUE = 4; /** - * Creates the breadcrumb menu. + * Creates the navigation menu. * - * @param level the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue) + * @param level the current active level (0: root, 1: project, 2: version, 3: issue list, 4: issue) * @param selection the currently selected objects - * @return a dynamic breadcrumb menu trying to display as many levels as possible + * @return a dynamic navigation menu trying to display as many levels as possible */ - private List getBreadcrumbs(int level, SessionSelection selection) { + private List getNavMenu(int level, SessionSelection selection) { MenuEntry entry; - final var breadcrumbs = new ArrayList(); + final var navigation = new ArrayList(); entry = new MenuEntry(new ResourceKey("localization.lightpit", "menu.projects"), "projects/"); - breadcrumbs.add(entry); - if (level == BREADCRUMB_LEVEL_ROOT) entry.setActive(true); + navigation.add(entry); + if (level == NAV_LEVEL_ROOT) entry.setActive(true); if (selection.project != null) { if (selection.project.getId() < 0) { @@ -232,8 +232,8 @@ entry = new MenuEntry(selection.project.getName(), "projects/view?pid=" + selection.project.getId()); } - if (level == BREADCRUMB_LEVEL_PROJECT) entry.setActive(true); - breadcrumbs.add(entry); + if (level == NAV_LEVEL_PROJECT) entry.setActive(true); + navigation.add(entry); } if (selection.version != null) { @@ -244,19 +244,19 @@ entry = new MenuEntry(selection.version.getName(), "projects/versions/view?vid=" + selection.version.getId()); } - if (level == BREADCRUMB_LEVEL_VERSION) entry.setActive(true); - breadcrumbs.add(entry); + if (level == NAV_LEVEL_VERSION) entry.setActive(true); + navigation.add(entry); } if (selection.project != null) { String path = "projects/issues/?pid=" + selection.project.getId(); if (selection.version != null) { - path += "&vid="+selection.version.getId(); + path += "&vid=" + selection.version.getId(); } entry = new MenuEntry(new ResourceKey("localization.projects", "menu.issues"), path); - if (level == BREADCRUMB_LEVEL_ISSUE_LIST) entry.setActive(true); - breadcrumbs.add(entry); + if (level == NAV_LEVEL_ISSUE_LIST) entry.setActive(true); + navigation.add(entry); } if (selection.issue != null) { @@ -268,11 +268,11 @@ // TODO: maybe change link to a view rather than directly opening the editor "projects/issues/edit?issue=" + selection.issue.getId()); } - if (level == BREADCRUMB_LEVEL_ISSUE) entry.setActive(true); - breadcrumbs.add(entry); + if (level == NAV_LEVEL_ISSUE) entry.setActive(true); + navigation.add(entry); } - return breadcrumbs; + return navigation; } @RequestMapping(method = HttpMethod.GET) @@ -297,7 +297,7 @@ setContentPage(req, "projects"); setStylesheet(req, "projects"); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ROOT, sessionSelection)); + setNavItems(req, getNavMenu(NAV_LEVEL_ROOT, sessionSelection)); return ResponseType.HTML; } @@ -308,7 +308,7 @@ viewModel.setUsers(dao.getUserDao().list()); setViewModel(req, viewModel); setContentPage(req, "project-form"); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection)); return viewModel; } @@ -377,7 +377,7 @@ viewModel.updateVersionInfo(); setViewModel(req, viewModel); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_PROJECT, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_PROJECT, selection)); setContentPage(req, "project-details"); setStylesheet(req, "projects"); @@ -400,7 +400,7 @@ viewModel.setIssues(issues); setViewModel(req, viewModel); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection)); setContentPage(req, "version"); setStylesheet(req, "projects"); @@ -414,7 +414,7 @@ } setViewModel(req, viewModel); setContentPage(req, "version-form"); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_VERSION, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_VERSION, selection)); return viewModel; } @@ -445,7 +445,7 @@ dao.getVersionDao().saveOrUpdate(version); // specifying the pid parameter will purposely reset the session selected version! - setRedirectLocation(req, "./projects/view?pid="+version.getProject().getId()); + setRedirectLocation(req, "./projects/view?pid=" + version.getProject().getId()); setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL); } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) { LOG.warn("Form validation failure: {}", ex.getMessage()); @@ -471,7 +471,7 @@ setViewModel(req, viewModel); setContentPage(req, "issue-form"); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE, selection)); return viewModel; } @@ -494,7 +494,7 @@ } setViewModel(req, viewModel); - setBreadcrumbs(req, getBreadcrumbs(BREADCRUMB_LEVEL_ISSUE_LIST, selection)); + setNavItems(req, getNavMenu(NAV_LEVEL_ISSUE_LIST, selection)); setContentPage(req, "issues"); setStylesheet(req, "projects"); @@ -534,7 +534,7 @@ getParameter(req, Integer[].class, "affected") .map(Stream::of) .map(stream -> - stream.map(Version::new).collect(Collectors.toList()) + stream.map(Version::new).collect(Collectors.toList()) ).ifPresent(issue::setAffectedVersions); getParameter(req, Integer[].class, "resolved") .map(Stream::of) @@ -544,8 +544,8 @@ dao.getIssueDao().saveOrUpdate(issue); - // specifying the issue parameter keeps the edited issue as breadcrumb - setRedirectLocation(req, "./projects/issues/?issue="+issue.getId()); + // specifying the issue parameter keeps the edited issue as menu item + setRedirectLocation(req, "./projects/issues/?issue=" + issue.getId()); setContentPage(req, Constants.JSP_COMMIT_SUCCESSFUL); } catch (NoSuchElementException | IllegalArgumentException | SQLException ex) { // TODO: set request attribute with error text diff -r 0552cc5755f3 -r b7b685f31e39 src/main/webapp/WEB-INF/jsp/site.jsp --- a/src/main/webapp/WEB-INF/jsp/site.jsp Sun Jun 21 12:38:15 2020 +0200 +++ b/src/main/webapp/WEB-INF/jsp/site.jsp Sat Aug 22 16:25:03 2020 +0200 @@ -40,7 +40,7 @@ <%-- Define an alias for the main menu --%> - + <%-- Define an alias for the content page name --%> @@ -83,17 +83,19 @@ <%@include file="../jspf/menu-entry.jsp" %> - -