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 2019/03/04 15:17:44 UTC
[myfaces-tobago] branch tobago-4.x updated: TOBAGO-1957 go to today
button for tc:date
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 20e25f2 TOBAGO-1957 go to today button for tc:date
20e25f2 is described below
commit 20e25f22be279aaef17109f30215539b00b3e8ca
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Mon Mar 4 16:17:35 2019 +0100
TOBAGO-1957 go to today button for tc:date
* implement todayButton attribute
* improve demo
* add feature to new-in-*.xhtml files
---
.../java/org/apache/myfaces/tobago/component/Attributes.java | 1 +
.../myfaces/tobago/internal/component/AbstractUIDate.java | 2 ++
.../tobago/internal/renderkit/renderer/DateRenderer.java | 1 +
.../tobago/internal/taglib/component/DateTagDeclaration.java | 10 +++++++---
.../apache/myfaces/tobago/renderkit/html/DataAttributes.java | 2 ++
.../10-intro/30-whats-new/60-new-in-5-0/new-in-5-0.xhtml | 2 ++
.../10-intro/30-whats-new/66-new-in-4-4/new-in-4-4.xhtml | 1 +
.../webapp/content/20-component/010-input/40-date/date.xhtml | 6 ++++++
.../standard/tobago-bootstrap/_version/js/tobago-calendar.js | 1 +
9 files changed, 23 insertions(+), 3 deletions(-)
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 a09f300..dddc245 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
@@ -404,6 +404,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 b26725b..bd8811e 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
@@ -49,4 +49,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 172bce5..9a0d832 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
@@ -59,6 +59,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 121fbfe..9358122 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
@@ -19,9 +19,7 @@
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.UIComponentTag;
+import org.apache.myfaces.tobago.apt.annotation.*;
import org.apache.myfaces.tobago.component.ClientBehaviors;
import org.apache.myfaces.tobago.component.RendererTypes;
import org.apache.myfaces.tobago.internal.taglib.declaration.HasAccessKey;
@@ -81,4 +79,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/new-in-5-0.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/new-in-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/new-in-5-0.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/60-new-in-5-0/new-in-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/new-in-4-4.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/new-in-4-4.xhtml
index 5b4e68a..063702e 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/new-in-4-4.xhtml
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/30-whats-new/66-new-in-4-4/new-in-4-4.xhtml
@@ -35,6 +35,7 @@
<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>TODO</li>
<li>...</li>
<li>Bugfixes</li>
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 3eb3122..2f4beda 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/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
index 9249326..f6a1d2a 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-calendar.js
@@ -28,6 +28,7 @@ Tobago.DateTime.init = function (elements) {
var analyzed = Tobago.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',