]> source.dussan.org Git - gitblit.git/commitdiff
Indicate selected filters. Strip default db value from links.
authorJames Moger <james.moger@gitblit.com>
Fri, 30 Dec 2011 12:53:00 +0000 (07:53 -0500)
committerJames Moger <james.moger@gitblit.com>
Fri, 30 Dec 2011 12:53:00 +0000 (07:53 -0500)
resources/bootstrap.gb.css
src/com/gitblit/wicket/PageRegistration.java
src/com/gitblit/wicket/pages/ActivityPage.java
src/com/gitblit/wicket/pages/RepositoriesPage.java
src/com/gitblit/wicket/pages/RootPage.java
src/com/gitblit/wicket/panels/DropDownMenu.java

index 44f2c19b73fdc76bcad4b1c45d01659136848953..e1092b03da1f973691d8051ee619c8e100f1131c 100644 (file)
@@ -86,12 +86,22 @@ hr {
     border-color: #eee;\r
 }\r
 \r
+.topbar div > ul .menu-dropdown .selected, .nav .menu-dropdown .selected, .topbar div > ul .dropdown-menu .selected, .nav .dropdown-menu .selected {\r
+       background-image: url("bullet_blue.png");\r
+       background-repeat: no-repeat;\r
+       background-position: left;      \r
+}\r
+\r
 .topbar div > ul .menu-dropdown li a, .nav .menu-dropdown li a, .topbar div > ul .dropdown-menu li a, .nav .dropdown-menu li a {\r
     color: #555;\r
     text-shadow: none;\r
     outline: 0;\r
 }\r
 \r
+.topbar ul .menu-dropdown li a, .topbar ul .dropdown-menu li a {\r
+    padding: 4px 22px;    \r
+}\r
+\r
 topbar div>ul .menu-dropdown li a:hover,.nav .menu-dropdown li a:hover,.topbar div>ul .dropdown-menu li a:hover,.nav .dropdown-menu li a:hover{\r
        background-color: #000070;\r
        background-repeat:no-repeat;\r
index 6c13b82e538faf8b0d8152f45d61c45082f124d6..fe76a85fc1b93fb5772be9d77b636447148effe0 100644 (file)
@@ -76,19 +76,17 @@ public class PageRegistration implements Serializable {
 \r
                private static final long serialVersionUID = 1L;\r
 \r
-               final PageParameters params;\r
+               final PageParameters parameters;\r
                final String displayText;\r
                final String parameter;\r
                final String value;\r
+               final boolean isSelected;\r
 \r
                /**\r
                 * Divider constructor.\r
                 */\r
                public DropDownMenuItem() {\r
-                       displayText = null;\r
-                       parameter = null;\r
-                       value = null;\r
-                       params = null;\r
+                       this(null, null, null, null);\r
                }\r
 \r
                /**\r
@@ -114,16 +112,37 @@ public class PageRegistration implements Serializable {
                        this.displayText = displayText;\r
                        this.parameter = parameter;\r
                        this.value = value;\r
+\r
                        if (params == null) {\r
-                               this.params = new PageParameters();\r
+                               // no parameters specified\r
+                               parameters = new PageParameters();\r
+                               setParameter(parameter, value);\r
+                               isSelected = false;\r
                        } else {\r
-                               this.params = new PageParameters(params);\r
+                               parameters = new PageParameters(params);\r
+                               if (parameters.containsKey(parameter)) {\r
+                                       isSelected = params.getString(parameter).equals(value);\r
+                                       if (isSelected) {\r
+                                               // already selected, so remove this enables toggling\r
+                                               parameters.remove(parameter);\r
+                                       } else {\r
+                                               // set the new selection value\r
+                                               setParameter(parameter, value);\r
+                                       }\r
+                               } else {\r
+                                       // not currently selected\r
+                                       isSelected = false;\r
+                                       setParameter(parameter, value);\r
+                               }\r
                        }\r
+               }\r
+\r
+               private void setParameter(String parameter, String value) {\r
                        if (!StringUtils.isEmpty(parameter)) {\r
                                if (StringUtils.isEmpty(value)) {\r
-                                       this.params.remove(parameter);\r
+                                       this.parameters.remove(parameter);\r
                                } else {\r
-                                       this.params.put(parameter, value);      \r
+                                       this.parameters.put(parameter, value);\r
                                }\r
                        }\r
                }\r
@@ -136,13 +155,17 @@ public class PageRegistration implements Serializable {
                }\r
 \r
                public PageParameters getPageParameters() {\r
-                       return params;\r
+                       return parameters;\r
                }\r
 \r
                public boolean isDivider() {\r
                        return displayText == null && value == null && parameter == null;\r
                }\r
 \r
+               public boolean isSelected() {\r
+                       return isSelected;\r
+               }\r
+\r
                @Override\r
                public int hashCode() {\r
                        if (isDivider()) {\r
index 9b258a72266b8da5a2c59c7aa78d3fcbd3e84ece..d548cfb649ef78db17f0677ebbd7d4488eb60a17 100644 (file)
@@ -109,16 +109,13 @@ public class ActivityPage extends RootPage {
 \r
                PageParameters currentParameters = getPageParameters();\r
                int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 14);\r
-               if (currentParameters.containsKey("db")) {\r
-                       daysBack = currentParameters.getInt("db");\r
-               }\r
-               if (daysBack < 1) {\r
-                       daysBack = 14;\r
+               if (currentParameters != null && !currentParameters.containsKey("db")) {\r
+                       currentParameters.put("db", daysBack);\r
                }\r
 \r
                // preserve time filter options on repository choices\r
-               filters.menuItems.addAll(getRepositoryFilterItems(new PageParameters("db=" + daysBack)));\r
-                               \r
+               filters.menuItems.addAll(getRepositoryFilterItems(currentParameters));\r
+\r
                // preserve repository filter options on time choices\r
                filters.menuItems.addAll(getTimeFilterItems(currentParameters));\r
 \r
index 21efddac3a3134b2ac19345de1cbc0ad13ad3ad3..bc33b01fdeb52238652757911b0cbf10db397f0d 100644 (file)
@@ -91,20 +91,16 @@ public class RepositoriesPage extends RootPage {
 \r
        @Override\r
        protected void addDropDownMenus(List<PageRegistration> pages) {\r
-               int daysBack = 0;\r
                PageParameters currentParameters = getPageParameters();\r
-               if (currentParameters != null && currentParameters.containsKey("db")) {\r
-                       daysBack = currentParameters.getInt("db");\r
-               }\r
-               PageParameters params = null;\r
-               if (daysBack > 0) {\r
-                       params = new PageParameters("db=" + daysBack);\r
+               int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 14);\r
+               if (currentParameters != null && !currentParameters.containsKey("db")) {\r
+                       currentParameters.put("db", daysBack);\r
                }\r
 \r
                DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters",\r
                                RepositoriesPage.class);\r
                // preserve time filter option on repository choices\r
-               menu.menuItems.addAll(getRepositoryFilterItems(params));\r
+               menu.menuItems.addAll(getRepositoryFilterItems(currentParameters));\r
                \r
                // preserve repository filter option on time choices\r
                menu.menuItems.addAll(getTimeFilterItems(currentParameters));\r
index 686fc72552ee29abb49df01e78566caeda7a9dad..cbf9cfe1aa39ffb293d2182b24c5a311ce5eef71 100644 (file)
@@ -171,12 +171,19 @@ public abstract class RootPage extends BasePage {
 \r
        private PageParameters getRootPageParameters() {\r
                if (reusePageParameters()) {\r
-                       PageParameters params = getPageParameters();\r
-                       if (params != null) {\r
+                       PageParameters pp = getPageParameters();\r
+                       if (pp != null) {\r
+                               PageParameters params = new PageParameters(pp);\r
                                // remove named repository parameter\r
                                params.remove("r");\r
-                       }\r
-                       return params;\r
+\r
+                               // remove days back parameter if it is the default value\r
+                               if (params.containsKey("db")\r
+                                               && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 14)) {\r
+                                       params.remove("db");\r
+                               }\r
+                               return params;\r
+                       }                       \r
                }\r
                return null;\r
        }\r
@@ -262,7 +269,7 @@ public abstract class RootPage extends BasePage {
                        if (addedExpression) {\r
                                filters.add(new DropDownMenuItem());\r
                        }\r
-               }               \r
+               }\r
                return new ArrayList<DropDownMenuItem>(filters);\r
        }\r
 \r
@@ -362,7 +369,7 @@ public abstract class RootPage extends BasePage {
                if (!hasParameter) {\r
                        models.addAll(availableModels);\r
                }\r
-               \r
+\r
                // time-filter the list\r
                if (daysBack > 0) {\r
                        Calendar cal = Calendar.getInstance();\r
index ef6a2fe43c1f255e5a596d92a74de6804954ac97..cc088d7434178f57a662862fc08e3a52eb8acdca 100644 (file)
@@ -43,9 +43,12 @@ public class DropDownMenu extends Panel {
                                if (entry.isDivider()) {\r
                                        item.add(new Label("menuItem").setRenderBodyOnly(true));\r
                                        WicketUtils.setCssClass(item, "divider");\r
-                               } else {\r
+                               } else {                                        \r
                                        item.add(new LinkPanel("menuItem", null, entry.toString(), menu.pageClass,\r
                                                        entry.getPageParameters()).setRenderBodyOnly(true));\r
+                                       if (entry.isSelected()) {\r
+                                               WicketUtils.setCssClass(item, "selected");\r
+                                       }\r
                                }\r
                        }\r
                };\r