You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/02/08 17:54:24 UTC

[isis] 02/02: ISIS-1861: adds 'collapseIfOne' atribute for TabGroups

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch maint-1.16.1
in repository https://gitbox.apache.org/repos/asf/isis.git

commit c24306a26485bf0345d57d5e48677d93b005c4df
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Thu Feb 8 17:54:01 2018 +0000

    ISIS-1861: adds 'collapseIfOne' atribute for TabGroups
---
 .../asciidoc/applib/layout/grid/bootstrap3/bootstrap3.xsd |  1 +
 .../isis/applib/layout/grid/bootstrap3/BS3TabGroup.java   | 15 +++++++++++++++
 .../viewer/wicket/ui/components/layout/bs3/col/Col.java   | 15 +++++++++------
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/applib/layout/grid/bootstrap3/bootstrap3.xsd b/adocs/documentation/src/main/asciidoc/applib/layout/grid/bootstrap3/bootstrap3.xsd
index f494e81..67b2f93 100644
--- a/adocs/documentation/src/main/asciidoc/applib/layout/grid/bootstrap3/bootstrap3.xsd
+++ b/adocs/documentation/src/main/asciidoc/applib/layout/grid/bootstrap3/bootstrap3.xsd
@@ -96,6 +96,7 @@
                     <xs:element maxOccurs="unbounded" minOccurs="0" name="tab" type="tns:tab"/>
                     <xs:element minOccurs="0" name="metadataError" type="xs:string"/>
                 </xs:sequence>
+                <xs:attribute name="collapseIfOne" type="xs:boolean"/>
                 <xs:attribute name="unreferencedCollections" type="xs:boolean"/>
             </xs:extension>
         </xs:complexContent>
diff --git a/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/BS3TabGroup.java b/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/BS3TabGroup.java
index 06e75a7..4ad42af 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/BS3TabGroup.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/layout/grid/bootstrap3/BS3TabGroup.java
@@ -65,6 +65,21 @@ public class BS3TabGroup extends BS3ElementAbstract implements BS3TabOwner {
 
 
 
+    private Boolean collapseIfOne;
+    /**
+     * If there is a single tab in the tabgroup, then whether to collapse and render without the outer tab.
+     */
+    @XmlAttribute(required = false)
+    public Boolean isCollapseIfOne() {
+        return collapseIfOne;
+    }
+
+    public void setCollapseIfOne(final Boolean collapseIfOne) {
+        this.collapseIfOne = collapseIfOne;
+    }
+
+
+
     private List<BS3Tab> tabs = Lists.newArrayList();
 
     // no wrapper; required=false because may be auto-generated
diff --git a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
index 0770f66..4c283b3 100644
--- a/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
+++ b/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/components/layout/bs3/col/Col.java
@@ -203,12 +203,15 @@ public class Col extends PanelAbstract<EntityModel> implements HasDynamicallyVis
                     // shouldn't occur; previously have filtered these out
                     throw new IllegalStateException("Cannot render tabGroup with no tabs");
                 case 1:
-                    final BS3Tab bs3Tab = tabs.get(0);
-                    // render the rows of the one-and-only tab of this tab group.
-                    final List<BS3Row> tabRows = bs3Tab.getRows();
-                    final RepeatingViewWithDynamicallyVisibleContent rowsRv = buildRows(id, tabRows);
-                    tabGroupRv.add(rowsRv);
-                    break;
+                    if(bs3TabGroup.isCollapseIfOne() == null || bs3TabGroup.isCollapseIfOne()) {
+                        final BS3Tab bs3Tab = tabs.get(0);
+                        // render the rows of the one-and-only tab of this tab group.
+                        final List<BS3Row> tabRows = bs3Tab.getRows();
+                        final RepeatingViewWithDynamicallyVisibleContent rowsRv = buildRows(id, tabRows);
+                        tabGroupRv.add(rowsRv);
+                        break;
+                    }
+                    // else fall through...
                 default:
                     final WebMarkupContainer tabGroup = new TabGroupPanel(id, getModel(), bs3TabGroup);
 

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.