En-desarrollo #59

Merged
alex merged 12 commits from En-desarrollo into main 2024-10-22 01:01:10 +00:00
Showing only changes of commit 69c61e093e - Show all commits

View File

@ -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();
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
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.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
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();