Skip to content

Commit 2da0d02

Browse files
committed
CAUSEWAY-3983: [v2] removes tab content when always hidden (backport)
1 parent 59dc7ae commit 2da0d02

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

api/applib/src/main/java/org/apache/causeway/applib/annotation/Where.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ public boolean inStandaloneTable() {
213213
|| this == ALL_TABLES;
214214
}
215215

216+
public boolean isObjectForms() {
217+
return this == OBJECT_FORMS;
218+
}
219+
216220
/**
217221
* Whether this <tt>Where</tt> is a superset of the context <tt>Where</tt> provided.
218222
*
@@ -225,5 +229,4 @@ public boolean includes(final Where context) {
225229
&& context.isAlways());
226230
}
227231

228-
229232
}

api/applib/src/main/java/org/apache/causeway/applib/layout/grid/bootstrap/BSGridTransformer.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.causeway.applib.layout.component.ActionLayoutData;
2626
import org.apache.causeway.applib.layout.component.CollectionLayoutData;
2727
import org.apache.causeway.applib.layout.component.DomainObjectLayoutData;
28+
import org.apache.causeway.applib.layout.component.HasHidden;
2829
import org.apache.causeway.applib.layout.component.PropertyLayoutData;
2930
import org.apache.causeway.applib.layout.grid.bootstrap.BSElement.BSElementVisitor;
3031
import org.apache.causeway.commons.internal.base._NullSafe;
@@ -48,19 +49,30 @@ public BSGrid apply(final BSGrid bsGrid) {
4849
// first phase: collect all empty tabs for removal
4950
bsGrid.visit(new BSElementVisitor() {
5051

51-
final Stack<Flag> stack = new Stack<Flag>();
52+
final Stack<Flag> stack = new Stack<>();
5253

5354
@Override public void visit(final ActionLayoutData actionLayoutData) {
54-
if(_NullSafe.isEmpty(actionLayoutData.getMetadataError())) keep();
55+
if(_NullSafe.isEmpty(actionLayoutData.getMetadataError())
56+
&& !isAlwaysHidden(actionLayoutData)) {
57+
keep();
58+
}
5559
}
5660
@Override public void visit(final DomainObjectLayoutData domainObjectLayoutData) {
57-
if(_NullSafe.isEmpty(domainObjectLayoutData.getMetadataError())) keep();
61+
if(_NullSafe.isEmpty(domainObjectLayoutData.getMetadataError())) {
62+
keep();
63+
}
5864
}
5965
@Override public void visit(final PropertyLayoutData propertyLayoutData) {
60-
if(_NullSafe.isEmpty(propertyLayoutData.getMetadataError())) keep();
66+
if(_NullSafe.isEmpty(propertyLayoutData.getMetadataError())
67+
&& !isAlwaysHidden(propertyLayoutData)) {
68+
keep();
69+
}
6170
}
6271
@Override public void visit(final CollectionLayoutData collectionLayoutData) {
63-
if(_NullSafe.isEmpty(collectionLayoutData.getMetadataError())) keep();
72+
if(_NullSafe.isEmpty(collectionLayoutData.getMetadataError())
73+
&& !isAlwaysHidden(collectionLayoutData)) {
74+
keep();
75+
}
6476
}
6577

6678
@Override public void enter(final BSTab bsTab) {
@@ -73,6 +85,11 @@ public BSGrid apply(final BSGrid bsGrid) {
7385
emptyTabs.add(bsTab);
7486
}
7587
}
88+
private boolean isAlwaysHidden(final HasHidden hasHidden) {
89+
if(hasHidden==null || hasHidden.getHidden()==null) return false;
90+
return hasHidden.getHidden().isAlways()
91+
|| hasHidden.getHidden().isObjectForms();
92+
}
7693
private void keep() {
7794
stack.stream().forEach(row->row.keep=true);
7895
}

0 commit comments

Comments
 (0)