@ -1,15 +1,11 @@
|
||||
package com.primefactorsolutions.model;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.primefactorsolutions.service;
|
||||
|
||||
import com.primefactorsolutions.model.Candidate;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.repositories.EmployeeRepository;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,7 +13,7 @@ import java.util.UUID;
|
||||
public class EmployeeService {
|
||||
private final EmployeeRepository employeeRepository;
|
||||
|
||||
public EmployeeService(EmployeeRepository employeeRepository) {
|
||||
public EmployeeService(final EmployeeRepository employeeRepository) {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,15 @@ package com.primefactorsolutions.views;
|
||||
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
import com.vaadin.flow.component.ClickEvent;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.textfield.EmailField;
|
||||
import com.vaadin.flow.component.ComponentEventListener;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
import com.vaadin.flow.component.html.H2;
|
||||
import com.vaadin.flow.component.html.H3;
|
||||
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
|
||||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.function.ValueProvider;
|
||||
import com.vaadin.flow.router.BeforeEvent;
|
||||
import com.vaadin.flow.router.HasUrlParameter;
|
||||
import com.vaadin.flow.router.PageTitle;
|
||||
@ -13,6 +19,8 @@ import com.vaadin.flow.spring.annotation.SpringComponent;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.components.datepicker.VDatePicker;
|
||||
import org.vaadin.firitin.components.grid.VGrid;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.util.List;
|
||||
@ -23,22 +31,106 @@ import java.util.UUID;
|
||||
@Scope("prototype")
|
||||
@PageTitle("Employee")
|
||||
@Route(value = "/employees", layout = MainLayout.class)
|
||||
|
||||
public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> {
|
||||
private final EmployeeService employeeService;
|
||||
|
||||
private TextField name = null;
|
||||
private TextField lastName = null;
|
||||
private VDatePicker birthday = null;
|
||||
private TextField birthCity = null;
|
||||
private TextField maritalStatus = null;
|
||||
private TextField residenceAddress = null;
|
||||
private TextField phoneNumber = null;
|
||||
private TextField personalEmail = null;
|
||||
|
||||
private TextField emergencyCName;
|
||||
private TextField emergencyCAddress;
|
||||
private TextField emergencyCPhone;
|
||||
private TextField emergencyCEmail;
|
||||
|
||||
public EmployeeView(final EmployeeService employeeService) {
|
||||
super(Employee.class);
|
||||
this.employeeService = employeeService;
|
||||
final H2 title = new H2("INFORMACION GENERAL DEL EMPLEADO");
|
||||
final H3 subtitle = new H3("INFORMACION PERSONAL");
|
||||
final HorizontalLayout hl = new HorizontalLayout();
|
||||
final HorizontalLayout hf = new HorizontalLayout();
|
||||
name = new TextField();
|
||||
name.setWidthFull();
|
||||
name.setLabel("Name");
|
||||
name.setLabel("Nombres: ");
|
||||
|
||||
lastName = new TextField();
|
||||
lastName.setWidthFull();
|
||||
lastName.setLabel("Apellidos: ");
|
||||
|
||||
birthday = new VDatePicker();
|
||||
birthday.setWidthFull();
|
||||
birthday.setLabel("Fecha de Nacimiento:");
|
||||
|
||||
birthCity = new TextField();
|
||||
birthCity.setWidthFull();
|
||||
birthCity.setLabel("Ciudad y pais de nacimiento: ");
|
||||
|
||||
maritalStatus = new TextField();
|
||||
maritalStatus.setWidthFull();
|
||||
maritalStatus.setLabel("Estado Civil: ");
|
||||
|
||||
residenceAddress = new TextField();
|
||||
residenceAddress.setWidthFull();
|
||||
residenceAddress.setLabel("Direccion de Residencia: ");
|
||||
|
||||
phoneNumber = new TextField();
|
||||
phoneNumber.setWidthFull();
|
||||
phoneNumber.setLabel("Telefono: ");
|
||||
|
||||
personalEmail = new TextField();
|
||||
personalEmail.setWidthFull();
|
||||
personalEmail.setLabel("E-mail: ");
|
||||
|
||||
final H3 secondsubtitle = new H3("DATOS DE CONTACTO DE EMERGENCIA");
|
||||
|
||||
emergencyCName = new TextField();
|
||||
emergencyCName.setWidthFull();
|
||||
emergencyCName.setLabel("Nombres y Apellidos de contacto: ");
|
||||
|
||||
emergencyCAddress = new TextField();
|
||||
emergencyCAddress.setWidthFull();
|
||||
emergencyCAddress.setLabel("Direccion de contacto: ");
|
||||
|
||||
emergencyCPhone = new TextField();
|
||||
emergencyCPhone.setWidthFull();
|
||||
emergencyCPhone.setLabel("Telefono de contacto: ");
|
||||
|
||||
emergencyCEmail = new TextField();
|
||||
emergencyCEmail.setWidthFull();
|
||||
emergencyCEmail.setLabel("Email de contacto: ");
|
||||
|
||||
final VGrid<Employee> grid = new VGrid<>(Employee.class);
|
||||
|
||||
grid.addComponentColumn((ValueProvider<Employee, Component>) employee -> {
|
||||
final Button edit = new Button("Edit");
|
||||
edit.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
// no-op
|
||||
});
|
||||
return edit;
|
||||
});
|
||||
|
||||
grid.addComponentColumn((ValueProvider<Employee, Component>) employee -> {
|
||||
final Button save = new Button("Save");
|
||||
save.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
// no-op
|
||||
});
|
||||
return save;
|
||||
});
|
||||
|
||||
setSavedHandler((SavedHandler<Employee>) employee -> {
|
||||
final Employee saved = employeeService.createOrUpdate(employee);
|
||||
setEntityWithEnabledSave(saved);
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -53,7 +145,21 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
|
||||
|
||||
@Override
|
||||
protected List<Component> getFormComponents() {
|
||||
return List.of(name);
|
||||
}
|
||||
return List.of(
|
||||
name,
|
||||
lastName,
|
||||
birthday,
|
||||
birthCity,
|
||||
maritalStatus,
|
||||
residenceAddress,
|
||||
phoneNumber,
|
||||
personalEmail,
|
||||
emergencyCName,
|
||||
emergencyCAddress,
|
||||
emergencyCPhone,
|
||||
emergencyCEmail
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user