improve tables layout
All checks were successful
Builder / Build-Project (push) Successful in 2m44s

This commit is contained in:
alex 2024-11-17 17:14:23 -05:00
parent 2a561a925c
commit 54ff167124
9 changed files with 71 additions and 42 deletions

Binary file not shown.

View File

@ -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);
}
}

View File

@ -9,8 +9,8 @@ import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.grid.GridSortOrder; 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.html.Span;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.data.provider.SortDirection; import com.vaadin.flow.data.provider.SortDirection;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
@ -26,13 +26,12 @@ import java.util.List;
import static com.primefactorsolutions.views.Constants.PAGE_SIZE; import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@PageTitle("Documents") @PageTitle("Documents")
@Route(value = "/documents", layout = MainLayout.class) @Route(value = "/documents", layout = MainLayout.class)
@PermitAll @PermitAll
public class DocumentsListView extends Main { public class DocumentsListView extends BaseView {
private final DocumentService documentService; private final DocumentService documentService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
@ -48,11 +47,16 @@ public class DocumentsListView extends Main {
} }
private void initializeView() { 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(); configureDocumentGrid();
add(createActionButton("Add Document", this::navigateToAddDocumentView)); getCurrentPageLayout().add(documentGrid);
add(createDocumentTypeFilter());
add(createEmployeeFilter());
add(documentGrid);
} }
private void configureDocumentGrid() { private void configureDocumentGrid() {

View File

@ -4,7 +4,6 @@ import com.primefactorsolutions.model.Employee;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.H2; 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.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent; import com.vaadin.flow.spring.annotation.SpringComponent;
@ -16,13 +15,12 @@ import org.springframework.context.annotation.Scope;
import java.util.List; import java.util.List;
@SpringComponent @SpringComponent
@Scope("prototype") @Scope("prototype")
@PageTitle("Employees") @PageTitle("Employees")
@Route(value = "/employees", layout = MainLayout.class) @Route(value = "/employees", layout = MainLayout.class)
@PermitAll @PermitAll
public class EmployeesListView extends Main { public class EmployeesListView extends BaseView {
private final EmployeeService employeeService; private final EmployeeService employeeService;
private final PagingGrid<Employee> table = new PagingGrid<>(Employee.class); private final PagingGrid<Employee> table = new PagingGrid<>(Employee.class);
@ -34,10 +32,10 @@ public class EmployeesListView extends Main {
} }
private void setupView() { private void setupView() {
add(new H2("Employee List")); getCurrentPageLayout().add(new H2("Employee List"));
configureTable(); configureTable();
add(createAddEmployeeButton()); getCurrentPageLayout().add(createAddEmployeeButton());
add(table); getCurrentPageLayout().add(table);
} }
private void configureTable() { private void configureTable() {

View File

@ -8,7 +8,6 @@ import com.primefactorsolutions.service.HoursWorkedService;
import com.primefactorsolutions.service.TeamService; import com.primefactorsolutions.service.TeamService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; 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.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
@ -30,7 +29,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@Scope("prototype") @Scope("prototype")
@PageTitle("Registro de Horas Trabajadas") @PageTitle("Registro de Horas Trabajadas")
@Route(value = "/hours-worked-list", layout = MainLayout.class) @Route(value = "/hours-worked-list", layout = MainLayout.class)
public class HoursWorkedListView extends Main { public class HoursWorkedListView extends BaseView {
private final HoursWorkedService hoursWorkedService; private final HoursWorkedService hoursWorkedService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
@ -111,16 +110,19 @@ public class HoursWorkedListView extends Main {
} }
private void initializeView() { private void initializeView() {
getCurrentPageLayout().add(createAddHoursWorked());
setupFilters(); setupFilters();
add(createAddHoursWorked());
setupListHoursWorkedGrid(); setupListHoursWorkedGrid();
add(hoursWorkedGrid); getCurrentPageLayout().add(hoursWorkedGrid);
add(createActionButtons()); getCurrentPageLayout().add(createActionButtons());
} }
private void setupFilters() { private void setupFilters() {
add(createEmployeeFilter()); final HorizontalLayout hl = new HorizontalLayout();
add(createTeamFilter()); hl.add(createEmployeeFilter());
hl.add(createTeamFilter());
getCurrentPageLayout().add(hl);
} }
private void setupListHoursWorkedGrid() { private void setupListHoursWorkedGrid() {
@ -184,8 +186,9 @@ public class HoursWorkedListView extends Main {
} }
private Button createButton(final String label, final Runnable onClickAction) { 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()); button.addClickListener(event -> onClickAction.run());
return button; return button;
} }
@ -199,7 +202,7 @@ public class HoursWorkedListView extends Main {
private ComboBox<Employee> createEmployeeFilter() { private ComboBox<Employee> createEmployeeFilter() {
employeeFilter = new ComboBox<>("Empleado"); employeeFilter = new ComboBox<>("Empleado");
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees()); final List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
employees.addFirst(createAllEmployeesOption()); employees.addFirst(createAllEmployeesOption());
employeeFilter.setItems(employees); employeeFilter.setItems(employees);
employeeFilter.setItemLabelGenerator(this::getEmployeeFullName); employeeFilter.setItemLabelGenerator(this::getEmployeeFullName);
@ -210,6 +213,7 @@ public class HoursWorkedListView extends Main {
teamFilter.getValue() teamFilter.getValue()
) )
); );
return employeeFilter; return employeeFilter;
} }

View File

@ -1,4 +1,5 @@
package com.primefactorsolutions.views; package com.primefactorsolutions.views;
import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.model.Employee;
import com.primefactorsolutions.model.HoursWorked; import com.primefactorsolutions.model.HoursWorked;
import com.primefactorsolutions.model.Team; import com.primefactorsolutions.model.Team;

View File

@ -13,6 +13,7 @@ import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.server.auth.AnonymousAllowed; import com.vaadin.flow.server.auth.AnonymousAllowed;
@SuppressWarnings("unused")
@Route("init-account") @Route("init-account")
@PageTitle("PFS Intra") @PageTitle("PFS Intra")
@AnonymousAllowed @AnonymousAllowed

View File

@ -6,7 +6,6 @@ import com.primefactorsolutions.service.TeamService;
import com.primefactorsolutions.service.TimeOffRequestService; import com.primefactorsolutions.service.TimeOffRequestService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; 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.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
@ -26,7 +25,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@PageTitle("PendingRequests") @PageTitle("PendingRequests")
@Route(value = "/pending-requests", layout = MainLayout.class) @Route(value = "/pending-requests", layout = MainLayout.class)
@PermitAll @PermitAll
public class PendingRequestsListView extends Main { public class PendingRequestsListView extends BaseView {
private final TimeOffRequestService requestService; private final TimeOffRequestService requestService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
@ -38,7 +37,6 @@ public class PendingRequestsListView extends Main {
private ComboBox<TimeOffRequestType> categoryFilter; private ComboBox<TimeOffRequestType> categoryFilter;
private UUID selectedRequestId; private UUID selectedRequestId;
public PendingRequestsListView(final TimeOffRequestService requestService, public PendingRequestsListView(final TimeOffRequestService requestService,
final EmployeeService employeeService, final EmployeeService employeeService,
final TeamService teamService) { final TeamService teamService) {
@ -52,14 +50,16 @@ public class PendingRequestsListView extends Main {
private void initializeView() { private void initializeView() {
setupFilters(); setupFilters();
setupPendingRequestsGrid(); setupPendingRequestsGrid();
add(pendingRequestsGrid); createActionButtons();
add(createActionButtons());
} }
private void setupFilters() { private void setupFilters() {
add(createEmployeeFilter()); final HorizontalLayout hl = new HorizontalLayout();
add(createTeamFilter()); hl.add(createEmployeeFilter());
add(createCategoryFilter()); hl.add(createTeamFilter());
hl.add(createCategoryFilter());
getCurrentPageLayout().add(hl);
} }
private void setupPendingRequestsGrid() { private void setupPendingRequestsGrid() {
@ -75,13 +75,16 @@ public class PendingRequestsListView extends Main {
selectedRequestId = selectedRequest.getId(); selectedRequestId = selectedRequest.getId();
} }
}); });
getCurrentPageLayout().add(pendingRequestsGrid);
} }
private HorizontalLayout createActionButtons() { private void createActionButtons() {
Button approveButton = createActionButton("Aprobar", TimeOffRequestStatus.APROBADO); final Button approveButton = createActionButton("Aprobar", TimeOffRequestStatus.APROBADO);
Button rejectButton = createActionButton("Rechazar", TimeOffRequestStatus.RECHAZADO); final Button rejectButton = createActionButton("Rechazar", TimeOffRequestStatus.RECHAZADO);
Button closeButton = new Button("Salir", event -> navigateToMainView()); final Button closeButton = new Button("Salir", event -> navigateToMainView());
return new HorizontalLayout(approveButton, rejectButton, closeButton);
getCurrentPageLayout().add(new HorizontalLayout(approveButton, rejectButton, closeButton));
} }
private Button createActionButton(final String caption, final TimeOffRequestStatus status) { private Button createActionButton(final String caption, final TimeOffRequestStatus status) {

View File

@ -7,7 +7,6 @@ import com.primefactorsolutions.service.TimeOffRequestService;
import com.primefactorsolutions.service.VacationService; import com.primefactorsolutions.service.VacationService;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox; 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.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
@ -29,7 +28,7 @@ import static com.primefactorsolutions.views.Constants.PAGE_SIZE;
@PageTitle("Requests") @PageTitle("Requests")
@Route(value = "/requests", layout = MainLayout.class) @Route(value = "/requests", layout = MainLayout.class)
@PermitAll @PermitAll
public class RequestsListView extends Main { public class RequestsListView extends BaseView {
private final TimeOffRequestService requestService; private final TimeOffRequestService requestService;
private final EmployeeService employeeService; private final EmployeeService employeeService;
@ -59,14 +58,17 @@ public class RequestsListView extends Main {
requestService.updateRequestStatuses(); requestService.updateRequestStatuses();
setupFilters(); setupFilters();
setupRequestGrid(); setupRequestGrid();
add(requestGrid); getCurrentPageLayout().add(requestGrid);
add(createActionButtons()); getCurrentPageLayout().add(createActionButtons());
} }
private void setupFilters() { private void setupFilters() {
add(createEmployeeFilter()); final HorizontalLayout hl = new HorizontalLayout();
add(createTeamFilter()); hl.add(createEmployeeFilter());
add(createStateFilter()); hl.add(createTeamFilter());
hl.add(createStateFilter());
getCurrentPageLayout().add(hl);
} }
private void setupRequestGrid() { private void setupRequestGrid() {