diff --git a/src/main/bundles/prod.bundle b/src/main/bundles/prod.bundle index 72a1ec0..eae3a50 100644 Binary files a/src/main/bundles/prod.bundle and b/src/main/bundles/prod.bundle differ diff --git a/src/main/java/com/primefactorsolutions/views/BaseView.java b/src/main/java/com/primefactorsolutions/views/BaseView.java new file mode 100644 index 0000000..48a17d8 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/BaseView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +import com.vaadin.flow.component.html.Main; +import com.vaadin.flow.component.orderedlayout.VerticalLayout; +import lombok.Getter; + +@Getter +public class BaseView extends Main { + + private final VerticalLayout currentPageLayout; + + public BaseView() { + currentPageLayout = new VerticalLayout(); + add(currentPageLayout); + } +} diff --git a/src/main/java/com/primefactorsolutions/views/DocumentsListView.java b/src/main/java/com/primefactorsolutions/views/DocumentsListView.java index e733495..39803d0 100644 --- a/src/main/java/com/primefactorsolutions/views/DocumentsListView.java +++ b/src/main/java/com/primefactorsolutions/views/DocumentsListView.java @@ -9,8 +9,8 @@ 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.grid.GridSortOrder; -import com.vaadin.flow.component.html.Main; import com.vaadin.flow.component.html.Span; +import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.data.provider.SortDirection; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; @@ -26,13 +26,12 @@ import java.util.List; import static com.primefactorsolutions.views.Constants.PAGE_SIZE; - @SpringComponent @Scope("prototype") @PageTitle("Documents") @Route(value = "/documents", layout = MainLayout.class) @PermitAll -public class DocumentsListView extends Main { +public class DocumentsListView extends BaseView { private final DocumentService documentService; private final EmployeeService employeeService; @@ -48,11 +47,16 @@ public class DocumentsListView extends Main { } private void initializeView() { + getCurrentPageLayout().add(createActionButton("Add Document", this::navigateToAddDocumentView)); + + final HorizontalLayout hl = new HorizontalLayout(); + hl.add(createDocumentTypeFilter()); + hl.add(createEmployeeFilter()); + + getCurrentPageLayout().add(hl); + configureDocumentGrid(); - add(createActionButton("Add Document", this::navigateToAddDocumentView)); - add(createDocumentTypeFilter()); - add(createEmployeeFilter()); - add(documentGrid); + getCurrentPageLayout().add(documentGrid); } private void configureDocumentGrid() { diff --git a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java index cb91785..40683a4 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeesListView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeesListView.java @@ -4,7 +4,6 @@ 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.component.html.Main; import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; import com.vaadin.flow.spring.annotation.SpringComponent; @@ -16,13 +15,12 @@ import org.springframework.context.annotation.Scope; import java.util.List; - @SpringComponent @Scope("prototype") @PageTitle("Employees") @Route(value = "/employees", layout = MainLayout.class) @PermitAll -public class EmployeesListView extends Main { +public class EmployeesListView extends BaseView { private final EmployeeService employeeService; private final PagingGrid table = new PagingGrid<>(Employee.class); @@ -34,10 +32,10 @@ public class EmployeesListView extends Main { } private void setupView() { - add(new H2("Employee List")); + getCurrentPageLayout().add(new H2("Employee List")); configureTable(); - add(createAddEmployeeButton()); - add(table); + getCurrentPageLayout().add(createAddEmployeeButton()); + getCurrentPageLayout().add(table); } private void configureTable() { diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java index e50ef43..6b8bf52 100644 --- a/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java @@ -8,7 +8,6 @@ import com.primefactorsolutions.service.HoursWorkedService; import com.primefactorsolutions.service.TeamService; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.combobox.ComboBox; -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.router.PageTitle; @@ -30,7 +29,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE; @Scope("prototype") @PageTitle("Registro de Horas Trabajadas") @Route(value = "/hours-worked-list", layout = MainLayout.class) -public class HoursWorkedListView extends Main { +public class HoursWorkedListView extends BaseView { private final HoursWorkedService hoursWorkedService; private final EmployeeService employeeService; @@ -111,16 +110,19 @@ public class HoursWorkedListView extends Main { } private void initializeView() { + getCurrentPageLayout().add(createAddHoursWorked()); setupFilters(); - add(createAddHoursWorked()); setupListHoursWorkedGrid(); - add(hoursWorkedGrid); - add(createActionButtons()); + getCurrentPageLayout().add(hoursWorkedGrid); + getCurrentPageLayout().add(createActionButtons()); } private void setupFilters() { - add(createEmployeeFilter()); - add(createTeamFilter()); + final HorizontalLayout hl = new HorizontalLayout(); + hl.add(createEmployeeFilter()); + hl.add(createTeamFilter()); + + getCurrentPageLayout().add(hl); } private void setupListHoursWorkedGrid() { @@ -184,8 +186,9 @@ public class HoursWorkedListView extends Main { } private Button createButton(final String label, final Runnable onClickAction) { - Button button = new Button(label); + final Button button = new Button(label); button.addClickListener(event -> onClickAction.run()); + return button; } @@ -199,7 +202,7 @@ public class HoursWorkedListView extends Main { private ComboBox createEmployeeFilter() { employeeFilter = new ComboBox<>("Empleado"); - List employees = new ArrayList<>(employeeService.findAllEmployees()); + final List employees = new ArrayList<>(employeeService.findAllEmployees()); employees.addFirst(createAllEmployeesOption()); employeeFilter.setItems(employees); employeeFilter.setItemLabelGenerator(this::getEmployeeFullName); @@ -210,6 +213,7 @@ public class HoursWorkedListView extends Main { teamFilter.getValue() ) ); + return employeeFilter; } diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java index 8387740..f870414 100644 --- a/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedView.java @@ -1,4 +1,5 @@ package com.primefactorsolutions.views; + import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.model.HoursWorked; import com.primefactorsolutions.model.Team; diff --git a/src/main/java/com/primefactorsolutions/views/InitAccountView.java b/src/main/java/com/primefactorsolutions/views/InitAccountView.java index 2cc8524..a3ce15d 100644 --- a/src/main/java/com/primefactorsolutions/views/InitAccountView.java +++ b/src/main/java/com/primefactorsolutions/views/InitAccountView.java @@ -13,6 +13,7 @@ import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; import com.vaadin.flow.server.auth.AnonymousAllowed; +@SuppressWarnings("unused") @Route("init-account") @PageTitle("PFS Intra") @AnonymousAllowed diff --git a/src/main/java/com/primefactorsolutions/views/PendingRequestsListView.java b/src/main/java/com/primefactorsolutions/views/PendingRequestsListView.java index 8ab68da..7163e18 100644 --- a/src/main/java/com/primefactorsolutions/views/PendingRequestsListView.java +++ b/src/main/java/com/primefactorsolutions/views/PendingRequestsListView.java @@ -6,7 +6,6 @@ import com.primefactorsolutions.service.TeamService; import com.primefactorsolutions.service.TimeOffRequestService; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.combobox.ComboBox; -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.router.PageTitle; @@ -26,7 +25,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE; @PageTitle("PendingRequests") @Route(value = "/pending-requests", layout = MainLayout.class) @PermitAll -public class PendingRequestsListView extends Main { +public class PendingRequestsListView extends BaseView { private final TimeOffRequestService requestService; private final EmployeeService employeeService; @@ -38,7 +37,6 @@ public class PendingRequestsListView extends Main { private ComboBox categoryFilter; private UUID selectedRequestId; - public PendingRequestsListView(final TimeOffRequestService requestService, final EmployeeService employeeService, final TeamService teamService) { @@ -52,14 +50,16 @@ public class PendingRequestsListView extends Main { private void initializeView() { setupFilters(); setupPendingRequestsGrid(); - add(pendingRequestsGrid); - add(createActionButtons()); + createActionButtons(); } private void setupFilters() { - add(createEmployeeFilter()); - add(createTeamFilter()); - add(createCategoryFilter()); + final HorizontalLayout hl = new HorizontalLayout(); + hl.add(createEmployeeFilter()); + hl.add(createTeamFilter()); + hl.add(createCategoryFilter()); + + getCurrentPageLayout().add(hl); } private void setupPendingRequestsGrid() { @@ -75,13 +75,16 @@ public class PendingRequestsListView extends Main { selectedRequestId = selectedRequest.getId(); } }); + + getCurrentPageLayout().add(pendingRequestsGrid); } - private HorizontalLayout createActionButtons() { - Button approveButton = createActionButton("Aprobar", TimeOffRequestStatus.APROBADO); - Button rejectButton = createActionButton("Rechazar", TimeOffRequestStatus.RECHAZADO); - Button closeButton = new Button("Salir", event -> navigateToMainView()); - return new HorizontalLayout(approveButton, rejectButton, closeButton); + 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) { diff --git a/src/main/java/com/primefactorsolutions/views/RequestsListView.java b/src/main/java/com/primefactorsolutions/views/RequestsListView.java index 029a66b..12b1715 100644 --- a/src/main/java/com/primefactorsolutions/views/RequestsListView.java +++ b/src/main/java/com/primefactorsolutions/views/RequestsListView.java @@ -7,7 +7,6 @@ import com.primefactorsolutions.service.TimeOffRequestService; import com.primefactorsolutions.service.VacationService; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.combobox.ComboBox; -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.router.PageTitle; @@ -29,7 +28,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE; @PageTitle("Requests") @Route(value = "/requests", layout = MainLayout.class) @PermitAll -public class RequestsListView extends Main { +public class RequestsListView extends BaseView { private final TimeOffRequestService requestService; private final EmployeeService employeeService; @@ -59,14 +58,17 @@ public class RequestsListView extends Main { requestService.updateRequestStatuses(); setupFilters(); setupRequestGrid(); - add(requestGrid); - add(createActionButtons()); + getCurrentPageLayout().add(requestGrid); + getCurrentPageLayout().add(createActionButtons()); } private void setupFilters() { - add(createEmployeeFilter()); - add(createTeamFilter()); - add(createStateFilter()); + final HorizontalLayout hl = new HorizontalLayout(); + hl.add(createEmployeeFilter()); + hl.add(createTeamFilter()); + hl.add(createStateFilter()); + + getCurrentPageLayout().add(hl); } private void setupRequestGrid() {