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.setItems(employees);
employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName()); employeeComboBox.setItemLabelGenerator(emp -> emp.getFirstName() + " " + emp.getLastName());
categoryComboBox.setEnabled(false); categoryComboBox.setEnabled(false);
categoryComboBox.addValueChangeListener(event -> updateAvailableDays(event.getValue())); categoryComboBox.addValueChangeListener(event -> {
clearForm();
updateAvailableDays(event.getValue());
});
employeeComboBox.addValueChangeListener(event -> { employeeComboBox.addValueChangeListener(event -> {
clearForm(); clearForm();
Employee selectedEmployee = event.getValue(); Employee selectedEmployee = event.getValue();
@ -116,22 +119,37 @@ public class RequestRegisterView extends VerticalLayout {
} }
private void setDatePickerLimits(Vacation vacation) { 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); 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.setMin(startDate);
startDatePicker.setMax(endDate); startDatePicker.setMax(endDate);
endDatePicker.setMin(startDate); endDatePicker.setMin(startDate);
endDatePicker.setMax(endDate); endDatePicker.setMax(endDate);
startDatePicker.setValue(startDate);
endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
} }
private void updateDatePickerMinValues() { private void updateDatePickerMinValues() {
LocalDate startDate = startDatePicker.getValue(); LocalDate startDate = startDatePicker.getValue();
if (vacation.getVacationDate() == null) {
endDate = startDate.plusDays(vacation.getExpiration().intValue() - 1);
}
if (startDate != null) { if (startDate != null) {
endDatePicker.setMin(startDate); 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)); endDatePicker.setValue(startDate.plusDays(vacation.getDuration().intValue() - 1));
}
calculateDays(); calculateDays();
} }
} }
@ -230,7 +248,6 @@ public class RequestRegisterView extends VerticalLayout {
} }
private void clearForm() { private void clearForm() {
categoryComboBox.clear();
availableDaysField.clear(); availableDaysField.clear();
startDatePicker.clear(); startDatePicker.clear();
endDatePicker.clear(); endDatePicker.clear();