Vacaciones #58
@ -67,7 +67,10 @@ public class RequestRegisterView extends VerticalLayout {
|
||||
employeeComboBox.setItems(employees);
|
||||
employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName());
|
||||
categoryComboBox.setEnabled(false);
|
||||
categoryComboBox.addValueChangeListener(event -> updateAvailableDays(event.getValue()));
|
||||
categoryComboBox.addValueChangeListener(event -> {
|
||||
clearForm();
|
||||
updateAvailableDays(event.getValue());
|
||||
});
|
||||
employeeComboBox.addValueChangeListener(event -> {
|
||||
clearForm();
|
||||
Employee selectedEmployee = event.getValue();
|
||||
@ -116,22 +119,37 @@ public class RequestRegisterView extends VerticalLayout {
|
||||
}
|
||||
|
||||
private void setDatePickerLimits(Vacation vacation) {
|
||||
LocalDate startDate = vacation.getVacationDate();
|
||||
LocalDate startDate;
|
||||
if (vacation.getVacationDate() != null) {
|
||||
startDate = vacation.getVacationDate();
|
||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||
startDatePicker.setValue(startDate);
|
||||
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
|
||||
|
||||
} else {
|
||||
startDate = LocalDate.now();
|
||||
endDate = null;
|
||||
}
|
||||
startDatePicker.setMin(startDate);
|
||||
startDatePicker.setMax(endDate);
|
||||
endDatePicker.setMin(startDate);
|
||||
endDatePicker.setMax(endDate);
|
||||
|
||||
startDatePicker.setValue(startDate);
|
||||
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
|
||||
}
|
||||
|
||||
private void updateDatePickerMinValues() {
|
||||
LocalDate startDate = startDatePicker.getValue();
|
||||
if (vacation.getVacationDate() == null) {
|
||||
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
|
||||
}
|
||||
if (startDate != null) {
|
||||
endDatePicker.setMin(startDate);
|
||||
endDatePicker.setMax(startDate.plusDays(vacation.getExpiration().intValue() - 1));
|
||||
if (vacation.getDuration() == 0.5) {
|
||||
endDatePicker.setValue(startDate.plusDays(0));
|
||||
} else {
|
||||
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
|
||||
}
|
||||
calculateDays();
|
||||
}
|
||||
}
|
||||
@ -230,7 +248,6 @@ public class RequestRegisterView extends VerticalLayout {
|
||||
}
|
||||
|
||||
private void clearForm() {
|
||||
categoryComboBox.clear();
|
||||
availableDaysField.clear();
|
||||
startDatePicker.clear();
|
||||
endDatePicker.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user