This commit is contained in:
parent
2a561a925c
commit
54ff167124
Binary file not shown.
16
src/main/java/com/primefactorsolutions/views/BaseView.java
Normal file
16
src/main/java/com/primefactorsolutions/views/BaseView.java
Normal 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);
|
||||
}
|
||||
}
|
@ -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() {
|
||||
|
@ -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<Employee> 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() {
|
||||
|
@ -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<Employee> createEmployeeFilter() {
|
||||
employeeFilter = new ComboBox<>("Empleado");
|
||||
List<Employee> employees = new ArrayList<>(employeeService.findAllEmployees());
|
||||
final List<Employee> 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;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package com.primefactorsolutions.views;
|
||||
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.model.HoursWorked;
|
||||
import com.primefactorsolutions.model.Team;
|
||||
|
@ -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
|
||||
|
@ -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<TimeOffRequestType> 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) {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user