Skip to content

Commit 9a08aac

Browse files
committed
feat: set initial implementation
1 parent 9bebc0e commit 9a08aac

28 files changed

+2393
-84
lines changed

README.md

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/template-add-on)
2-
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/template-add-on.svg)](https://vaadin.com/directory/component/template-add-on)
3-
[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/template-addon)
4-
[![Maven Central](https://img.shields.io/maven-central/v/com.flowingcode.vaadin.addons/template-addon)](https://mvnrepository.com/artifact/com.flowingcode.vaadin.addons/template-addon)
5-
[![Javadoc](https://img.shields.io/badge/javadoc-00b4f0)](https://javadoc.flowingcode.com/artifact/com.flowingcode.vaadin.addons/template-addon)
1+
[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/date-time-range-picker-add-on)
2+
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/template-add-on.svg)](https://vaadin.com/directory/component/date-time-range-picker-add-on)
3+
[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/date-time-range-picker-addon)
4+
[![Maven Central](https://img.shields.io/maven-central/v/com.flowingcode.vaadin.addons/template-addon)](https://mvnrepository.com/artifact/com.flowingcode.vaadin.addons/date-time-range-picker-addon)
5+
[![Javadoc](https://img.shields.io/badge/javadoc-00b4f0)](https://javadoc.flowingcode.com/artifact/com.flowingcode.vaadin.addons/date-time-range-picker-addon)
66

7-
# Template Add-on
7+
# DateTimeRangePicker Add-on for Vaadin 24
88

9-
This is a template project for building new Vaadin 24 add-ons
9+
A component to create [Time Intervals](https://en.wikipedia.org/wiki/ISO_8601#Time_intervals) (_a time period defined by start and end points_) constrained by a time frame.
1010

11-
## Features
11+
You use the UI to define time and date ranges in which the time intervals should be created, and then call the API to operate them.
12+
13+
As an example, you could set it to create an interval **every weekend** from **8:30 to 12:30 AM** between the
14+
**1st and 15th of May 2025**.<br>Then, you can make the following queries:
1215

13-
* List the features of your add-on in here
16+
1. How many intervals will be created? (4)
17+
2. Starting from today, when will the next interval occur?
18+
3. Is the 7th of May at 9:15 AM included in any interval? (It's not)
19+
- How about the 5th of May at 9:00 AM? (Yes)
20+
4. How many intervals will have passed after the 9th of May? (2)
21+
5. How many intervals will remain after the 5th of May at 12:45? (3)
22+
23+
... and more
24+
25+
## Features
26+
- Customizable selection of date, time and days.
27+
- API to create and query time intervals.
1428

1529
## Online demo
1630

17-
[Online demo here](http://addonsv24.flowingcode.com/template)
31+
[Online demo here](http://addonsv24.flowingcode.com/date-time-range-picker)
1832

1933
## Download release
2034

21-
[Available in Vaadin Directory](https://vaadin.com/directory/component/template-add-on)
35+
[Available in Vaadin Directory](https://vaadin.com/directory/component/date-time-range-picker-add-on)
2236

2337
### Maven install
2438

@@ -27,7 +41,7 @@ Add the following dependencies in your pom.xml file:
2741
```xml
2842
<dependency>
2943
<groupId>com.flowingcode.vaadin.addons</groupId>
30-
<artifactId>template-addon</artifactId>
44+
<artifactId>date-time-range-picker-addon</artifactId>
3145
<version>X.Y.Z</version>
3246
</dependency>
3347
```
@@ -44,7 +58,7 @@ To see the demo, navigate to http://localhost:8080/
4458

4559
## Release notes
4660

47-
See [here](https://github.com/FlowingCode/TemplateAddon/releases)
61+
See [here](https://github.com/FlowingCode/date-time-range-picker-addon/releases)
4862

4963
## Issue tracking
5064

@@ -69,13 +83,65 @@ Then, follow these steps for creating a contribution:
6983

7084
This add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.
7185

72-
TEMPLATE_ADDON is written by Flowing Code S.A.
86+
DateTimeRangePicker is written by Flowing Code S.A.
7387

7488
# Developer Guide
7589

7690
## Getting started
7791

78-
Add your code samples in this section
92+
```
93+
DateTimeRangePicker addon = new DateTimeRangePicker(); (1)
94+
addon.setMinDate(LocalDate.now()); (2)
95+
addon.setMaxDate(LocalDate.now().plusDays(15)); (2)
96+
addon.setWeekDays(DayOfWeek.MONDAY, DayOfWeek.FRIDAY); (3)
97+
```
98+
- (1) Instantiation.
99+
- (2) Date range selection will be constraint between **today** and **fifteen** days later.
100+
- (3) Component will have **Monday** and **Friday** selected by default.
101+
102+
## Binding
103+
104+
The API is exposed through the **DateTimeRange** class.
105+
106+
```
107+
DateTimeRangePicker addon = new DateTimeRangePicker();
108+
Binder<Pojo> binder = new Binder<>(Pojo.class); (1)
109+
binder.forField(addon).bind(Pojo::getDateTimeRange, Pojo::setDateTimeRange); (2)
110+
binder.setBean(pojo); (3)
111+
```
112+
- (1) The **Pojo** class is binded using its getter and setter methods (2).
113+
- (2) The **DateTimeRangePicker** is binded. Its [value](https://vaadin.com/api/platform/current/com/vaadin/flow/component/HasValue.html) can be operated now.
114+
- (3) The **DateTimeRange** instance is saved in the **Pojo** class or returned from it.
115+
116+
117+
You can operate time intervals with the **DateTimeRange** class, which acts as a holder.
118+
119+
```
120+
TimeInterval interval = pojo.getDateTimeRange().getNextInterval(); (1)
121+
boolean includes = pojo.getDateTimeRange().includes(LocalDateTime.now()); (2)
122+
```
123+
- (1) "Starting from today, when will the next interval occur?"
124+
- (2) "Is today included in any interval?"
125+
126+
You can also use the **TimeInterval** instance directly.
127+
128+
```
129+
boolean includes = interval != null && interval.includes(LocalDateTime.now());
130+
```
131+
132+
## I18n support
133+
134+
Customize a ``DateTimeRangePickerI18n`` instance and pass it to the component (1).
135+
136+
```
137+
DateTimeRangePicker addon = new DateTimeRangePicker();
138+
addon.setI18n(new DateTimeRangePickerI18n() (1)
139+
.setDatesTitle("Your custom title")
140+
.setTimeChipsText("AM", "PM", "AM + PM")
141+
.setTimesPlaceholder("Start time", "End time")
142+
);
143+
```
144+
79145

80146
## Special configuration when using Spring
81147

pom.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.flowingcode.vaadin.addons</groupId>
8-
<artifactId>template-addon</artifactId>
8+
<artifactId>date-time-range-picker-addon</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10-
<name>Template Add-on</name>
11-
<description>Template Add-on for Vaadin Flow</description>
10+
<name>DateTimeRangePicker</name>
11+
<description>DateTimeRangePicker Vaadin Add-on</description>
1212
<url>https://www.flowingcode.com/en/open-source/</url>
1313

1414
<properties>
15-
<vaadin.version>24.4.6</vaadin.version>
15+
<vaadin.version>24.4.7</vaadin.version>
1616
<selenium.version>4.10.0</selenium.version>
1717
<maven.compiler.source>17</maven.compiler.source>
1818
<maven.compiler.target>17</maven.compiler.target>
@@ -156,6 +156,13 @@
156156
<version>5.9.1</version>
157157
<scope>test</scope>
158158
</dependency>
159+
160+
<dependency>
161+
<groupId>com.flowingcode.vaadin.addons</groupId>
162+
<artifactId>day-of-week-selector-addon</artifactId>
163+
<version>1.0.1</version>
164+
</dependency>
165+
159166
</dependencies>
160167

161168
<build>

0 commit comments

Comments
 (0)