myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] branch master updated: TOBAGO-1957 go to today button for tc:date
Date Mon, 11 Mar 2019 16:08:38 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 2a5feaf  TOBAGO-1957 go to today button for tc:date
2a5feaf is described below

commit 2a5feafa6592d2fdcbde612812b67142eaf04e75
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Mon Mar 11 17:08:14 2019 +0100

    TOBAGO-1957 go to today button for tc:date
    
    * implement todayButton attribute
    * improve demo
    * add feature to new-in-*.xhtml files
---
 .../main/java/org/apache/myfaces/tobago/component/Attributes.java | 1 +
 .../apache/myfaces/tobago/internal/component/AbstractUIDate.java  | 2 ++
 .../myfaces/tobago/internal/renderkit/renderer/DateRenderer.java  | 1 +
 .../tobago/internal/taglib/component/DateTagDeclaration.java      | 8 ++++++++
 .../org/apache/myfaces/tobago/renderkit/html/DataAttributes.java  | 2 ++
 .../content/10-intro/30-whats-new/60-new-in-5-0/Tobago_5.0.xhtml  | 2 ++
 .../content/10-intro/30-whats-new/66-new-in-4-4/Tobago_4.4.xhtml  | 2 ++
 .../main/webapp/content/20-component/010-input/40-date/Date.xhtml | 6 ++++++
 .../tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts      | 1 +
 9 files changed, 25 insertions(+)

diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
index f82355c..61cdce6 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/component/Attributes.java
@@ -405,6 +405,7 @@ public enum Attributes {
   timezone,
   title,
   tip,
+  todayButton,
   top,
   totalCount,
   transition,
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
index 6ccdfaf..0683da7 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUIDate.java
@@ -50,4 +50,6 @@ public abstract class AbstractUIDate extends AbstractUIInput {
     }
     return DateFormatUtils.findPattern((DateTimeConverter) converter);
   }
+
+  public abstract boolean isTodayButton();
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DateRenderer.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DateRenderer.java
index 91809fd..d46baba 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DateRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DateRenderer.java
@@ -60,6 +60,7 @@ public class DateRenderer extends InRenderer {
     writer.writeAttribute(DataAttributes.TODAY, sdf.format(new Date()), true);
     final DateTimeI18n dateTimeI18n = DateTimeI18n.valueOf(facesContext.getViewRoot().getLocale());
     writer.writeAttribute(DataAttributes.DATE_TIME_I18N, JsonUtils.encode(dateTimeI18n),
true);
+    writer.writeAttribute(DataAttributes.TODAY_BUTTON, date.isTodayButton());
   }
 
   @Override
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
index cfb280b..4901a69 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/DateTagDeclaration.java
@@ -21,7 +21,9 @@ package org.apache.myfaces.tobago.internal.taglib.component;
 
 import org.apache.myfaces.tobago.apt.annotation.Behavior;
 import org.apache.myfaces.tobago.apt.annotation.Tag;
+import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
 import org.apache.myfaces.tobago.apt.annotation.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
 import org.apache.myfaces.tobago.component.ClientBehaviors;
 import org.apache.myfaces.tobago.component.RendererTypes;
 import org.apache.myfaces.tobago.internal.taglib.declaration.HasAccessKey;
@@ -80,4 +82,10 @@ public interface DateTagDeclaration
     IsDisabled, HasConverter, HasLabel, HasHelp, HasLabelLayout,
     HasTip, IsRequired, HasPlaceholder {
 
+  /**
+   * If true, a today button is displayed on the datetimepicker.
+   */
+  @TagAttribute
+  @UIComponentTagAttribute(type = "boolean", defaultValue = "false")
+  void setTodayButton(String required);
 }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
index b1cd0a7..b78c536 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/DataAttributes.java
@@ -206,6 +206,8 @@ public enum DataAttributes implements MarkupLanguageAttributes {
 
   TODAY("data-tobago-today"),
 
+  TODAY_BUTTON("data-tobago-today-button"),
+
   TOGGLE("data-toggle"),
 
   TRANSITION("data-tobago-transition"),
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/Tobago_5.0.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/Tobago_5.0.xhtml
index 5110dca..692e334 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/Tobago_5.0.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/Tobago_5.0.xhtml
@@ -35,6 +35,8 @@
       <li>Refactoring: JavaScript -> TypeScript</li>
       <li>Refactoring: ResourceBunde and MessageBundle</li>
       <li>A context message can now be added to form-component.</li>
+      <li>Update to Bootstrap 4.3.1</li>
+      <li>tc:date todayButton</li>
       <li>...</li>
       <li>Bugfixes</li>
     </ul>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/Tobago_4.4.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/Tobago_4.4.xhtml
index 875e677..e837ba4 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/Tobago_4.4.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/Tobago_4.4.xhtml
@@ -33,6 +33,8 @@
 
     <ul>
       <li>A context message can now be added to form-component.</li>
+      <li>Update to Bootstrap 4.3.1</li>
+      <li>tc:date todayButton</li>
       <li>...</li>
       <li>Bugfixes</li>
     </ul>
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/Date.xhtml
b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/Date.xhtml
index 9b4f05b..6805b45 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/Date.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/20-component/010-input/40-date/Date.xhtml
@@ -150,6 +150,12 @@
         <f:convertDateTime pattern="dd.MM. - HH:mm" type="both"/>
       </tc:date>
     </tc:section>
+    <tc:section label="Today Button">
+      <p>Display a today button on the datepicker with the attribute <code>todayButton=true</code>.</p>
+      <tc:date id="dateTodayButton" label="Today Button" value="#{dateController.now}"
todayButton="true">
+        <f:convertDateTime pattern="dd.MM.yyyy"/>
+      </tc:date>
+    </tc:section>
   </tc:section>
   <tc:section label="Styles">
     <p>Styles can be set with the attributes <code>dateStyle</code> and
<code>timeStyle</code>.
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
index 01ae725..04a40e3 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-calendar.ts
@@ -28,6 +28,7 @@ Tobago4.DateTime.init = function (elements) {
         var analyzed = Tobago4.DateTime.analyzePattern($date.data("tobago-pattern"));
         var options = {
           format: analyzed,
+          showTodayButton: $date.data("tobago-today-button") === "data-tobago-today-button",
           icons: {
             time: 'fa fa-clock-o',
             date: 'fa fa-calendar',


Mime
View raw message