myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch tobago-4.x updated: TOBAGO-2002 GridLayout: behavior of 'auto' is the same as '*'
Date Thu, 22 Aug 2019 14:54:04 GMT
This is an automated email from the ASF dual-hosted git repository.

hnoeth pushed a commit to branch tobago-4.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/tobago-4.x by this push:
     new 4f0d800  TOBAGO-2002 GridLayout: behavior of 'auto' is the same as '*'
4f0d800 is described below

commit 4f0d80063abe204adba041cda60ab04aee6484b8
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Thu Aug 22 16:53:47 2019 +0200

    TOBAGO-2002 GridLayout: behavior of 'auto' is the same as '*'
    
    * a hidden '1fr' is added to grid layout column if there is an 'auto'
      value without a 'fr' value
    * test added
    * getter for stream of measureList added
---
 .../renderkit/renderer/GridLayoutRenderer.java     | 12 ++++++++
 .../apache/myfaces/tobago/layout/MeasureList.java  |  5 ++++
 .../100-auto-column/auto-column.test.js            | 26 ++++++++++++++++++
 .../100-auto-column/auto-column.xhtml              | 32 ++++++++++++++++++++++
 4 files changed, 75 insertions(+)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/GridLayoutRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/GridLayoutRenderer.java
index ecfa366..f0fc7b0 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/GridLayoutRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/GridLayoutRenderer.java
@@ -25,6 +25,7 @@ import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.internal.component.AbstractUIGridLayout;
 import org.apache.myfaces.tobago.internal.component.AbstractUIStyle;
 import org.apache.myfaces.tobago.internal.util.JsonUtils;
+import org.apache.myfaces.tobago.layout.Measure;
 import org.apache.myfaces.tobago.layout.MeasureList;
 import org.apache.myfaces.tobago.renderkit.RendererBase;
 import org.apache.myfaces.tobago.renderkit.css.TobagoClass;
@@ -62,6 +63,17 @@ public class GridLayoutRenderer extends RendererBase {
         facesContext, Tags.style.componentType(), RendererTypes.Style.name());
     style.setTransient(true);
 
+    /*
+     * If the column attribute contains and 'auto' value but not an 'fr' value,
+     * the behavior of the 'auto' value is the same as a 'fr' value.
+     * So if there is only an 'auto' value we add a hidden 'fr' value.
+     * https://issues.apache.org/jira/browse/TOBAGO-2002
+     */
+    if (columns.stream().anyMatch(measure -> Measure.Unit.AUTO.equals(measure.getUnit()))
+        && columns.stream().noneMatch(measure -> Measure.Unit.FR.equals(measure.getUnit())))
{
+      columns.add(new Measure(1, Measure.Unit.FR));
+    }
+
     style.setGridTemplateColumns(columns.serialize());
     style.setGridTemplateRows(rows.serialize());
     gridLayout.getChildren().add(style);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/MeasureList.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/MeasureList.java
index fa1b0ae..468c1bb 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/MeasureList.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/layout/MeasureList.java
@@ -24,6 +24,7 @@ import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
+import java.util.stream.Stream;
 
 public class MeasureList implements Iterable<Measure>, Serializable {
 
@@ -37,6 +38,10 @@ public class MeasureList implements Iterable<Measure>, Serializable
{
     return list.iterator();
   }
 
+  public Stream<Measure> stream() {
+    return list.stream();
+  }
+
   public static MeasureList parse(final String string) {
     final MeasureList measureList = new MeasureList();
     final StringTokenizer tokenizer = new StringTokenizer(string, "; ");
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.test.js
b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.test.js
new file mode 100644
index 0000000..e0816c6
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.test.js
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+QUnit.test("test width of grid layout and 'auto' button", function (assert) {
+  assert.expect(2);
+
+  var gridLayoutFn = jQueryFrameFn("#page\\:mainForm\\:grid");
+  var buttonAutoFn = jQueryFrameFn("#page\\:mainForm\\:buttonAuto");
+
+  assert.equal(gridLayoutFn().width(), 358);
+  assert.ok(buttonAutoFn().width() < 33);
+});
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.xhtml
new file mode 100644
index 0000000..a8d154e
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/40-test/4600-gridLayout/100-auto-column/auto-column.xhtml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+-->
+
+<ui:composition template="/main.xhtml"
+                xmlns="http://www.w3.org/1999/xhtml"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="http://java.sun.com/jsf/facelets">
+  <tc:box label="'auto' value">
+    <tc:style width="400px"/>
+    <p>Grid Layout - column with 'auto' but without '*'</p>
+    <tc:gridLayout id="grid" columns="100px auto">
+      <tc:button id="button100Px" label="100px"/>
+      <tc:button id="buttonAuto" label="auto"/>
+    </tc:gridLayout>
+  </tc:box>
+</ui:composition>


Mime
View raw message