Skip to content

Commit

Permalink
Tempus-Dominus v6 is added (#1002)
Browse files Browse the repository at this point in the history
* Tempus-Dominus v6 is added

* Build should be fixed

* Code clean-up

* Consumers are added to config; Example page is improved

* Dates are being validated onChange

* Jar-based localization seems to be loaded

* OnChangeAjaxBehavior seems to work

* Code comment is added

* Validation errors are being displayed

* tempus-dominus-v5 is marked as deprecated; code clean-up

* Non bundled bootstrap 5.3.2 version is used

* Code related to OnChangeBehavior is simplified

* Comments are addressed
  • Loading branch information
solomax authored Oct 9, 2023
1 parent 52aaf3c commit a10a7f7
Show file tree
Hide file tree
Showing 34 changed files with 2,425 additions and 1,918 deletions.
4 changes: 4 additions & 0 deletions bootstrap-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>popperjs__core</artifactId>
</dependency>

<dependency>
<groupId>org.webjars</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package de.agilecoders.wicket.core.markup.html.references;

import java.util.List;

import org.apache.wicket.markup.head.HeaderItem;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;

import de.agilecoders.wicket.core.Bootstrap;
import de.agilecoders.wicket.core.util.Dependencies;
import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference;

/**
Expand Down Expand Up @@ -31,6 +38,12 @@ public static BootstrapJavaScriptReference instance() {
* Private constructor.
*/
private BootstrapJavaScriptReference() {
super("/bootstrap/current/js/bootstrap.bundle.js");
super("/bootstrap/current/js/bootstrap.js");
}

@Override
public List<HeaderItem> getDependencies() {
return Dependencies.combine(super.getDependencies(),
JavaScriptHeaderItem.forReference(Bootstrap.getSettings().getPopperJsResourceReference()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.agilecoders.wicket.core.markup.html.references;

import de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference;

/**
* Represents Popper.js library.
*/
public class PopperJavaScriptReference extends WebjarsJavaScriptResourceReference {
private static final long serialVersionUID = 1L;

/**
* Singleton instance of this reference
*/
private static final class Holder {
private static final PopperJavaScriptReference INSTANCE = new PopperJavaScriptReference();
}

/**
* Private constructor.
*/
private PopperJavaScriptReference() {
super("popperjs__core/current/dist/umd/popper.js");
}

/**
*
* @return the single instance of the resource reference
*/
public static PopperJavaScriptReference instance() {
return Holder.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import de.agilecoders.wicket.core.markup.html.references.BootstrapJavaScriptReference;
import de.agilecoders.wicket.core.markup.html.references.ModernizrJavaScriptReference;
import de.agilecoders.wicket.core.markup.html.references.PopperJavaScriptReference;
import de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssReference;
import de.agilecoders.wicket.core.markup.html.themes.bootstrap.BootstrapCssRtlReference;

Expand All @@ -25,12 +26,14 @@ private static final class Holder {
private static ResourceReference modernizrJavaScriptReference = ModernizrJavaScriptReference.instance();
private static ResourceReference bootstrapCssReference = BootstrapCssReference.instance();
private static ResourceReference bootstrapCssRtlReference = BootstrapCssRtlReference.instance();
private static ResourceReference popperJavaScriptReference = PopperJavaScriptReference.instance();
}

private ResourceReference bootstrapJavaScriptReference = null;
private ResourceReference modernizrJavaScriptReference = null;
private ResourceReference bootstrapCssReference = null;
private ResourceReference bootstrapCssRtlReference = null;
private ResourceReference popperJavaScriptReference = null;

private ThemeProvider themeProvider;
private ActiveThemeProvider activeThemeProvider;
Expand All @@ -42,6 +45,7 @@ private static final class Holder {
private boolean deferJavascript;
private String version = VERSION;
private String modernizrVersion = MODERNIZR_VERSION;
private String popperVersion = POPPER_VERSION;

/**
* Constructor.
Expand All @@ -68,6 +72,12 @@ public IBootstrapSettings setModernizrVersion(String version) {
return this;
}

@Override
public IBootstrapSettings setPopperJsVersion(String version) {
this.popperVersion = version;
return this;
}

@Override
public String getVersion() {
return version;
Expand All @@ -83,6 +93,11 @@ public String getModernizrVersion() {
return modernizrVersion;
}

@Override
public String getPopperJsVersion() {
return popperVersion;
}

@Override
public boolean autoAppendResources() {
return autoAppendResources;
Expand Down Expand Up @@ -135,6 +150,20 @@ public ResourceReference getModernizrResourceReference() {
return jsReference != null ? jsReference : Holder.modernizrJavaScriptReference;
}

@Override
public ResourceReference getPopperJsResourceReference() {
ResourceReference jsReference;

if (useCdnResources()) {
String cdnUrl = String.format(POPPER_JS_CDN_PATTERN, getPopperJsVersion());
jsReference = new UrlResourceReference(Url.parse(cdnUrl));
} else {
jsReference = popperJavaScriptReference;
}

return jsReference != null ? jsReference : Holder.popperJavaScriptReference;
}

@Override
public String getJsResourceFilterName() {
return resourceFilterName;
Expand Down Expand Up @@ -193,6 +222,12 @@ public BootstrapSettings setModernizrResourceReference(final ResourceReference m
return this;
}

@Override
public IBootstrapSettings setPopperJsResourceReference(final ResourceReference popperJsResourceReference) {
this.popperJavaScriptReference = popperJsResourceReference;
return this;
}

@Override
public IBootstrapSettings setUpdateSecurityManager(boolean activate) {
updateSecurityManager = activate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public interface IBootstrapSettings {
*/
String MODERNIZR_VERSION = "2.8.3";

/**
* The version of Popper.js
*/
String POPPER_VERSION = "2.11.8";

/**
* The url to the JavaScript resource at a CDN network
*/
Expand All @@ -41,6 +46,11 @@ public interface IBootstrapSettings {
*/
String CSS_RTL_CDN_PATTERN = "//stackpath.bootstrapcdn.com/bootstrap/%s/css/bootstrap.rtl.min.css";

/**
* The url to the Popper.js Javascript resource at a CDN network
*/
String POPPER_JS_CDN_PATTERN = "//unpkg.com/popper.js@%s/dist/umd/popper.min.js";

/**
* @param version The version of Bootstrap. CDN resources use it to construct their urls
* @return same instance for chaining
Expand All @@ -53,6 +63,12 @@ public interface IBootstrapSettings {
*/
IBootstrapSettings setModernizrVersion(String version);

/**
* @param version The version of popper.js. CDN resources use it to construct their urls
* @return same instance for chaining
*/
IBootstrapSettings setPopperJsVersion(String version);

/**
* @return the deferJavascript flag
*/
Expand All @@ -68,6 +84,11 @@ public interface IBootstrapSettings {
*/
String getModernizrVersion();

/**
* @return The version of popper.js. CDN resources use it to construct their urls
*/
String getPopperJsVersion();

/**
* @return True, if bootstrap resources should be added to each page automatically
*/
Expand All @@ -88,6 +109,11 @@ public interface IBootstrapSettings {
*/
ResourceReference getModernizrResourceReference();

/**
* @return the popper.js JavaScript resource reference
*/
ResourceReference getPopperJsResourceReference();

/**
* @param reference a reference to the base bootstrap css library.
* Defaults to the embedded bootstrap.css
Expand Down Expand Up @@ -116,6 +142,14 @@ public interface IBootstrapSettings {
*/
IBootstrapSettings setModernizrResourceReference(ResourceReference reference);

/**
*
* @param popperJsResourceReference a reference to the Popper.js library.
* Defaults to the embedded popper.js.
* @return same instance for chaining
*/
IBootstrapSettings setPopperJsResourceReference(ResourceReference popperJsResourceReference);

/**
* @return javascript resource filter name
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void cdnResources() {

CharSequence url = tester().getRequestCycle().urlFor(jsResourceReference, null);
assertThat(url.toString(), is(equalTo(
String.format("./wicket/resource/de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference/webjars/bootstrap/%s/js/bootstrap.bundle.js",
String.format("./wicket/resource/de.agilecoders.wicket.webjars.request.resource.WebjarsJavaScriptResourceReference/webjars/bootstrap/%s/js/bootstrap.js",
IBootstrapSettings.VERSION))));

settings.useCdnResources(true);
Expand Down
11 changes: 9 additions & 2 deletions bootstrap-extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
<font-awesome.version>6.4.2</font-awesome.version>
<momentjs.version>2.29.4</momentjs.version>
<bootstrap-select.version>1.14.0-beta3</bootstrap-select.version>
<tempusdominus.version>5.39.0</tempusdominus.version>
<tempusdominus4.version>5.39.0</tempusdominus4.version>
<tempusdominus.version>6.7.11</tempusdominus.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -55,7 +56,7 @@
<dependency>
<groupId>org.webjars</groupId>
<artifactId>tempusdominus-bootstrap-4</artifactId>
<version>${tempusdominus.version}</version>
<version>${tempusdominus4.version}</version>
</dependency>

<dependency>
Expand All @@ -64,6 +65,12 @@
<version>${momentjs.version}</version>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>eonasdan__tempus-dominus</artifactId>
<version>${tempusdominus.version}</version>
</dependency>

<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap-select</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @author Alexey Volkov
* @since 01.02.2015
*/
@Deprecated
public abstract class AbstractDateTimePickerWithIcon<T> extends FormComponentPanel<T> {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author Alexey Volkov
* @since 01.02.2015
*/
@Deprecated
public class DatetimePicker extends DateTextField {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @author Alexey Volkov
* @since 01.02.2015
*/
@Deprecated
public class DatetimePickerBehavior extends BootstrapJavascriptBehavior {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* @since 02.02.2015
* @see <a href="http://eonasdan.github.io/bootstrap-datetimepicker/Options/">JS widget options</a>
*/
@Deprecated
public class DatetimePickerConfig extends AbstractConfig {

public enum ViewModeType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @author Alexey Volkov
* @since 07.02.15
*/
@Deprecated
public class DatetimePickerIconConfig extends AbstractConfig {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @author Alexey Volkov
* @since 01.02.2015
*/
@Deprecated
public class LocalDateTimePicker extends LocalDateTimeTextField {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<wicket:panel xmlns:wicket="http://wicket.apache.org">
<input type="text" class="form-control" wicket:id="date"/>
<span class="input-group-text" wicket:id="iconContainer">
<i wicket:id="icon"></i>
</span>
</wicket:panel>
Loading

0 comments on commit a10a7f7

Please sign in to comment.