You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2022/07/25 14:28:31 UTC

[myfaces-tobago] branch tobago-5.x updated (9e69b03a53 -> ca99e1e151)

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

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


    from 9e69b03a53 Merge pull request #2960 from lofwyr14/tobago-5.x-release-5.2.0
     new 033f63da41 fix: input group with tc:suggest
     new ca99e1e151 build(theme): rebuild after fixing suggest input group

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../tobago-example-demo/package-lock.json          |  2 +-
 .../1025-suggest-group/Suggest_Input_Group.test.js | 92 ++++++++++++++++++++++
 .../Suggest_Input_Group.xhtml}                     | 33 ++++----
 tobago-theme/package-lock.json                     |  2 +-
 .../tobago-theme-standard/src/main/js/tobago.js    |  4 +-
 .../src/main/js/tobago.js.map                      |  2 +-
 .../src/main/ts/tobago-suggest.ts                  | 13 ++-
 7 files changed, 125 insertions(+), 23 deletions(-)
 create mode 100644 tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.test.js
 copy tobago-example/tobago-example-demo/src/main/webapp/content/900-test/{4800-labelLayout/300-label-input-spacing/Label_Input_Spacing.xhtml => 1025-suggest-group/Suggest_Input_Group.xhtml} (60%)


[myfaces-tobago] 01/02: fix: input group with tc:suggest

Posted by hn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 033f63da419a35c11ae34b421909a5be2c525479
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Jul 25 16:14:58 2022 +0200

    fix: input group with tc:suggest
    
    * CSS style is now correct applied (rounded corners for input group)
    * add test
    
    Issue: TOBAGO-2150
---
 .../1025-suggest-group/Suggest_Input_Group.test.js | 92 ++++++++++++++++++++++
 .../1025-suggest-group/Suggest_Input_Group.xhtml   | 48 +++++++++++
 .../src/main/ts/tobago-suggest.ts                  | 13 ++-
 3 files changed, 151 insertions(+), 2 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.test.js b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.test.js
new file mode 100644
index 0000000000..3bc9821459
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.test.js
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+import {elementByIdFn, querySelectorFn} from "/script/tobago-test.js";
+import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js";
+
+it("before input group", function (done) {
+  const inputGroupTextFn = querySelectorFn("#page\\:mainForm\\:beforeInputGroup .input-group-text");
+  const inputFn = elementByIdFn("page:mainForm:beforeInputGroup::field");
+
+  const test = new JasmineTestTool(done);
+  test.do(() => expect(getTopLeftRadius(inputGroupTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomLeftRadius(inputGroupTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopRightRadius(inputGroupTextFn())).toBe(0));
+  test.do(() => expect(getBottomRightRadius(inputGroupTextFn())).toBe(0));
+
+  test.do(() => expect(getTopRightRadius(inputFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomRightRadius(inputFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopLeftRadius(inputFn())).toBe(0));
+  test.do(() => expect(getBottomLeftRadius(inputFn())).toBe(0));
+  test.start();
+});
+
+it("after input group", function (done) {
+  const inputFn = elementByIdFn("page:mainForm:afterInputGroup::field");
+  const inputGroupTextFn = querySelectorFn("#page\\:mainForm\\:afterInputGroup .input-group-text");
+
+  const test = new JasmineTestTool(done);
+  test.do(() => expect(getTopLeftRadius(inputFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomLeftRadius(inputFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopRightRadius(inputFn())).toBe(0));
+  test.do(() => expect(getBottomRightRadius(inputFn())).toBe(0));
+
+  test.do(() => expect(getTopRightRadius(inputGroupTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomRightRadius(inputGroupTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopLeftRadius(inputGroupTextFn())).toBe(0));
+  test.do(() => expect(getBottomLeftRadius(inputGroupTextFn())).toBe(0));
+  test.start();
+});
+
+it("before and after input group", function (done) {
+  const beforeTextFn = querySelectorFn("#page\\:mainForm\\:bothInputGroup .input-group-text:first-child");
+  const inputFn = elementByIdFn("page:mainForm:bothInputGroup::field");
+  const afterTextFn = querySelectorFn("#page\\:mainForm\\:bothInputGroup .input-group-text:last-child");
+
+  const test = new JasmineTestTool(done);
+  test.do(() => expect(getTopLeftRadius(beforeTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomLeftRadius(beforeTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopRightRadius(beforeTextFn())).toBe(0));
+  test.do(() => expect(getBottomRightRadius(beforeTextFn())).toBe(0));
+
+  test.do(() => expect(getTopLeftRadius(inputFn())).toBe(0));
+  test.do(() => expect(getTopRightRadius(inputFn())).toBe(0));
+  test.do(() => expect(getBottomLeftRadius(inputFn())).toBe(0));
+  test.do(() => expect(getBottomRightRadius(inputFn())).toBe(0));
+
+  test.do(() => expect(getTopRightRadius(afterTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getBottomRightRadius(afterTextFn())).toBeGreaterThan(0));
+  test.do(() => expect(getTopLeftRadius(afterTextFn())).toBe(0));
+  test.do(() => expect(getBottomLeftRadius(afterTextFn())).toBe(0));
+  test.start();
+});
+
+function getTopLeftRadius($element) {
+  return parseInt(getComputedStyle($element).borderTopLeftRadius);
+}
+
+function getTopRightRadius($element) {
+  return parseInt(getComputedStyle($element).borderTopRightRadius);
+}
+
+function getBottomLeftRadius($element) {
+  return parseInt(getComputedStyle($element).borderBottomLeftRadius);
+}
+
+function getBottomRightRadius($element) {
+  return parseInt(getComputedStyle($element).borderBottomRightRadius);
+}
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.xhtml
new file mode 100644
index 0000000000..3b1b8ee28e
--- /dev/null
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/900-test/1025-suggest-group/Suggest_Input_Group.xhtml
@@ -0,0 +1,48 @@
+<?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:f="http://xmlns.jcp.org/jsf/core"
+                xmlns:tc="http://myfaces.apache.org/tobago/component"
+                xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
+  <ui:param name="title" value="Test quotation mark in suggest results"/>
+  <tc:section label="Suggest Input Group">
+    <p>The input groups should have rounded corners.</p>
+    <tc:in id="beforeInputGroup">
+      <f:facet name="before">before</f:facet>
+      <tc:suggest totalCount="10" query="#{suggestQuotMarkController.query}">
+        <tc:selectItems value="#{suggestController.solarObjects}" var="name" itemValue="#{name}"/>
+      </tc:suggest>
+    </tc:in>
+    <tc:in id="afterInputGroup">
+      <f:facet name="after">after</f:facet>
+      <tc:suggest totalCount="10" query="#{suggestQuotMarkController.query}">
+        <tc:selectItems value="#{suggestController.solarObjects}" var="name" itemValue="#{name}"/>
+      </tc:suggest>
+    </tc:in>
+    <tc:in id="bothInputGroup">
+      <f:facet name="before">before</f:facet>
+      <f:facet name="after">after</f:facet>
+      <tc:suggest totalCount="10" query="#{suggestQuotMarkController.query}">
+        <tc:selectItems value="#{suggestController.solarObjects}" var="name" itemValue="#{name}"/>
+      </tc:suggest>
+    </tc:in>
+  </tc:section>
+</ui:composition>
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-suggest.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-suggest.ts
index 28b68e718f..2a55b517f5 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-suggest.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-suggest.ts
@@ -37,7 +37,12 @@ export class Suggest {
     this.registerAjaxListener();
     this.base.classList.add("autocomplete");
     this.suggestInput.classList.add("autocomplete-input");
-    this.suggestInput.insertAdjacentHTML("beforebegin", "<div class=\"autocomplete-pseudo-container\"></div>");
+
+    if (this.isInputGroup && this.suggestInput.previousElementSibling === null) {
+      this.suggestInput.insertAdjacentHTML("afterend", "<div class=\"autocomplete-pseudo-container\"></div>");
+    } else {
+      this.suggestInput.insertAdjacentHTML("beforebegin", "<div class=\"autocomplete-pseudo-container\"></div>");
+    }
     this.suggestInput.insertAdjacentHTML("afterend", "<ul class=\"autocomplete-result-list\"></ul>");
 
     const options = {
@@ -140,7 +145,7 @@ export class Suggest {
       this.resultList.style.left = `${suggestInputRect.left}px`;
       if (this.resultListPosition === "below") {
         this.resultList.style.marginTop =
-            `${window.scrollY + suggestInputRect.top + suggestInputRect.height + space}px`;
+          `${window.scrollY + suggestInputRect.top + suggestInputRect.height + space}px`;
         this.resultList.style.marginBottom = null;
       } else if (this.resultListPosition === "above") {
         this.resultList.style.marginTop = null;
@@ -224,4 +229,8 @@ export class Suggest {
   private get filter(): SuggestFilter {
     return SuggestFilter[this.suggest.getAttribute("filter")] as SuggestFilter;
   }
+
+  private get isInputGroup(): boolean {
+    return this.suggestInput.parentElement.classList.contains("input-group");
+  }
 }


[myfaces-tobago] 02/02: build(theme): rebuild after fixing suggest input group

Posted by hn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ca99e1e1512e5725de3844febad8b6ecaa098b09
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Jul 25 16:16:26 2022 +0200

    build(theme): rebuild after fixing suggest input group
---
 tobago-example/tobago-example-demo/package-lock.json         | 2 +-
 tobago-theme/package-lock.json                               | 2 +-
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js     | 4 ++--
 tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tobago-example/tobago-example-demo/package-lock.json b/tobago-example/tobago-example-demo/package-lock.json
index cf43d4a8a1..44953743c3 100644
--- a/tobago-example/tobago-example-demo/package-lock.json
+++ b/tobago-example/tobago-example-demo/package-lock.json
@@ -6,7 +6,7 @@
   "packages": {
     "": {
       "name": "tobago-example-demo",
-      "version": "5.1.0-SNAPSHOT",
+      "version": "5.2.1-SNAPSHOT",
       "license": "Apache-2.0",
       "dependencies": {
         "font-awesome": "4.7.0",
diff --git a/tobago-theme/package-lock.json b/tobago-theme/package-lock.json
index 51a53490ad..1a02783681 100644
--- a/tobago-theme/package-lock.json
+++ b/tobago-theme/package-lock.json
@@ -6,7 +6,7 @@
   "packages": {
     "": {
       "name": "tobago-theme",
-      "version": "5.1.1-SNAPSHOT",
+      "version": "5.2.1-SNAPSHOT",
       "license": "Apache-2.0",
       "dependencies": {
         "@trevoreyre/autocomplete-js": "^2.2.0",
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
index f5a7b177ba..35d34abceb 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js
@@ -1,8 +1,8 @@
-!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";class e extends HTMLElement{constructor(){super(),this.CssClass={SHOW:"show",COLLAPSE:"collapse",COLLAPSING:"collapsing"},this.toggleButton.addEventListener("click",this.toggleCollapse.bind(this))}connectedCallback(){this.expanded="true"===this.toggleButton.ariaExpanded}toggleCollapse(e){window.clearTimeout(this.timeout),this.expanded?(this.expanded=!1,this.navbarContent.style.height=`${this.navbar [...]
+!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";class e extends HTMLElement{constructor(){super(),this.CssClass={SHOW:"show",COLLAPSE:"collapse",COLLAPSING:"collapsing"},this.toggleButton.addEventListener("click",this.toggleCollapse.bind(this))}connectedCallback(){this.expanded="true"===this.toggleButton.ariaExpanded}toggleCollapse(e){window.clearTimeout(this.timeout),this.expanded?(this.expanded=!1,this.navbarContent.style.height=`${this.navbar [...]
 /*!
     * Bootstrap v5.1.3 (https://getbootstrap.com/)
     * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
     * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
     */
-const Ne="transitionend",De=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},Re=e=>{const t=De(e);return t&&document.querySelector(t)?t:null},Me=e=>{const t=De(e);return t?document.querySelector(t):null},je=e=>{e.dispatchEvent(new Event(Ne))},He=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
+const Ne="transitionend",De=e=>{let t=e.getAttribute("data-bs-target");if(!t||"#"===t){let s=e.getAttribute("href");if(!s||!s.includes("#")&&!s.startsWith("."))return null;s.includes("#")&&!s.startsWith("#")&&(s=`#${s.split("#")[1]}`),t=s&&"#"!==s?s.trim():null}return t},Re=e=>{const t=De(e);return t&&document.querySelector(t)?t:null},Me=e=>{const t=De(e);return t?document.querySelector(t):null},je=e=>{e.dispatchEvent(new Event(Ne))},He=e=>!(!e||"object"!=typeof e)&&(void 0!==e.jquery&&( [...]
 //# sourceMappingURL=tobago.js.map
diff --git a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
index a6c47a5dab..836466fa43 100644
--- a/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
+++ b/tobago-theme/tobago-theme-standard/src/main/js/tobago.js.map
@@ -1 +1 @@
-{"version":3,"file":"tobago.js","sources":["../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js","../../../../node_m [...]
\ No newline at end of file
+{"version":3,"file":"tobago.js","sources":["../ts/tobago-bar.ts","../../../../node_modules/@popperjs/core/lib/enums.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../../../../node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../../../../node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../../../../node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../../../../node_modules/@popperjs/core/lib/utils/getBasePlacement.js","../../../../node_m [...]
\ No newline at end of file