Observaciones-vacaciones #83
60
package.json
60
package.json
@ -4,7 +4,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@f0rce/ace-widget": "1.0.2",
|
"@f0rce/ace-widget": "1.0.2",
|
||||||
"@polymer/polymer": "3.5.1",
|
"@polymer/polymer": "3.5.2",
|
||||||
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
|
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
|
||||||
"@vaadin/bundles": "24.5.1",
|
"@vaadin/bundles": "24.5.1",
|
||||||
"@vaadin/common-frontend": "0.0.19",
|
"@vaadin/common-frontend": "0.0.19",
|
||||||
@ -19,29 +19,30 @@
|
|||||||
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
||||||
"construct-style-sheets-polyfill": "3.1.0",
|
"construct-style-sheets-polyfill": "3.1.0",
|
||||||
"date-fns": "2.29.3",
|
"date-fns": "2.29.3",
|
||||||
"lit": "3.1.4",
|
"lit": "3.2.1",
|
||||||
"print-js": "1.6.0",
|
"print-js": "1.6.0",
|
||||||
"proj4": "2.12.1",
|
"proj4": "2.12.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-router-dom": "6.23.1"
|
"react-router-dom": "6.26.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-react": "7.24.7",
|
"@babel/preset-react": "7.25.7",
|
||||||
"@rollup/plugin-replace": "5.0.7",
|
"@preact/signals-react-transform": "0.4.0",
|
||||||
"@rollup/pluginutils": "5.1.0",
|
"@rollup/plugin-replace": "6.0.1",
|
||||||
"@types/react": "18.3.3",
|
"@rollup/pluginutils": "5.1.2",
|
||||||
"@types/react-dom": "18.3.0",
|
"@types/react": "18.3.11",
|
||||||
"@vitejs/plugin-react": "4.3.1",
|
"@types/react-dom": "18.3.1",
|
||||||
"async": "3.2.5",
|
"@vitejs/plugin-react": "4.3.3",
|
||||||
"glob": "10.4.1",
|
"async": "3.2.6",
|
||||||
|
"glob": "10.4.5",
|
||||||
"rollup-plugin-brotli": "3.1.0",
|
"rollup-plugin-brotli": "3.1.0",
|
||||||
"rollup-plugin-visualizer": "5.12.0",
|
"rollup-plugin-visualizer": "5.12.0",
|
||||||
"strip-css-comments": "5.0.0",
|
"strip-css-comments": "5.0.0",
|
||||||
"transform-ast": "2.4.4",
|
"transform-ast": "2.4.4",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.6.3",
|
||||||
"vite": "5.3.3",
|
"vite": "5.4.9",
|
||||||
"vite-plugin-checker": "0.6.4",
|
"vite-plugin-checker": "0.8.0",
|
||||||
"workbox-build": "7.1.1",
|
"workbox-build": "7.1.1",
|
||||||
"workbox-core": "7.1.0",
|
"workbox-core": "7.1.0",
|
||||||
"workbox-precaching": "7.1.0"
|
"workbox-precaching": "7.1.0"
|
||||||
@ -49,7 +50,7 @@
|
|||||||
"vaadin": {
|
"vaadin": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@f0rce/ace-widget": "1.0.2",
|
"@f0rce/ace-widget": "1.0.2",
|
||||||
"@polymer/polymer": "3.5.1",
|
"@polymer/polymer": "3.5.2",
|
||||||
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
|
"@vaadin-component-factory/vcf-pdf-viewer": "2.0.1",
|
||||||
"@vaadin/bundles": "24.5.1",
|
"@vaadin/bundles": "24.5.1",
|
||||||
"@vaadin/common-frontend": "0.0.19",
|
"@vaadin/common-frontend": "0.0.19",
|
||||||
@ -64,34 +65,35 @@
|
|||||||
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
"@vaadin/vaadin-usage-statistics": "2.1.3",
|
||||||
"construct-style-sheets-polyfill": "3.1.0",
|
"construct-style-sheets-polyfill": "3.1.0",
|
||||||
"date-fns": "2.29.3",
|
"date-fns": "2.29.3",
|
||||||
"lit": "3.1.4",
|
"lit": "3.2.1",
|
||||||
"print-js": "1.6.0",
|
"print-js": "1.6.0",
|
||||||
"proj4": "2.12.1",
|
"proj4": "2.12.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
"react-dom": "18.3.1",
|
"react-dom": "18.3.1",
|
||||||
"react-router-dom": "6.23.1"
|
"react-router-dom": "6.26.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/preset-react": "7.24.7",
|
"@babel/preset-react": "7.25.7",
|
||||||
"@rollup/plugin-replace": "5.0.7",
|
"@preact/signals-react-transform": "0.4.0",
|
||||||
"@rollup/pluginutils": "5.1.0",
|
"@rollup/plugin-replace": "6.0.1",
|
||||||
"@types/react": "18.3.3",
|
"@rollup/pluginutils": "5.1.2",
|
||||||
"@types/react-dom": "18.3.0",
|
"@types/react": "18.3.11",
|
||||||
"@vitejs/plugin-react": "4.3.1",
|
"@types/react-dom": "18.3.1",
|
||||||
"async": "3.2.5",
|
"@vitejs/plugin-react": "4.3.3",
|
||||||
"glob": "10.4.1",
|
"async": "3.2.6",
|
||||||
|
"glob": "10.4.5",
|
||||||
"rollup-plugin-brotli": "3.1.0",
|
"rollup-plugin-brotli": "3.1.0",
|
||||||
"rollup-plugin-visualizer": "5.12.0",
|
"rollup-plugin-visualizer": "5.12.0",
|
||||||
"strip-css-comments": "5.0.0",
|
"strip-css-comments": "5.0.0",
|
||||||
"transform-ast": "2.4.4",
|
"transform-ast": "2.4.4",
|
||||||
"typescript": "5.4.5",
|
"typescript": "5.6.3",
|
||||||
"vite": "5.3.3",
|
"vite": "5.4.9",
|
||||||
"vite-plugin-checker": "0.6.4",
|
"vite-plugin-checker": "0.8.0",
|
||||||
"workbox-build": "7.1.1",
|
"workbox-build": "7.1.1",
|
||||||
"workbox-core": "7.1.0",
|
"workbox-core": "7.1.0",
|
||||||
"workbox-precaching": "7.1.0"
|
"workbox-precaching": "7.1.0"
|
||||||
},
|
},
|
||||||
"hash": "1a0f17d48b329307b5862bc57499307d1b89f7d89260121c2b7189f76957c436"
|
"hash": "2dc40a4f634ae025081ca2239cba00b14a35fe94ab78ac0a4dd3023d882081d5"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@vaadin/bundles": "$@vaadin/bundles",
|
"@vaadin/bundles": "$@vaadin/bundles",
|
||||||
|
@ -19,6 +19,7 @@ import jakarta.annotation.security.PermitAll;
|
|||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.DayOfWeek;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -91,8 +92,20 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
onCategoryChange(event.getValue());
|
onCategoryChange(event.getValue());
|
||||||
handleCategorySelection(event.getValue());
|
handleCategorySelection(event.getValue());
|
||||||
});
|
});
|
||||||
startDatePicker.addValueChangeListener(event -> updateDatePickerMinValues());
|
startDatePicker.addValueChangeListener(event -> {
|
||||||
endDatePicker.addValueChangeListener(event -> calculateDays());
|
LocalDate selectedDate = event.getValue();
|
||||||
|
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6 || selectedDate.getDayOfWeek().getValue() == 7)) {
|
||||||
|
startDatePicker.setValue(selectedDate.minusDays(1));
|
||||||
|
}
|
||||||
|
updateDatePickerMinValues();
|
||||||
|
});
|
||||||
|
endDatePicker.addValueChangeListener(event -> {
|
||||||
|
LocalDate selectedDate = event.getValue();
|
||||||
|
if (selectedDate != null && (selectedDate.getDayOfWeek().getValue() == 6 || selectedDate.getDayOfWeek().getValue() == 7)) {
|
||||||
|
startDatePicker.setValue(selectedDate.minusDays(1));
|
||||||
|
}
|
||||||
|
calculateDays();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureBinder() {
|
private void configureBinder() {
|
||||||
@ -167,7 +180,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
|
|
||||||
private void onCategoryChange(final TimeOffRequestType selectedCategory) {
|
private void onCategoryChange(final TimeOffRequestType selectedCategory) {
|
||||||
if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL
|
if (selectedCategory == TimeOffRequestType.VACACION_GESTION_ACTUAL
|
||||||
|| selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
|
|| selectedCategory == TimeOffRequestType.VACACION_GESTION_ANTERIOR) {
|
||||||
startDatePicker.setEnabled(true);
|
startDatePicker.setEnabled(true);
|
||||||
endDatePicker.setEnabled(true);
|
endDatePicker.setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@ -199,8 +212,8 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
&& latestRequest.getDaysBalance() > 0)
|
&& latestRequest.getDaysBalance() > 0)
|
||||||
|| latestRequest.getState() == TimeOffRequestStatus.RECHAZADO
|
|| latestRequest.getState() == TimeOffRequestStatus.RECHAZADO
|
||||||
|| (latestRequest.getState() == TimeOffRequestStatus.TOMADO
|
|| (latestRequest.getState() == TimeOffRequestStatus.TOMADO
|
||||||
&& latestRequest.getDaysBalance() == 0
|
&& latestRequest.getDaysBalance() == 0
|
||||||
&& latestRequest.getExpiration().isBefore(LocalDate.now()));
|
&& latestRequest.getExpiration().isBefore(LocalDate.now()));
|
||||||
} else {
|
} else {
|
||||||
return (latestRequest.getState() == TimeOffRequestStatus.TOMADO
|
return (latestRequest.getState() == TimeOffRequestStatus.TOMADO
|
||||||
&& latestRequest.getExpiration().isBefore(LocalDate.now()))
|
&& latestRequest.getExpiration().isBefore(LocalDate.now()))
|
||||||
@ -375,6 +388,13 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
Double availableDays = availableDaysField.getValue();
|
Double availableDays = availableDaysField.getValue();
|
||||||
|
|
||||||
if (areDatesValid(startDate, endDate)) {
|
if (areDatesValid(startDate, endDate)) {
|
||||||
|
long workDays = countWorkDaysBetween(startDate, endDate);
|
||||||
|
|
||||||
|
daysToBeTakenField.setValue((double) workDays);
|
||||||
|
|
||||||
|
balanceDaysField.setValue(availableDaysField.getValue() - workDays);
|
||||||
|
|
||||||
|
|
||||||
double daysToBeTaken = calculateDaysBetween(startDate, endDate);
|
double daysToBeTaken = calculateDaysBetween(startDate, endDate);
|
||||||
setDaysToBeTakenField(daysToBeTaken);
|
setDaysToBeTakenField(daysToBeTaken);
|
||||||
|
|
||||||
@ -391,8 +411,19 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
return startDate != null && endDate != null;
|
return startDate != null && endDate != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long countWorkDaysBetween(LocalDate startDate, LocalDate endDate) {
|
||||||
|
return startDate.datesUntil(endDate.plusDays(1))
|
||||||
|
.filter(date -> date.getDayOfWeek() != DayOfWeek.SATURDAY && date.getDayOfWeek() != DayOfWeek.SUNDAY)
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
private double calculateDaysBetween(final LocalDate startDate, final LocalDate endDate) {
|
private double calculateDaysBetween(final LocalDate startDate, final LocalDate endDate) {
|
||||||
return java.time.temporal.ChronoUnit.DAYS.between(startDate, endDate) + 1;
|
return startDate.datesUntil(endDate.plusDays(1))
|
||||||
|
.filter(date -> {
|
||||||
|
DayOfWeek day = date.getDayOfWeek();
|
||||||
|
return day != DayOfWeek.SATURDAY && day != DayOfWeek.SUNDAY;
|
||||||
|
})
|
||||||
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDaysToBeTakenField(final double daysToBeTaken) {
|
private void setDaysToBeTakenField(final double daysToBeTaken) {
|
||||||
|
@ -154,7 +154,7 @@ public class RequestsListView extends BaseView {
|
|||||||
private String getEmployeeStatus(final Employee employee) {
|
private String getEmployeeStatus(final Employee employee) {
|
||||||
Optional<TimeOffRequest> activeRequest = requestService
|
Optional<TimeOffRequest> activeRequest = requestService
|
||||||
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.EN_USO);
|
.findByEmployeeAndState(employee.getId(), TimeOffRequestStatus.EN_USO);
|
||||||
return activeRequest.isPresent() ? "EN_DESCANSO" : "ACTIVO";
|
return activeRequest.isPresent() ? "EN_DESCANSO" : "EN_FUNCIONES";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getGeneralTotal(final Employee employee) {
|
private String getGeneralTotal(final Employee employee) {
|
||||||
@ -383,7 +383,7 @@ public class RequestsListView extends BaseView {
|
|||||||
private enum Status {
|
private enum Status {
|
||||||
TODOS,
|
TODOS,
|
||||||
EN_DESCANSO,
|
EN_DESCANSO,
|
||||||
ACTIVO
|
EN_FUNCIONES
|
||||||
}
|
}
|
||||||
|
|
||||||
private Employee createAllEmployeesOption() {
|
private Employee createAllEmployeesOption() {
|
||||||
|
Loading…
Reference in New Issue
Block a user