Skip to content

Commit 4a7d6dc

Browse files
committed
feat: update with changes
1 parent 9a08aac commit 4a7d6dc

24 files changed

+650
-483
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: 5 additions & 5 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
@@ -109,8 +109,8 @@ The API is exposed through the **DateTimeRange** class.
109109
binder.forField(addon).bind(Pojo::getDateTimeRange, Pojo::setDateTimeRange); (2)
110110
binder.setBean(pojo); (3)
111111
```
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.
112+
- (1) The **Pojo** class is bound using its getter and setter methods (2).
113+
- (2) The **DateTimeRangePicker** is bound. Its [value](https://vaadin.com/api/platform/current/com/vaadin/flow/component/HasValue.html) can be operated now.
114114
- (3) The **DateTimeRange** instance is saved in the **Pojo** class or returned from it.
115115

116116

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<groupId>com.flowingcode.vaadin.addons</groupId>
88
<artifactId>date-time-range-picker-addon</artifactId>
99
<version>1.0.0-SNAPSHOT</version>
10-
<name>DateTimeRangePicker</name>
11-
<description>DateTimeRangePicker Vaadin Add-on</description>
10+
<name>Date Time Range Picker Add-on</name>
11+
<description>Component that facilitates the selection of a date and time range</description>
1212
<url>https://www.flowingcode.com/en/open-source/</url>
1313

1414
<properties>
@@ -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: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.Set;
3333

3434
/**
35-
* A class to operate {@link TimeInterval} instances based on defined date and time constraints<br>
35+
* A class to operate {@link TimeInterval} instances based on defined date and time constraints
3636
*
3737
* @author Izaguirre, Ezequiel
3838
* @see TimeInterval
@@ -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: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,31 @@
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;
4546
import java.util.Set;
4647

47-
// A single selection ChipGroup
48+
/**
49+
* A UI component representing a group of single-selection chips.
50+
* The group can be set to read-only mode, disabling user interaction.
51+
* This component is styled using the "fc-dtrp" CSS classes.
52+
*/
4853
@CssImport("./styles/styles.css")
4954
class ChipGroup extends HorizontalLayout {
5055

5156
private final Set<Chip> chips = new HashSet<>();
5257
private Chip checkedChip;
58+
private boolean readOnly = false;
5359

5460
public ChipGroup() {
5561
addClassNames(
5662
AlignItems.CENTER,
5763
JustifyContent.END,
5864
Gap.SMALL,
5965
FlexWrap.WRAP,
60-
Horizontal.SMALL,
66+
Left.SMALL,
6167
Vertical.SMALL
6268
);
6369
}
@@ -72,16 +78,11 @@ public ChipGroup(Chip... chips) {
7278
public Chip addChip(Chip chip) {
7379
chips.add(chip);
7480
chip.setParent(this);
81+
chip.setReadOnly(readOnly);
7582
add(chip);
7683
return chip;
7784
}
7885

79-
public boolean deleteChip(Chip chip) {
80-
chip.setParent(null);
81-
remove(chip);
82-
return chips.remove(chip);
83-
}
84-
8586
private void onChipChange(Chip chip) {
8687
if (checkedChip != null) {
8788
if (!checkedChip.equals(chip)) {
@@ -96,6 +97,7 @@ private void onChipChange(Chip chip) {
9697
}
9798

9899
public void setReadOnly(boolean readOnly) {
100+
this.readOnly = readOnly;
99101
chips.forEach(c -> c.setReadOnly(readOnly));
100102
}
101103

@@ -120,7 +122,6 @@ public Chip(String text) {
120122
Display.INLINE_FLEX,
121123
Gap.SMALL
122124
);
123-
getStyle().setCursor("pointer");
124125
checkIcon = VaadinIcon.CHECK.create();
125126
checkIcon.setSize("14px");
126127

@@ -193,14 +194,12 @@ public void setReadOnly(boolean readOnly) {
193194
removeClassName("fc-dtrp-hoverable");
194195
removeClassName(TextColor.BODY);
195196
addClassName(TextColor.SECONDARY);
196-
getStyle().setCursor("default");
197-
getElement().getStyle().set("border-style", "dashed");
197+
addClassName("fc-dtrp-readonly");
198198
} else {
199-
addClassName("fc-dtrp-hoverable");
199+
removeClassName("fc-dtrp-readonly");
200200
removeClassName(TextColor.SECONDARY);
201+
addClassName("fc-dtrp-hoverable");
201202
addClassName(TextColor.BODY);
202-
getElement().getStyle().set("border-style", "solid");
203-
getStyle().setCursor("pointer");
204203
}
205204
}
206205

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,20 @@
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;
29-
30-
// Indicator circle
23+
24+
/**
25+
* A simple UI component representing a circular indicator.
26+
* The circle's background color can be customized using the {@link #setColor(String)} method.
27+
* This component is styled with the "fc-dtrp-circle" CSS class.
28+
*/
3129
class Circle extends Div {
3230

3331
private final Div circle;
3432

3533
public Circle() {
3634
circle = new Div();
3735

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-
);
36+
addClassName("fc-dtrp-circle");
4737

4838
add(circle);
4939
}

0 commit comments

Comments
 (0)