cambios de diseno tablas
All checks were successful
Builder / Build-Project (push) Successful in 2m40s
All checks were successful
Builder / Build-Project (push) Successful in 2m40s
This commit is contained in:
parent
54ff167124
commit
1d135c9869
Binary file not shown.
@ -14,7 +14,6 @@ public enum TimeOffRequestType {
|
||||
AÑO_NUEVO_ANDINO,
|
||||
ANIVERSARIO_DEPARTAMENTAL,
|
||||
DIA_DE_TODOS_LOS_DIFUNTOS,
|
||||
|
||||
CUMPLEAÑOS,
|
||||
MATERNIDAD,
|
||||
PATERNIDAD,
|
||||
|
@ -8,7 +8,6 @@ import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.confirmdialog.ConfirmDialog;
|
||||
import com.vaadin.flow.component.grid.Grid;
|
||||
import com.vaadin.flow.component.html.Main;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.data.provider.DataProvider;
|
||||
@ -31,7 +30,7 @@ import java.util.stream.Stream;
|
||||
@PageTitle("Assessments")
|
||||
@Route(value = "/assessments", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class AssessmentsListView extends Main {
|
||||
public class AssessmentsListView extends BaseView {
|
||||
|
||||
public AssessmentsListView(final AssessmentService assessmentService) {
|
||||
final HorizontalLayout hl = new HorizontalLayout();
|
||||
@ -122,7 +121,7 @@ public class AssessmentsListView extends Main {
|
||||
});
|
||||
grid.setAllRowsVisible(true);
|
||||
|
||||
add(hl, grid);
|
||||
getCurrentPageLayout().add(hl, grid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.html.Main;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.data.provider.DataProvider;
|
||||
import com.vaadin.flow.data.provider.DataProviderListener;
|
||||
@ -27,7 +26,7 @@ import java.util.stream.Stream;
|
||||
@PageTitle("Candidates")
|
||||
@Route(value = "/candidates", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class CandidatesListView extends Main {
|
||||
public class CandidatesListView extends BaseView {
|
||||
|
||||
public CandidatesListView(final CandidateService candidateService) {
|
||||
|
||||
@ -84,6 +83,6 @@ public class CandidatesListView extends Main {
|
||||
}
|
||||
});
|
||||
|
||||
add(hl, grid);
|
||||
getCurrentPageLayout().add(hl, grid);
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,22 @@ import com.primefactorsolutions.model.DocumentType;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.service.DocumentService;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.views.util.MenuBarUtils;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.UI;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.grid.GridSortOrder;
|
||||
import com.vaadin.flow.component.html.Span;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.data.provider.SortDirection;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.server.StreamRegistration;
|
||||
@ -73,13 +82,20 @@ public class DocumentsListView extends BaseView {
|
||||
}
|
||||
|
||||
private void addActionColumns() {
|
||||
addDocumentActionColumn("View", this::navigateToDocumentView);
|
||||
addDocumentActionColumn("Edit", this::navigateToEditDocumentView);
|
||||
addDocumentActionColumn("Download", this::downloadDocument);
|
||||
}
|
||||
|
||||
private void addDocumentActionColumn(final String label, final DocumentActionHandler handler) {
|
||||
documentGrid.addComponentColumn(document -> createActionButton(label, () -> handler.handle(document)));
|
||||
documentGrid.addComponentColumn((ValueProvider<Document, Component>) document -> {
|
||||
final MenuBar menuBar = new MenuBar();
|
||||
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
|
||||
final MenuItem viewItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.EYE, "View");
|
||||
viewItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
navigateToDocumentView(document));
|
||||
final MenuItem editItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.PENCIL, "Edit");
|
||||
editItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
navigateToEditDocumentView(document));
|
||||
final MenuItem downloadItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.DOWNLOAD, "Download");
|
||||
downloadItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
downloadDocument(document));
|
||||
return menuBar;
|
||||
});
|
||||
}
|
||||
|
||||
private Button createActionButton(final String label, final Runnable onClickAction) {
|
||||
@ -203,9 +219,4 @@ public class DocumentsListView extends BaseView {
|
||||
StreamRegistration registration = ui.getSession().getResourceRegistry().registerResource(resource);
|
||||
ui.getPage().open(registration.getResourceUri().toString());
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface DocumentActionHandler {
|
||||
void handle(Document document);
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@ package com.primefactorsolutions.views;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.html.H2;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
@ -32,7 +31,6 @@ public class EmployeesListView extends BaseView {
|
||||
}
|
||||
|
||||
private void setupView() {
|
||||
getCurrentPageLayout().add(new H2("Employee List"));
|
||||
configureTable();
|
||||
getCurrentPageLayout().add(createAddEmployeeButton());
|
||||
getCurrentPageLayout().add(table);
|
||||
|
@ -6,10 +6,19 @@ import com.primefactorsolutions.model.Team;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.service.HoursWorkedService;
|
||||
import com.primefactorsolutions.service.TeamService;
|
||||
import com.primefactorsolutions.views.util.MenuBarUtils;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
@ -37,8 +46,6 @@ public class HoursWorkedListView extends BaseView {
|
||||
private final PagingGrid<HoursWorked> hoursWorkedGrid = new PagingGrid<>();
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private UUID selectedEmployeeId;
|
||||
|
||||
|
||||
public HoursWorkedListView(final HoursWorkedService hoursWorkedService,
|
||||
final EmployeeService employeeService,
|
||||
@ -114,7 +121,6 @@ public class HoursWorkedListView extends BaseView {
|
||||
setupFilters();
|
||||
setupListHoursWorkedGrid();
|
||||
getCurrentPageLayout().add(hoursWorkedGrid);
|
||||
getCurrentPageLayout().add(createActionButtons());
|
||||
}
|
||||
|
||||
private void setupFilters() {
|
||||
@ -141,15 +147,18 @@ public class HoursWorkedListView extends BaseView {
|
||||
hoursWorkedGrid.addColumn(HoursWorked::getHours).setHeader("Total Horas").setSortable(true);
|
||||
hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes")
|
||||
.setSortable(true);
|
||||
hoursWorkedGrid.addComponentColumn((ValueProvider<HoursWorked, Component>) hoursWorked -> {
|
||||
final MenuBar menuBar = new MenuBar();
|
||||
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
|
||||
final MenuItem viewItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.EYE, "Ver");
|
||||
viewItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||
navigateToHoursWorkedView(hoursWorked.getEmployee().getId());
|
||||
});
|
||||
return menuBar;
|
||||
});
|
||||
|
||||
hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
hoursWorkedGrid.setPageSize(PAGE_SIZE);
|
||||
hoursWorkedGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
HoursWorked selectedHoursWorked = event.getValue();
|
||||
if (selectedHoursWorked != null) {
|
||||
selectedEmployeeId = selectedHoursWorked.getEmployee().getId();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private double calcularTotal(final HoursWorked hoursWorked) {
|
||||
@ -165,22 +174,6 @@ public class HoursWorkedListView extends BaseView {
|
||||
.sum();
|
||||
}
|
||||
|
||||
private HorizontalLayout createActionButtons() {
|
||||
Button viewButton = new Button("Ver", event -> {
|
||||
if (selectedEmployeeId != null) {
|
||||
navigateToHoursWorkedView(selectedEmployeeId);
|
||||
} else {
|
||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
||||
}
|
||||
});
|
||||
Button closeButton = new Button("Salir", event -> navigateToListView());
|
||||
return new HorizontalLayout(viewButton, closeButton);
|
||||
}
|
||||
|
||||
private void navigateToListView() {
|
||||
getUI().ifPresent(ui -> ui.navigate(MainView.class));
|
||||
}
|
||||
|
||||
private void navigateToHoursWorkedView(final UUID idEmployee) {
|
||||
getUI().ifPresent(ui -> ui.navigate("hours-worked-list/" + idEmployee.toString()));
|
||||
}
|
||||
|
@ -4,10 +4,17 @@ import com.primefactorsolutions.model.*;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.service.TeamService;
|
||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.primefactorsolutions.views.util.MenuBarUtils;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
@ -22,7 +29,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@PageTitle("PendingRequests")
|
||||
@PageTitle("Pending Requests")
|
||||
@Route(value = "/pending-requests", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class PendingRequestsListView extends BaseView {
|
||||
@ -35,7 +42,6 @@ public class PendingRequestsListView extends BaseView {
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||
private UUID selectedRequestId;
|
||||
|
||||
public PendingRequestsListView(final TimeOffRequestService requestService,
|
||||
final EmployeeService employeeService,
|
||||
@ -50,7 +56,6 @@ public class PendingRequestsListView extends BaseView {
|
||||
private void initializeView() {
|
||||
setupFilters();
|
||||
setupPendingRequestsGrid();
|
||||
createActionButtons();
|
||||
}
|
||||
|
||||
private void setupFilters() {
|
||||
@ -66,38 +71,31 @@ public class PendingRequestsListView extends BaseView {
|
||||
pendingRequestsGrid.addColumn(this::getEmployeeFullName).setHeader("Empleado");
|
||||
pendingRequestsGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
||||
pendingRequestsGrid.addColumn(this::getCategory).setHeader("Categoría");
|
||||
pendingRequestsGrid.addComponentColumn((ValueProvider<TimeOffRequest, Component>) timeOffRequest -> {
|
||||
final MenuBar menuBar = new MenuBar();
|
||||
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
|
||||
final MenuItem approveItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.CHECK, "Aprobar");
|
||||
approveItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||
actionForRequest(timeOffRequest.getId(), TimeOffRequestStatus.APROBADO);
|
||||
});
|
||||
final MenuItem rejectItem = MenuBarUtils.createIconItem(menuBar, VaadinIcon.BAN, "Rechazar");
|
||||
rejectItem.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent -> {
|
||||
actionForRequest(timeOffRequest.getId(), TimeOffRequestStatus.RECHAZADO);
|
||||
});
|
||||
return menuBar;
|
||||
});
|
||||
|
||||
pendingRequestsGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
pendingRequestsGrid.setPageSize(PAGE_SIZE);
|
||||
pendingRequestsGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
TimeOffRequest selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
selectedRequestId = selectedRequest.getId();
|
||||
}
|
||||
});
|
||||
|
||||
getCurrentPageLayout().add(pendingRequestsGrid);
|
||||
}
|
||||
|
||||
private void createActionButtons() {
|
||||
final Button approveButton = createActionButton("Aprobar", TimeOffRequestStatus.APROBADO);
|
||||
final Button rejectButton = createActionButton("Rechazar", TimeOffRequestStatus.RECHAZADO);
|
||||
final Button closeButton = new Button("Salir", event -> navigateToMainView());
|
||||
|
||||
getCurrentPageLayout().add(new HorizontalLayout(approveButton, rejectButton, closeButton));
|
||||
}
|
||||
|
||||
private Button createActionButton(final String caption, final TimeOffRequestStatus status) {
|
||||
return new Button(caption, event -> {
|
||||
if (selectedRequestId != null) {
|
||||
TimeOffRequest request = requestService.findTimeOffRequest(selectedRequestId);
|
||||
request.setState(status);
|
||||
requestService.saveTimeOffRequest(request);
|
||||
refreshGeneralPendingRequestsGrid(null, null, null);
|
||||
} else {
|
||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
||||
}
|
||||
});
|
||||
private void actionForRequest(final UUID selectedRequestId, final TimeOffRequestStatus status) {
|
||||
TimeOffRequest request = requestService.findTimeOffRequest(selectedRequestId);
|
||||
request.setState(status);
|
||||
requestService.saveTimeOffRequest(request);
|
||||
refreshGeneralPendingRequestsGrid(null, null, null);
|
||||
}
|
||||
|
||||
private void refreshGeneralPendingRequestsGrid(final Employee employee,
|
||||
@ -223,8 +221,4 @@ public class PendingRequestsListView extends BaseView {
|
||||
allTeamsOption.setName("TODOS");
|
||||
return allTeamsOption;
|
||||
}
|
||||
|
||||
private void navigateToMainView() {
|
||||
getUI().ifPresent(ui -> ui.navigate(MainView.class));
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.html.Main;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.data.provider.DataProvider;
|
||||
import com.vaadin.flow.data.provider.DataProviderListener;
|
||||
@ -27,7 +26,7 @@ import java.util.stream.Stream;
|
||||
@PageTitle("Questions")
|
||||
@Route(value = "/questions", layout = MainLayout.class)
|
||||
@PermitAll
|
||||
public class QuestionsListView extends Main {
|
||||
public class QuestionsListView extends BaseView {
|
||||
|
||||
public QuestionsListView(final QuestionService questionService) {
|
||||
|
||||
@ -82,6 +81,6 @@ public class QuestionsListView extends Main {
|
||||
});
|
||||
grid.setAllRowsVisible(true);
|
||||
|
||||
add(hl, grid);
|
||||
getCurrentPageLayout().add(hl, grid);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import java.util.stream.Collectors;
|
||||
@PermitAll
|
||||
@Route(value = "/reportes", layout = MainLayout.class)
|
||||
@PageTitle("Reporte de Horas Trabajadas")
|
||||
public class ReporteView extends VerticalLayout {
|
||||
public class ReporteView extends BaseView {
|
||||
|
||||
private final EmployeeService employeeService;
|
||||
private final HoursWorkedService hoursWorkedService;
|
||||
@ -51,7 +51,7 @@ public class ReporteView extends VerticalLayout {
|
||||
private final Span semanaInfoSpan = new Span();
|
||||
|
||||
// Obtener el año actual
|
||||
private int currentYear = LocalDate.now().getYear();
|
||||
private final int currentYear = LocalDate.now().getYear();
|
||||
|
||||
@Autowired
|
||||
public ReporteView(final HoursWorkedService hoursWorkedService,
|
||||
@ -63,7 +63,7 @@ public class ReporteView extends VerticalLayout {
|
||||
this.employeeService = employeeService;
|
||||
|
||||
H2 title = new H2("Reporte de Horas Trabajadas");
|
||||
add(title);
|
||||
getCurrentPageLayout().add(title);
|
||||
|
||||
List<Team> teams = teamService.findAllTeams();
|
||||
equipoComboBox.setItems(teams);
|
||||
@ -80,11 +80,12 @@ public class ReporteView extends VerticalLayout {
|
||||
|
||||
Button reportButton = new Button("Generar Reporte de Horas Trabajadas",
|
||||
event -> generateHoursWorkedReport());
|
||||
HorizontalLayout filtersLayout = new HorizontalLayout(equipoComboBox, semanaComboBox, reportButton);
|
||||
add(filtersLayout);
|
||||
getCurrentPageLayout().add(reportButton);
|
||||
|
||||
// Añadir `headerLayout` al diseño principal para el encabezado dinámico
|
||||
add(headerLayout);
|
||||
HorizontalLayout filtersLayout = new HorizontalLayout(equipoComboBox, semanaComboBox);
|
||||
getCurrentPageLayout().add(filtersLayout);
|
||||
|
||||
getCurrentPageLayout().add(headerLayout);
|
||||
updateHeaderLayout(null, null);
|
||||
|
||||
grid.addColumn(map -> map.get("Empleado")).setHeader("Empleado");
|
||||
@ -92,7 +93,7 @@ public class ReporteView extends VerticalLayout {
|
||||
grid.addColumn(map -> map.get("Horas Pendientes")).setHeader("Horas Pendientes");
|
||||
grid.addColumn(map -> map.get("Observaciones")).setHeader("Observaciones");
|
||||
|
||||
add(grid);
|
||||
getCurrentPageLayout().add(grid);
|
||||
}
|
||||
|
||||
private void initializeSemanaComboBox() {
|
||||
@ -104,12 +105,11 @@ public class ReporteView extends VerticalLayout {
|
||||
.map(date -> {
|
||||
int weekNumber = date.get(WeekFields.of(DayOfWeek.MONDAY, 1)
|
||||
.weekOfWeekBasedYear());
|
||||
LocalDate startOfWeek = date;
|
||||
LocalDate endOfWeek = startOfWeek.plusDays(6);
|
||||
LocalDate endOfWeek = date.plusDays(6);
|
||||
|
||||
return String.format("Semana %d: %s - %s",
|
||||
weekNumber,
|
||||
startOfWeek.getDayOfMonth() + " de " + startOfWeek.getMonth()
|
||||
date.getDayOfMonth() + " de " + date.getMonth()
|
||||
.getDisplayName(TextStyle.FULL, Locale.getDefault()),
|
||||
endOfWeek.getDayOfMonth() + " de " + endOfWeek.getMonth()
|
||||
.getDisplayName(TextStyle.FULL, Locale.getDefault())
|
||||
@ -170,15 +170,8 @@ public class ReporteView extends VerticalLayout {
|
||||
headerLayout.removeAll();
|
||||
|
||||
if (team != null && dateInWeek != null) {
|
||||
LocalDate startOfWeek = dateInWeek.with(DayOfWeek.FRIDAY);
|
||||
LocalDate endOfWeek = dateInWeek.with(DayOfWeek.THURSDAY);
|
||||
int weekNumber = getWeekOfYear(dateInWeek);
|
||||
|
||||
String formattedStartDate = startOfWeek.getDayOfMonth() + " de "
|
||||
+ startOfWeek.getMonth().getDisplayName(TextStyle.FULL, Locale.getDefault());
|
||||
String formattedEndDate = endOfWeek.getDayOfMonth() + " de "
|
||||
+ endOfWeek.getMonth().getDisplayName(TextStyle.FULL, Locale.getDefault());
|
||||
|
||||
headerLayout.add(new Span("Informe "
|
||||
+ String.format("%03d", weekNumber) + "/" + currentYear) {{
|
||||
getStyle().set("font-size", "24px");
|
||||
@ -217,7 +210,7 @@ public class ReporteView extends VerticalLayout {
|
||||
if (downloadLink == null) {
|
||||
downloadLink = new Anchor(excelResource, "Descargar Reporte en Excel");
|
||||
downloadLink.getElement().setAttribute("download", true);
|
||||
add(downloadLink);
|
||||
getCurrentPageLayout().add(downloadLink);
|
||||
} else {
|
||||
downloadLink.setHref(excelResource);
|
||||
}
|
||||
|
@ -4,14 +4,19 @@ import com.primefactorsolutions.model.*;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||
import com.primefactorsolutions.service.VacationService;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.html.Div;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.html.H3;
|
||||
import com.vaadin.flow.component.html.Span;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.BeforeEvent;
|
||||
import com.vaadin.flow.router.HasUrlParameter;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
@ -27,13 +32,14 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
import static com.primefactorsolutions.views.util.MenuBarUtils.createIconItem;
|
||||
|
||||
@SpringComponent
|
||||
@PermitAll
|
||||
@Scope("prototype")
|
||||
@PageTitle("RequestEmployee")
|
||||
@PageTitle("Employee Request")
|
||||
@Route(value = "/requests", layout = MainLayout.class)
|
||||
public class RequestEmployeeView extends Div implements HasUrlParameter<String> {
|
||||
public class RequestEmployeeView extends BaseView implements HasUrlParameter<String> {
|
||||
|
||||
private final TimeOffRequestService requestService;
|
||||
private final EmployeeService employeeService;
|
||||
@ -43,7 +49,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
private ComboBox<TimeOffRequestType> categoryFilter;
|
||||
private ComboBox<TimeOffRequestStatus> stateFilter;
|
||||
private UUID employeeId;
|
||||
private TimeOffRequest request;
|
||||
|
||||
public RequestEmployeeView(final TimeOffRequestService requestService,
|
||||
final EmployeeService employeeService,
|
||||
@ -57,14 +62,15 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
requestService.updateRequestStatuses();
|
||||
setupFilters();
|
||||
setupGrid();
|
||||
add(requestGrid, createActionButtons(), createSummaryLayout());
|
||||
getCurrentPageLayout().add(requestGrid, new H3("Balance"), createSummaryLayout());
|
||||
refreshRequestGrid(null, null);
|
||||
}
|
||||
|
||||
private void setupFilters() {
|
||||
categoryFilter = createCategoryFilter();
|
||||
stateFilter = createStateFilter();
|
||||
add(categoryFilter, stateFilter);
|
||||
HorizontalLayout hl = new HorizontalLayout(categoryFilter, stateFilter);
|
||||
getCurrentPageLayout().add(hl);
|
||||
}
|
||||
|
||||
private ComboBox<TimeOffRequestType> createCategoryFilter() {
|
||||
@ -96,15 +102,20 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
requestGrid.getColumnByKey("startDate").setHeader("Fecha de Inicio");
|
||||
requestGrid.getColumnByKey("endDate").setHeader("Fecha de Fin");
|
||||
requestGrid.getColumnByKey("daysToBeTake").setHeader("Días a Tomar");
|
||||
requestGrid.addComponentColumn((ValueProvider<TimeOffRequest, Component>) timeOffRequest -> {
|
||||
final MenuBar menuBar = new MenuBar();
|
||||
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
|
||||
final MenuItem view = createIconItem(menuBar, VaadinIcon.EYE, "View");
|
||||
view.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
navigateToViewRequest(timeOffRequest));
|
||||
final MenuItem edit = createIconItem(menuBar, VaadinIcon.PENCIL, "Edit");
|
||||
edit.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
navigateToEditRequest(timeOffRequest));
|
||||
return menuBar;
|
||||
});
|
||||
|
||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
requestGrid.setPageSize(PAGE_SIZE);
|
||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
TimeOffRequest selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
request = selectedRequest;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Set<TimeOffRequestType> getStandardExclusions() {
|
||||
@ -291,24 +302,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
return vacation.getType() != Vacation.Type.OTHER;
|
||||
}
|
||||
|
||||
private HorizontalLayout createActionButtons() {
|
||||
Button viewButton = createButton("Ver", () -> navigateToViewRequest(request));
|
||||
Button editButton = createButton("Editar", () -> navigateToEditRequest(request));
|
||||
Button closeButton = new Button("Salir", event -> navigateToRequestsListView());
|
||||
|
||||
return new HorizontalLayout(viewButton, editButton, closeButton);
|
||||
}
|
||||
|
||||
private Button createButton(final String caption, final Runnable action) {
|
||||
return new Button(caption, event -> {
|
||||
if (request != null) {
|
||||
action.run();
|
||||
} else {
|
||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void navigateToRequestsListView() {
|
||||
getUI().ifPresent(ui -> ui.navigate(RequestsListView.class));
|
||||
}
|
||||
@ -417,7 +410,6 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
||||
}
|
||||
|
||||
private void setViewTitle(final String employeeName, final String employeeTeam) {
|
||||
addComponentAsFirst(new H3("Nombre del empleado: " + employeeName));
|
||||
addComponentAtIndex(1, new H3("Equipo: " + employeeTeam));
|
||||
getCurrentPageLayout().addComponentAsFirst(new H3(String.format("%s (%s)", employeeName, employeeTeam)));
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,16 @@ import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.primefactorsolutions.service.TeamService;
|
||||
import com.primefactorsolutions.service.TimeOffRequestService;
|
||||
import com.primefactorsolutions.service.VacationService;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.combobox.ComboBox;
|
||||
import com.vaadin.flow.component.notification.Notification;
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import com.vaadin.flow.component.menubar.MenuBarVariant;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
import com.vaadin.flow.router.Route;
|
||||
import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
@ -22,6 +28,7 @@ import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
|
||||
import static com.primefactorsolutions.views.util.MenuBarUtils.createIconItem;
|
||||
|
||||
@SpringComponent
|
||||
@Scope("prototype")
|
||||
@ -39,8 +46,6 @@ public class RequestsListView extends BaseView {
|
||||
private ComboBox<Employee> employeeFilter;
|
||||
private ComboBox<Team> teamFilter;
|
||||
private ComboBox<Status> stateFilter;
|
||||
private UUID selectedEmployeeId;
|
||||
|
||||
|
||||
public RequestsListView(final TimeOffRequestService requestService,
|
||||
final EmployeeService employeeService,
|
||||
@ -59,7 +64,6 @@ public class RequestsListView extends BaseView {
|
||||
setupFilters();
|
||||
setupRequestGrid();
|
||||
getCurrentPageLayout().add(requestGrid);
|
||||
getCurrentPageLayout().add(createActionButtons());
|
||||
}
|
||||
|
||||
private void setupFilters() {
|
||||
@ -76,27 +80,18 @@ public class RequestsListView extends BaseView {
|
||||
requestGrid.addColumn(this::getTeamName).setHeader("Equipo");
|
||||
requestGrid.addColumn(this::getEmployeeStatus).setHeader("Estado del empleado");
|
||||
requestGrid.addColumn(this::getGeneralTotal).setHeader("Total general");
|
||||
requestGrid.addComponentColumn((ValueProvider<Employee, Component>) employee -> {
|
||||
final MenuBar menuBar = new MenuBar();
|
||||
menuBar.addThemeVariants(MenuBarVariant.LUMO_TERTIARY_INLINE);
|
||||
final MenuItem view = createIconItem(menuBar, VaadinIcon.EYE, "View");
|
||||
view.addClickListener((ComponentEventListener<ClickEvent<MenuItem>>) menuItemClickEvent ->
|
||||
navigateToTimeOffRequestView(employee.getId()));
|
||||
|
||||
return menuBar;
|
||||
});
|
||||
|
||||
requestGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM);
|
||||
requestGrid.setPageSize(PAGE_SIZE);
|
||||
requestGrid.asSingleSelect().addValueChangeListener(event -> {
|
||||
Employee selectedRequest = event.getValue();
|
||||
if (selectedRequest != null) {
|
||||
selectedEmployeeId = selectedRequest.getId();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private HorizontalLayout createActionButtons() {
|
||||
Button viewButton = new Button("Ver", event -> {
|
||||
if (selectedEmployeeId != null) {
|
||||
navigateToTimeOffRequestView(selectedEmployeeId);
|
||||
} else {
|
||||
Notification.show("Seleccione una solicitud.", 3000, Notification.Position.MIDDLE);
|
||||
}
|
||||
});
|
||||
Button closeButton = new Button("Salir", event -> navigateToMainView());
|
||||
return new HorizontalLayout(viewButton, closeButton);
|
||||
}
|
||||
|
||||
private void refreshGeneralRequestGrid(final Employee employee,
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.primefactorsolutions.views.util;
|
||||
|
||||
import com.vaadin.flow.component.contextmenu.MenuItem;
|
||||
import com.vaadin.flow.component.icon.Icon;
|
||||
import com.vaadin.flow.component.icon.VaadinIcon;
|
||||
import com.vaadin.flow.component.menubar.MenuBar;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class MenuBarUtils {
|
||||
|
||||
public static MenuItem createIconItem(final MenuBar menu, final VaadinIcon iconName, final String ariaLabel) {
|
||||
final Icon icon = new Icon(iconName);
|
||||
final MenuItem item = menu.addItem(icon);
|
||||
item.setAriaLabel(ariaLabel);
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user