Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename i18n internal property to datePickerI18n #6328

Merged
merged 1 commit into from
May 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ public class DateTimePicker

private final DateTimePickerDatePicker datePicker = new DateTimePickerDatePicker();
private final DateTimePickerTimePicker timePicker = new DateTimePickerTimePicker();
private DatePickerI18n i18n;
private DatePickerI18n datePickerI18n;

private DateTimePickerI18n dateTimePickerI18n;
private DateTimePickerI18n i18n;
private Locale locale;

private final static SerializableFunction<String, LocalDateTime> PARSER = s -> {
Expand Down Expand Up @@ -450,12 +450,11 @@ public void setTimeLabel(String timeLabel) {
* the value to be used as part of date picker aria-label.
*/
public void setDateAriaLabel(String dateLabel) {
if (dateTimePickerI18n == null) {
dateTimePickerI18n = new DateTimePickerI18n();
if (i18n == null) {
i18n = new DateTimePickerI18n();
}
dateTimePickerI18n.setDateLabel(dateLabel);
getElement().setPropertyJson("i18n",
JsonSerializer.toJson(dateTimePickerI18n));
i18n.setDateLabel(dateLabel);
getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
}

/**
Expand All @@ -468,10 +467,10 @@ public void setDateAriaLabel(String dateLabel) {
* @return an optional label or an empty optional if no label has been set
*/
public Optional<String> getDateAriaLabel() {
if (dateTimePickerI18n == null) {
if (i18n == null) {
return Optional.empty();
}
return Optional.ofNullable(dateTimePickerI18n.getDateLabel());
return Optional.ofNullable(i18n.getDateLabel());
}

/**
Expand All @@ -485,12 +484,11 @@ public Optional<String> getDateAriaLabel() {
* the value to be used as part of time picker aria-label.
*/
public void setTimeAriaLabel(String timeLabel) {
if (dateTimePickerI18n == null) {
dateTimePickerI18n = new DateTimePickerI18n();
if (i18n == null) {
i18n = new DateTimePickerI18n();
}
dateTimePickerI18n.setTimeLabel(timeLabel);
getElement().setPropertyJson("i18n",
JsonSerializer.toJson(dateTimePickerI18n));
i18n.setTimeLabel(timeLabel);
getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
}

/**
Expand All @@ -503,10 +501,10 @@ public void setTimeAriaLabel(String timeLabel) {
* @return an optional label or an empty optional if no label has been set
*/
public Optional<String> getTimeAriaLabel() {
if (dateTimePickerI18n == null) {
if (i18n == null) {
return Optional.empty();
}
return Optional.ofNullable(dateTimePickerI18n.getTimeLabel());
return Optional.ofNullable(i18n.getTimeLabel());
}

/**
Expand Down Expand Up @@ -603,7 +601,7 @@ public Duration getStep() {
* Set true to display ISO-8601 week numbers in the calendar.
* <p>
* Note that displaying of week numbers is only supported when
* i18n.firstDayOfWeek is 1 (Monday).
* datePickerI18n.firstDayOfWeek is 1 (Monday).
*
* @param weekNumbersVisible
* the boolean value to set
Expand Down Expand Up @@ -873,7 +871,7 @@ public LocalDateTime getMax() {
* properties weren't set.
*/
public DatePickerI18n getDatePickerI18n() {
return i18n;
return datePickerI18n;
}

/**
Expand All @@ -886,7 +884,7 @@ public DatePickerI18n getDatePickerI18n() {
public void setDatePickerI18n(DatePickerI18n i18n) {
Objects.requireNonNull(i18n,
"The i18n properties object should not be null");
this.i18n = i18n;
this.datePickerI18n = i18n;
datePicker.setI18n(i18n);
}

Expand Down