From: ybosy Date: Fri, 7 Apr 2017 08:46:35 +0000 (+0200) Subject: collapsible group repositories X-Git-Tag: r1.9.0~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=150ff287d220b93092e689c887a64b00a21a2693;p=gitblit.git collapsible group repositories --- diff --git a/src/main/distrib/data/defaults.properties b/src/main/distrib/data/defaults.properties index 9c597903..bada3350 100644 --- a/src/main/distrib/data/defaults.properties +++ b/src/main/distrib/data/defaults.properties @@ -2154,3 +2154,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 diff --git a/src/main/java/com/gitblit/wicket/pages/BasePage.html b/src/main/java/com/gitblit/wicket/pages/BasePage.html index 4dbc2e57..49810ddc 100644 --- a/src/main/java/com/gitblit/wicket/pages/BasePage.html +++ b/src/main/java/com/gitblit/wicket/pages/BasePage.html @@ -51,7 +51,8 @@ - + + \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html index 2de52b09..7c3b3082 100644 --- a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html +++ b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.html @@ -18,6 +18,9 @@ + + + @@ -72,9 +75,15 @@ + + + + + + Repository @@ -86,8 +95,16 @@ + + + + + + + + - [group name] + [group name] [description] diff --git a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java index c3f07099..aab602e5 100644 --- a/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/RepositoriesPanel.java @@ -58,6 +58,25 @@ import com.gitblit.wicket.pages.UserPage; public class RepositoriesPanel extends BasePanel { private static final long serialVersionUID = 1L; + + private enum CollapsibleRepositorySetting { + DISABLED, + + EXPANDED, + + COLLAPSED; + + public static CollapsibleRepositorySetting get(String name) { + CollapsibleRepositorySetting returnVal = CollapsibleRepositorySetting.DISABLED; + for (CollapsibleRepositorySetting setting : values()) { + if (setting.name().equalsIgnoreCase(name)) { + returnVal = setting; + break; + } + } + return returnVal; + } + } public RepositoriesPanel(String wicketId, final boolean showAdmin, final boolean showManagement, List models, boolean enableLinks, @@ -66,6 +85,8 @@ public class RepositoriesPanel extends BasePanel { final boolean linksActive = enableLinks; final boolean showSize = app().settings().getBoolean(Keys.web.showRepositorySizes, true); + final String collapsibleRespositorySetting = app().settings().getString(Keys.web.collapsibleRepositoryGroups, null); + final CollapsibleRepositorySetting collapsibleRepoGroups = CollapsibleRepositorySetting.get(collapsibleRespositorySetting); final UserModel user = GitBlitWebSession.get().getUser(); @@ -160,6 +181,16 @@ public class RepositoriesPanel extends BasePanel { GroupRepositoryModel groupRow = (GroupRepositoryModel) entry; currGroupName = entry.name; Fragment row = new Fragment("rowContent", "groupRepositoryRow", this); + if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED) { + Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupMinusCollapsible", this); + row.add(groupCollapsible); + } else if(collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) { + Fragment groupCollapsible = new Fragment("groupCollapsible", "tableGroupPlusCollapsible", this); + row.add(groupCollapsible); + } else { + Fragment groupCollapsible = new Fragment("groupCollapsible", "emptyFragment", this); + row.add(groupCollapsible); + } item.add(row); String name = groupRow.name; @@ -174,7 +205,7 @@ public class RepositoriesPanel extends BasePanel { row.add(new LinkPanel("groupName", null, groupRow.toString(), ProjectPage.class, WicketUtils.newProjectParameter(entry.name))); row.add(new Label("groupDescription", entry.description == null ? "":entry.description)); } - WicketUtils.setCssClass(item, "group"); + WicketUtils.setCssClass(item, "group collapsible"); // reset counter so that first row is light background counter = 0; return; @@ -319,6 +350,14 @@ public class RepositoriesPanel extends BasePanel { } else { // not sortable Fragment fragment = new Fragment("headerContent", "groupRepositoryHeader", this); + if(collapsibleRepoGroups == CollapsibleRepositorySetting.EXPANDED || + collapsibleRepoGroups == CollapsibleRepositorySetting.COLLAPSED) { + Fragment allCollapsible = new Fragment("allCollapsible", "tableAllCollapsible", this); + fragment.add(allCollapsible); + } else { + Fragment allCollapsible = new Fragment("allCollapsible", "emptyFragment", this); + fragment.add(allCollapsible); + } add(fragment); } } diff --git a/src/main/resources/gitblit/js/collapsible-table.js b/src/main/resources/gitblit/js/collapsible-table.js new file mode 100644 index 00000000..538b412e --- /dev/null +++ b/src/main/resources/gitblit/js/collapsible-table.js @@ -0,0 +1,32 @@ +$(function() { + $('i.table-group-collapsible') + .click(function(){ + $(this).closest('tr.group.collapsible').nextUntil('tr.group.collapsible').toggle(); + $(this).toggleClass('fa-minus-square-o'); + $(this).toggleClass('fa-plus-square-o'); + }); + + $('i.table-openall-collapsible') + .click(function(){ + $('tr.group.collapsible').first().find('i').addClass('fa-minus-square-o'); + $('tr.group.collapsible').first().find('i').removeClass('fa-plus-square-o'); + $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').show(); + $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-minus-square-o'); + $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-plus-square-o'); + }); + + $('i.table-closeall-collapsible') + .click(function(){ + $('tr.group.collapsible').first().find('i').addClass('fa-plus-square-o'); + $('tr.group.collapsible').first().find('i').removeClass('fa-minus-square-o'); + $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide(); + $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').addClass('fa-plus-square-o'); + $('tr.group.collapsible').first().nextAll('tr.group.collapsible').find('i').removeClass('fa-minus-square-o'); + }); + + $( document ).ready(function() { + if($('tr.group.collapsible').first().find('i').hasClass('fa-plus-square-o')) { + $('tr.group.collapsible').first().nextAll('tr:not(tr.group.collapsible)').hide(); + } + }); +}); \ No newline at end of file