myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From we...@apache.org
Subject [myfaces-tobago] 14/19: Tobago-1999: hide dropdown
Date Fri, 29 Nov 2019 15:46:05 GMT
This is an automated email from the ASF dual-hosted git repository.

weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 9ac2bfcb49f7518b005aa6da5801c372e98dd1fc
Author: Volker Weber <v.weber@inexso.de>
AuthorDate: Wed Sep 4 18:52:19 2019 +0200

    Tobago-1999: hide dropdown
---
 .../component/AbstractUISelectManyBox.java         | 12 ++++++++++
 .../component/AbstractUISelectOneChoice.java       |  1 +
 .../component/SelectManyBoxTagDeclaration.java     |  9 ++++++--
 .../content/25-select/00-select2/select2.xhtml     | 27 ++++++++++++++++++++++
 .../tobago/renderkit/html/Select2Options.java      | 19 +++++++++++++++
 .../html/standard/standard/style/tobago.css        |  9 ++++----
 6 files changed, 71 insertions(+), 6 deletions(-)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyBox.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyBox.java
index 5963567..21b7c9a 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyBox.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectManyBox.java
@@ -49,6 +49,18 @@ public abstract class AbstractUISelectManyBox extends AbstractUISelectMany
{
     getStateHelper().put(Select2Keys.allowCustom, allowCustom);
   }
 
+  public boolean isHideDropdown() {
+    Boolean hideDropdown = (Boolean) getStateHelper().eval(Select2Keys.hideDropdown);
+    if (hideDropdown != null) {
+      return hideDropdown;
+    }
+    return false;
+  }
+
+  public void setHideDropdown(boolean hideDropdown) {
+    getStateHelper().put(Select2Keys.hideDropdown, hideDropdown);
+  }
+
   public String getMatcher() {
     String matcher = (String) getStateHelper().eval(Select2Keys.matcher);
     if (matcher != null) {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
index 1faeafc..8555b95 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISelectOneChoice.java
@@ -24,6 +24,7 @@ public abstract class AbstractUISelectOneChoice extends AbstractUISelectOneBase
   enum Select2Keys {
     allowClear,
     allowCustom,
+    hideDropdown,
     isSelect2,
     language,
     matcher,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
index 9187f61..3ea22c0 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectManyBoxTagDeclaration.java
@@ -79,7 +79,6 @@ public interface SelectManyBoxTagDeclaration
 
   /**
    * A javascript callback that handles automatic tokenization of free-text entry.
-   * This is a select2 feature and will force select2=true
    */
   @TagAttribute()
   @UIComponentTagAttribute(generate = false)
@@ -87,9 +86,15 @@ public interface SelectManyBoxTagDeclaration
 
   /**
    * The list of characters that should be used as token separators.
-   * This is a select2 feature and will force select2=true
    */
   @TagAttribute()
   @UIComponentTagAttribute(generate = false)
   void setTokenSeparators(String tokenSeparators);
+
+  /**
+   * Hide the dropdown, this is only useful with allowCustom=true
+   */
+  @TagAttribute()
+  @UIComponentTagAttribute(type = "boolean", defaultValue = "false", generate = false)
+  void setHideDropdown(String hideDropdown);
 }
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
index 7dad3ba..e728e3a 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/25-select/00-select2/select2.xhtml
@@ -129,6 +129,33 @@
         </tc:selectManyBox>
 
       </tc:panel>
+      <tc:panel>
+        <f:facet name="layout">
+          <tc:gridLayout columns="400px;1*" rows="45px"/>
+        </f:facet>
+
+        <tc:label value="TokenSeparators ',', ' ', '-'" for="many_3"/>
+        <tc:selectManyBox id="many_3"
+                          placeholder="Custom input allowed"
+                          tokenSeparators=", -"
+                          allowCustom="true">
+        </tc:selectManyBox>
+
+      </tc:panel>
+      <tc:panel>
+        <f:facet name="layout">
+          <tc:gridLayout columns="400px;1*" rows="45px"/>
+        </f:facet>
+
+        <tc:label value="Hiden dropdown" for="many_4"/>
+        <tc:selectManyBox id="many_4"
+                          placeholder="Enter your values!"
+                          tokenSeparators=", -"
+                          allowCustom="true"
+                          hideDropdown="true">
+        </tc:selectManyBox>
+
+      </tc:panel>
     </tc:panel>
 
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
index 54122b1..2dfdc7e 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/Select2Options.java
@@ -29,6 +29,7 @@ public class Select2Options {
 
   private Boolean allowClear;
   private Boolean dropdownAutoWidth;
+  private Boolean hideDropdown;
   private String language;
   private String matcher;
   private Integer maximumInputLength;
@@ -103,6 +104,10 @@ public class Select2Options {
       options.setAllowClear(select.isAllowClear());
     }
 
+    if (select.isHideDropdown()) {
+      options.setHideDropdown(true);
+    }
+
     FacesContext facesContext = FacesContext.getCurrentInstance();
     if (facesContext != null) {
       options.setLanguage(facesContext.getViewRoot().getLocale().getLanguage());
@@ -170,6 +175,14 @@ public class Select2Options {
     this.allowClear = allowClear;
   }
 
+  public Boolean getHideDropdown() {
+    return hideDropdown;
+  }
+
+  public void setHideDropdown(Boolean hideDropdown) {
+    this.hideDropdown = hideDropdown;
+  }
+
   public String getLanguage() {
     return language;
   }
@@ -240,6 +253,11 @@ public class Select2Options {
     if (allowClear != null) {
       JsonUtils.encode(builder, "allowClear", allowClear);
     }
+
+    if (hideDropdown != null && hideDropdown) {
+      JsonUtils.encode(builder, "dropdownCssClass", "tobago-select2-hide-dropdown");
+    }
+
     if (language != null) {
       JsonUtils.encode(builder, "language", language);
     }
@@ -263,6 +281,7 @@ public class Select2Options {
     }
 
 
+
     if (builder.length() > 0 && builder.charAt(builder.length() - 1) == ',') {
       builder.deleteCharAt(builder.length() - 1);
     }
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
index 6d49612..fff9531 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
@@ -1,6 +1,7 @@
 /* select2 */
 
-/*.select2-container {*/
-  /*position: absolute;*/
-/*}*/
-
+.tobago-select2-hide-dropdown .select2-search,
+.tobago-select2-hide-dropdown .select2-results,
+.tobago-select2-hide-dropdown .select2-dropdown {
+  display: none;
+}


Mime
View raw message