Skip to content

Commit 0b9238e

Browse files
committed
feat: update with changes
1 parent 9a08aac commit 0b9238e

24 files changed

+613
-451
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Bug Report
2-
description: Please report issues related to TEMPLATE_ADDON here.
2+
description: Please report issues related to DateTimeRangePicker here.
33
body:
44
- type: textarea
55
id: problem-description

.github/ISSUE_TEMPLATE/feature-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Feature Request
2-
description: Please add feature suggestions related to TEMPLATE_ADDON here.
2+
description: Please add feature suggestions related to DateTimeRangePicker here.
33
body:
44
- type: textarea
55
id: feature-proposal

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![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)
2+
[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/date-time-range-picker-add-on.svg)](https://vaadin.com/directory/component/date-time-range-picker-add-on)
3+
[![Build Status](https://jenkins.flowingcode.com/job/date-time-range-picker-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/date-time-range-picker-addon)](https://mvnrepository.com/artifact/com.flowingcode.vaadin.addons/date-time-range-picker-addon)
55
[![Javadoc](https://img.shields.io/badge/javadoc-00b4f0)](https://javadoc.flowingcode.com/artifact/com.flowingcode.vaadin.addons/date-time-range-picker-addon)
66

77
# DateTimeRangePicker Add-on for Vaadin 24

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
</licenses>
3939

4040
<scm>
41-
<url>https://github.com/FlowingCode/AddonStarter24</url>
42-
<connection>scm:git:git://github.com/FlowingCode/AddonStarter24.git</connection>
43-
<developerConnection>scm:git:ssh://git@github.com:/FlowingCode/AddonStarter24.git</developerConnection>
41+
<url>https://github.com/FlowingCode/DateTimeRangePicker</url>
42+
<connection>scm:git:git://github.com/FlowingCode/DateTimeRangePicker.git</connection>
43+
<developerConnection>scm:git:ssh://git@github.com:/FlowingCode/DateTimeRangePicker.git</developerConnection>
4444
<tag>master</tag>
4545
</scm>
4646

src/main/java/com/flowingcode/vaadin/addons/datetimerangepicker/api/DateTimeRange.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class DateTimeRange implements Serializable {
5353

5454

5555
public DateTimeRange(LocalDate startDate, LocalDate endDate, Set<DayOfWeek> weekDays) {
56+
if (!startDate.isBefore(endDate)) {
57+
throw new IllegalArgumentException("startDate must be before endDate");
58+
}
5659
this.startDate = startDate;
5760
this.endDate = endDate;
5861
setWeekDays(weekDays);
@@ -65,8 +68,7 @@ public DateTimeRange(LocalDate startDate, LocalDate endDate) {
6568
public DateTimeRange(LocalDate startDate, LocalDate endDate, LocalTime startTime, LocalTime endTime,
6669
Set<DayOfWeek> weekDays) {
6770
this(startDate, endDate, weekDays);
68-
this.endTime = endTime;
69-
this.startTime = startTime;
71+
setDayDuration(startTime, endTime);
7072
}
7173

7274
public DateTimeRange(LocalDate startDate, LocalDate endDate, LocalTime startTime, LocalTime endTime) {
@@ -80,6 +82,9 @@ public DateTimeRange(LocalDate startDate, LocalDate endDate, LocalTime startTime
8082
* @param endTime the ending point (exclusive).
8183
*/
8284
public void setDayDuration(LocalTime startTime, LocalTime endTime) {
85+
if (!startTime.isBefore(endTime)) {
86+
throw new IllegalArgumentException("startTime must be before endTime");
87+
}
8388
this.startTime = startTime;
8489
this.endTime = endTime;
8590
}
@@ -90,6 +95,9 @@ public void setDayDuration(LocalTime startTime, LocalTime endTime) {
9095
* @param weekDays a list of days
9196
*/
9297
public void setWeekDays(Set<DayOfWeek> weekDays) {
98+
if(weekDays == null) {
99+
throw new IllegalArgumentException("weekDays can't be null");
100+
}
93101
DayOfWeek[] allWeekDays = DayOfWeek.values();
94102

95103
for (int i = 0; i < allWeekDays.length; i++) {
@@ -263,9 +271,9 @@ public Duration getDayDuration() {
263271
}
264272

265273
/**
266-
* Gets the amount of days between the start and (exclusive) end dates
274+
* Gets the period between the start and (exclusive) end dates
267275
*/
268-
public Period getDaysSpan() {
276+
public Period getDatesPeriod() {
269277
return Period.between(startDate, endDate);
270278
}
271279

@@ -321,8 +329,8 @@ private List<TimeInterval> generateIntervals(LocalDateTime from, LocalDateTime t
321329
LocalDate startDate = from.toLocalDate();
322330
LocalTime startTime = from.toLocalTime();
323331
LocalDate endDate = to.toLocalDate();
324-
int days = Period.between(startDate, endDate).getDays();
325-
int i = 0;
332+
long days = java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate);
333+
long i = 0;
326334
List<TimeInterval> entities = new ArrayList<>();
327335
DayOfWeek firstDay = startDate.getDayOfWeek();
328336
if (this.weekDays[firstDay.getValue() - 1] == null || !this.endTime.isAfter(startTime)) {

src/main/java/com/flowingcode/vaadin/addons/datetimerangepicker/api/TimeInterval.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class TimeInterval implements Serializable, Comparable<TimeInterval> {
3535
private final LocalDateTime endDate;
3636

3737
public TimeInterval(LocalDateTime start, LocalDateTime end) {
38+
if (!start.isBefore(end)) {
39+
throw new IllegalArgumentException("start time must be before end time");
40+
}
3841
this.startDate = start;
3942
this.endDate = end;
4043
}

src/main/java/com/flowingcode/vaadin/addons/datetimerangepicker/ui/ChipGroup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.vaadin.flow.theme.lumo.LumoUtility.Margin;
4040
import com.vaadin.flow.theme.lumo.LumoUtility.Padding;
4141
import com.vaadin.flow.theme.lumo.LumoUtility.Padding.Horizontal;
42+
import com.vaadin.flow.theme.lumo.LumoUtility.Padding.Left;
4243
import com.vaadin.flow.theme.lumo.LumoUtility.Padding.Vertical;
4344
import com.vaadin.flow.theme.lumo.LumoUtility.TextColor;
4445
import java.util.HashSet;
@@ -57,7 +58,7 @@ public ChipGroup() {
5758
JustifyContent.END,
5859
Gap.SMALL,
5960
FlexWrap.WRAP,
60-
Horizontal.SMALL,
61+
Left.SMALL,
6162
Vertical.SMALL
6263
);
6364
}

src/main/java/com/flowingcode/vaadin/addons/datetimerangepicker/ui/Circle.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
package com.flowingcode.vaadin.addons.datetimerangepicker.ui;
2121

2222
import com.vaadin.flow.component.html.Div;
23-
import com.vaadin.flow.theme.lumo.LumoUtility.AlignItems;
24-
import com.vaadin.flow.theme.lumo.LumoUtility.Display;
25-
import com.vaadin.flow.theme.lumo.LumoUtility.JustifyContent;
26-
import com.vaadin.flow.theme.lumo.LumoUtility.Padding.Vertical;
27-
import com.vaadin.flow.theme.lumo.LumoUtility.Position;
28-
import com.vaadin.flow.theme.lumo.LumoUtility.Width;
2923

3024
// Indicator circle
3125
class Circle extends Div {
@@ -35,15 +29,7 @@ class Circle extends Div {
3529
public Circle() {
3630
circle = new Div();
3731

38-
addClassNames(
39-
Display.INLINE_FLEX,
40-
AlignItems.CENTER,
41-
JustifyContent.CENTER,
42-
Vertical.XSMALL,
43-
Position.ABSOLUTE,
44-
Width.AUTO,
45-
"fc-dtrp-circle"
46-
);
32+
addClassName("fc-dtrp-circle");
4733

4834
add(circle);
4935
}

0 commit comments

Comments
 (0)