]> source.dussan.org Git - gitblit.git/commitdiff
collapsible group repositories 1224/head
authorybosy <author@example.com>
Fri, 7 Apr 2017 08:46:35 +0000 (10:46 +0200)
committerybosy <committer@example.com>
Fri, 7 Apr 2017 08:46:35 +0000 (10:46 +0200)
src/main/distrib/data/defaults.properties
src/main/java/com/gitblit/wicket/pages/BasePage.html
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html
src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java
src/main/resources/gitblit/js/collapsible-table.js [new file with mode: 0644]

index 51fa1253ab25d4d880fa28cc5d12a27ffd291820..157731c5cd5bdacf59b05079370487beaffba3ff 100644 (file)
@@ -2147,3 +2147,17 @@ filestore.storageFolder = ${baseFolder}/lfs
 # Common unit suffixes of k, m, or g are supported.
 # SINCE 1.7.0
 filestore.maxUploadSize = -1
+
+# Specify the behaviour of the Repository groups on the "Repositories"
+# page, specifically whether they can be collapsed and expanded, and
+# their default state on loading the page.
+# Only on repositoryListType grouped 
+#
+# Values (case-insensitive): 
+#   disabled - Repository groups cannot collapsed; maintains behaviour
+#              from previous versions of GitBlit.
+#   expanded - On loading the page all repository groups are expanded.
+#   collapsed - On loading the page all repository groups are collapsed.
+#
+# SINCE 1.9.0
+web.collapsibleRepositoryGroups = disabled
index 4dbc2e5743f1312e741ca05aa5ba3d9f32221754..49810ddc09d78c7d90d40eb49fccc71fbca99253 100644 (file)
@@ -51,7 +51,8 @@
                \r
                <!-- Include scripts at end for faster page loading -->\r
                <script type="text/javascript" src="bootstrap/js/jquery.js"></script>\r
-               <script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>                \r
+               <script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>        \r
+               <script type="text/javascript" src="gitblit/js/collapsible-table.js"></script>\r
                <wicket:container wicket:id="bottomScripts"></wicket:container>\r
        </body>\r
 </html>
\ No newline at end of file
index 2de52b09f26544e77543ece451945d53a9ef281e..7c3b3082b175747f7f6634a7e980603369618a7b 100644 (file)
@@ -18,6 +18,9 @@
        </tbody>\r
        </table>\r
 \r
+       <wicket:fragment wicket:id="emptyFragment">\r
+    </wicket:fragment>\r
+\r
     <wicket:fragment wicket:id="repoIconFragment">\r
         <span class="octicon octicon-centered octicon-repo"></span>\r
     </wicket:fragment>\r
                </tr>\r
        </wicket:fragment>\r
        \r
+       <wicket:fragment wicket:id="tableAllCollapsible">\r
+               <i title="Click to expand all" class="fa fa-plus-square-o table-openall-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>\r
+               <i title="Click to collapse all" class="fa fa-minus-square-o table-closeall-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>\r
+    </wicket:fragment>\r
+       \r
        <wicket:fragment wicket:id="groupRepositoryHeader">\r
                <tr>\r
                        <th class="left">\r
+                               <span wicket:id="allCollapsible"></span>\r
                                <img style="vertical-align: middle;" src="git-black-16x16.png"/>\r
                                <wicket:message key="gb.repository">Repository</wicket:message>\r
                        </th>\r
                </tr>\r
        </wicket:fragment>\r
        \r
+       <wicket:fragment wicket:id="tableGroupMinusCollapsible">\r
+               <i title="Click to expand/collapse" class="fa fa-minus-square-o table-group-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>\r
+    </wicket:fragment>\r
+    \r
+    <wicket:fragment wicket:id="tableGroupPlusCollapsible">\r
+               <i title="Click to expand/collapse" class="fa fa-plus-square-o table-group-collapsible" aria-hidden="true" style="padding-right:3px;cursor:pointer;"></i>\r
+    </wicket:fragment>\r
+       \r
        <wicket:fragment wicket:id="groupRepositoryRow">\r
-        <td colspan="1"><span wicket:id="groupName">[group name]</span></td>\r
+        <td colspan="1"><span wicket:id="groupCollapsible"></span><span wicket:id="groupName">[group name]</span></td>\r
         <td colspan="6" style="padding: 2px;"><span class="hidden-phone" style="font-weight:normal;color:#666;" wicket:id="groupDescription">[description]</span></td>\r
        </wicket:fragment>\r
                \r
index c3f07099d3265a6029343bbb0c742e1320bab7b2..aab602e5c75d847ef466a4e82f0bacf9a82a072a 100644 (file)
@@ -58,6 +58,25 @@ import com.gitblit.wicket.pages.UserPage;
 public class RepositoriesPanel extends BasePanel {\r
 \r
        private static final long serialVersionUID = 1L;\r
+       \r
+       private enum CollapsibleRepositorySetting {\r
+               DISABLED,\r
+\r
+               EXPANDED,\r
+\r
+               COLLAPSED;\r
+\r
+               public static CollapsibleRepositorySetting get(String name) {\r
+                       CollapsibleRepositorySetting returnVal = CollapsibleRepositorySetting.DISABLED;\r
+                       for (CollapsibleRepositorySetting setting : values()) {\r
+                               if (setting.name().equalsIgnoreCase(name)) {\r
+                                       returnVal = setting;\r
+                                       break;\r
+                               }\r
+                       }\r
+                       return returnVal;\r
+               }\r
+       }\r
 \r
        public RepositoriesPanel(String wicketId, final boolean showAdmin, final boolean showManagement,\r
                        List<RepositoryModel> models, boolean enableLinks,\r
@@ -66,6 +85,8 @@ public class RepositoriesPanel extends BasePanel {
 \r
                final boolean linksActive = enableLinks;\r
                final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true);\r
+               final String collapsibleRespositorySetting = app().settings().getString(Keys.web.collapsibleRepositoryGroups, null);\r
+               final CollapsibleRepositorySetting collapsibleRepoGroups = CollapsibleRepositorySetting.get(collapsibleRespositorySetting);\r
 \r
                final UserModel user = GitBlitWebSession.get().getUser();\r
 \r
@@ -160,6 +181,16 @@ public class RepositoriesPanel extends BasePanel {
                                        GroupRepositoryModel groupRow = (GroupRepositoryModel) entry;\r
                                        currGroupName = entry.name;\r
                                        Fragment row = new Fragment("rowContent", "groupRepositoryRow", this);\r
+                                       if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED) {\r
+                                               Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupMinusCollapsible", this);\r
+                                               row.add(groupCollapsible);\r
+                                       } else if(collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) {\r
+                                               Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupPlusCollapsible", this);\r
+                                               row.add(groupCollapsible);\r
+                                       } else {\r
+                                               Fragment groupCollapsible = new Fragment("groupCollapsible", "emptyFragment", this);\r
+                                               row.add(groupCollapsible);\r
+                                       }\r
                                        item.add(row);\r
 \r
                                        String name = groupRow.name;\r
@@ -174,7 +205,7 @@ public class RepositoriesPanel extends BasePanel {
                                                row.add(new LinkPanel("groupName", null, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name)));\r
                                                row.add(new Label("groupDescription", entry.description == null ? "":entry.description));\r
                                        }\r
-                                       WicketUtils.setCssClass(item, "group");\r
+                                       WicketUtils.setCssClass(item, "group collapsible");\r
                                        // reset counter so that first row is light background\r
                                        counter = 0;\r
                                        return;\r
@@ -319,6 +350,14 @@ public class RepositoriesPanel extends BasePanel {
                } else {\r
                        // not sortable\r
                        Fragment fragment = new Fragment("headerContent", "groupRepositoryHeader", this);\r
+                       if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED || \r
+                                       collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) {\r
+                               Fragment allCollapsible = new Fragment("allCollapsible", "tableAllCollapsible", this);\r
+                               fragment.add(allCollapsible);\r
+                       } else {\r
+                               Fragment allCollapsible = new Fragment("allCollapsible", "emptyFragment", this);\r
+                               fragment.add(allCollapsible);\r
+                       }\r
                        add(fragment);\r
                }\r
        }\r
diff --git a/src/main/resources/gitblit/js/collapsible-table.js b/src/main/resources/gitblit/js/collapsible-table.js
new file mode 100644 (file)
index 0000000..538b412
--- /dev/null
@@ -0,0 +1,32 @@
+$(function() {\r
+       $('i.table-group-collapsible')\r
+               .click(function(){\r
+                       $(this).closest('tr.group.collapsible').nextUntil('tr.group.collapsible').toggle();\r
+                       $(this).toggleClass('fa-minus-square-o');\r
+                       $(this).toggleClass('fa-plus-square-o');\r
+               });\r
+       \r
+       $('i.table-openall-collapsible')\r
+               .click(function(){\r
+                       $('tr.group.collapsible').first().find('i').addClass('fa-minus-square-o');\r
+                       $('tr.group.collapsible').first().find('i').removeClass('fa-plus-square-o');\r
+                       $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').show();\r
+                       $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-minus-square-o');\r
+                       $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-plus-square-o');\r
+               });\r
+       \r
+       $('i.table-closeall-collapsible')\r
+               .click(function(){\r
+                       $('tr.group.collapsible').first().find('i').addClass('fa-plus-square-o');\r
+                       $('tr.group.collapsible').first().find('i').removeClass('fa-minus-square-o');\r
+                       $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide();\r
+                       $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-plus-square-o');\r
+                       $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-minus-square-o');\r
+               });\r
+       \r
+       $( document ).ready(function() {\r
+               if($('tr.group.collapsible').first().find('i').hasClass('fa-plus-square-o')) {\r
+                       $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide();\r
+               }\r
+       });\r
+});
\ No newline at end of file