#4 Perfil de Empleado - Revisar campos del Formulario

This commit is contained in:
Melina Gutierrez 2024-09-26 15:26:34 -04:00
parent 8bf4a97c88
commit b7a63b8c78
2 changed files with 152 additions and 95 deletions

View File

@ -19,8 +19,7 @@
private LocalDate birthday; private LocalDate birthday;
private String birthCity; private String birthCity;
private String age; private String age;
@Enumerated(EnumType.STRING)
private MaritalStatus maritalStatus;
private String residenceAddress; private String residenceAddress;
private String phoneNumber; private String phoneNumber;
private String personalEmail; private String personalEmail;
@ -33,8 +32,6 @@
private String numberOfChildren; private String numberOfChildren;
private String departmentAndProvinceResidence; private String departmentAndProvinceResidence;
private String gender;
private String ci; private String ci;
private String issuedIn; private String issuedIn;
@ -83,12 +80,21 @@
ACTIVE, ACTIVE,
INACTIVE INACTIVE
} }
@Enumerated(EnumType.STRING)
private MaritalStatus maritalStatus;
public enum MaritalStatus { public enum MaritalStatus {
SINGLE, SINGLE,
MARRIED, MARRIED,
WIDOWED, WIDOWED,
DIVORCED DIVORCED
} }
@Enumerated(EnumType.STRING)
private Gender gender;
public enum Gender {
MALE,
FEMALE
}
public Status getStatus() { public Status getStatus() {
return status; return status;
} }

View File

@ -6,7 +6,6 @@ import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant; import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.combobox.ComboBox; import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.datepicker.DatePicker;
import com.vaadin.flow.component.html.H2; import com.vaadin.flow.component.html.H2;
import com.vaadin.flow.component.html.H3; import com.vaadin.flow.component.html.H3;
import com.vaadin.flow.component.html.Image; import com.vaadin.flow.component.html.Image;
@ -37,89 +36,95 @@ import java.util.UUID;
@PageTitle("Employee") @PageTitle("Employee")
@Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class) @Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class)
public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> { public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> {
private static final String SAVE_BUTTON_TEXT = "Save";
private static final String EDIT_BUTTON_TEXT = "Edit";
private static final String NOTIFICATION_SAVE_SUCCESS = "Employee saved successfully.";
private static final String NOTIFICATION_VALIDATE_ERROR = "Please complete the required fields correctly.";
private static final String PHONE_NUMBER_ERROR_MESSAGE = "El teléfono debe contener solo números.";
private final EmployeeService employeeService; private final EmployeeService employeeService;
// TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente. // TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente.
// INFORMACION PERSONAL
private final TextField userName = createTextField("Username: ", 30, true); private final TextField userName = createTextField("Username: ", 30, true);
private final TextField firstName = createTextField("Nombres: ", 30, true); private final TextField firstName = createTextField("Nombres: ", 30, true);
private final TextField lastName = createTextField("Apellidos", 30, true); private final TextField lastName = createTextField("Apellidos", 30, true);
private final ComboBox<Employee.Status> status = createStatusComboBox(); private final ComboBox<Employee.Status> status = createStatusComboBox();
private final ComboBox<Employee.Gender> gender = createGenderComboBox();
private final VDatePicker birthday = new VDatePicker("Fecha de Nacimiento"); private final VDatePicker birthday = new VDatePicker("Fecha de Nacimiento");
private final TextField age = createTextField("Edad", 3, false);
private final TextField birthCity = createTextField("Ciudad y País de Nacimiento", 20, false); private final TextField birthCity = createTextField("Ciudad y País de Nacimiento", 20, false);
private final TextField residenceAddress = createTextField("Dirección de Domicilio Actual", 50, false);
private final TextField localAddress = createTextField("Dep/Provincia de Residencia", 10, false);
private final ComboBox<Employee.MaritalStatus> maritalStatus = createMaritalStatusComboBox(); private final ComboBox<Employee.MaritalStatus> maritalStatus = createMaritalStatusComboBox();
private final TextField residenceAddress = createTextField("Dirección de Residencia", 50, false); private final TextField numberOfChildren = createTextField("Numero de Hijos", 3, false);
private final TextField ci = createTextField("CI", 30, false);
private final TextField issuedIn = createTextField("Expedido en ", 30, false);
private final TextField phoneNumber = createTextField("Teléfono", 8, false); private final TextField phoneNumber = createTextField("Teléfono", 8, false);
private final EmailField personalEmail = createEmailField("E-mail"); private final EmailField personalEmail = createEmailField("E-mail");
private final TextField cod = createTextField("Codigo de Empleado", 30, false);
private final TextField position = createTextField("Cargo", 30, false); private final TextField position = createTextField("Cargo", 30, false);
private final TextField team = createTextField("Equipo", 30, false); private final TextField team = createTextField("Equipo", 30, false);
private final TextField leadManager = createTextField("Lead/Manager", 30, false);
private final TextField project = createTextField("Proyecto", 30, false);
private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false); private final TextField emergencyCName = createTextField("Nombres y Apellidos de Contacto", 50, false);
private final TextField emergencyCAddress = createTextField("Dirección de Contacto", 50, false); private final TextField emergencyCAddress = createTextField("Dirección de Contacto", 50, false);
private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false); private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false);
private final EmailField emergencyCEmail = createEmailField("Email de Contacto"); private final EmailField emergencyCEmail = createEmailField("Email de Contacto");
private final MemoryBuffer buffer = new MemoryBuffer(); private final MemoryBuffer buffer = new MemoryBuffer();
private final Upload upload = new Upload(buffer); private final Upload upload = new Upload(buffer);
private final Image profileImagePreview = new Image(); private final Image profileImagePreview = new Image();
//INFORMACION PROFESIONAL
private final TextField pTitle1 = createTextField("Título 1", 30, false);
private final TextField pTitle2 = createTextField("Título 2", 30, false);
private final TextField pTitle3 = createTextField("Título 3", 30, false);
private final TextField pStudy1 = createTextField("Estudio 1", 30, false);
private final TextField pStudy2 = createTextField("Estudio 2", 30, false);
private final TextField pStudy3 = createTextField("Estudio 3", 30, false);
private final TextField certification1 = createTextField("Certificación 1", 30, false);
private final TextField certification2 = createTextField("Certificación 2", 30, false);
private final TextField certification3 = createTextField("Certificación 3", 30, false);
private final TextField certification4 = createTextField("Certificación 4", 30, false);
private final TextField recognition = createTextField("Reconocimientos", 30, false);
private final TextField achievements = createTextField("Logros Profesionales", 30, false);
private final TextField language = createTextField("Idioma", 30, false);
private final TextField languageLevel = createTextField("Nivel de Idioma", 30, false);
//INFORMACION DE CONTRATACION
private final VDatePicker dateOfEntry = new VDatePicker("Fecha de Ingreso");
private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro");
private final TextField contractType = createTextField("Tipo de Contratación", 30, false);
private final TextField seniority = createTextField("Antiguedad", 30, false);
private final TextField salary = createTextField("Salario", 30, false);
private final TextField bankName = createTextField("Banco", 30, false);
private final TextField accountNumber = createTextField("Nro. de Cuenta", 30, false);
private final TextField gpss = createTextField("Código Único de Asegurado (GPSS)", 30, false);
private final TextField sss = createTextField("Matricula de Asegurado (SSS)", 30, false);
private final TextField beneficiaries = createTextField("Derechohabientes", 30, false);
//TITULOS PARA INFORMACION PERSONAL
private final H2 infoPer = new H2("Información Personal");
private final H3 infoGenr = new H3("Información General");
private final H3 contEmerg = new H3("Contacto de Emergencia");
//TITULOS PARA INFORMACIÓN PROFESIONAL
private final H2 infProf = new H2("Información Profesional");
private final H3 titulos = new H3("Titulos Profesionales y Estudios Realizados");
private final H3 certif = new H3("Certificaciones Profesionales");
private final H3 logros = new H3("Otros Logros y Reconocimientos");
private final H3 idioma = new H3("Dominio de Idiomas");
//TITULOS PARA INFORMACIÓN ADMINISTRATIVA
private final H2 infoAdm = new H2("Información Administrativa");
private final H3 infoCont = new H3("Información de Contratación");
private final H3 datBanc = new H3("Datos Bancados");
private final H3 datGest = new H3("Datos Gestora Pública y Seguro Social");
//BOTONES
private static final String SAVE_BUTTON_TEXT = "Save";
private static final String EDIT_BUTTON_TEXT = "Edit";
private final Button saveButton = new Button(SAVE_BUTTON_TEXT, e -> saveEmployee()); private final Button saveButton = new Button(SAVE_BUTTON_TEXT, e -> saveEmployee());
private final Button editButton = new Button(EDIT_BUTTON_TEXT, e -> enableEditMode()); private final Button editButton = new Button(EDIT_BUTTON_TEXT, e -> enableEditMode());
private final H2 mt = new H2("Información General del Empleado"); //ALERTAS
private final H3 fs = new H3("Información Personal"); private static final String NOTIFICATION_SAVE_SUCCESS = "Employee saved successfully.";
private final H3 ss = new H3("Datos de Contacto de Emergencia"); private static final String NOTIFICATION_VALIDATE_ERROR = "Please complete the required fields correctly.";
private final H3 si = new H3("Foto del Empleado"); private static final String PHONE_NUMBER_ERROR_MESSAGE = "El teléfono debe contener solo números.";
private final TextField age = createTextField("Edad", 3, false);
private final TextField gender = createTextField("Genero:", 10, false);
private final TextField numberOfChildren = createTextField("Number of Children", 3, false);
private final TextField ci = createTextField("CI", 30, false);
private final TextField issuedIn = createTextField("Issued In", 30, false);
private final TextField pTitle1 = createTextField("Professional Title 1", 30, false);
private final TextField pTitle2 = createTextField("Professional Title 2", 30, false);
private final TextField pTitle3 = createTextField("Professional Title 3", 30, false);
private final TextField pStudy1 = createTextField("Study 1", 30, false);
private final TextField pStudy2 = createTextField("Study 2", 30, false);
private final TextField pStudy3 = createTextField("Study 3", 30, false);
private final TextField certification1 = createTextField("Certification 1", 30, false);
private final TextField certification2 = createTextField("Certification 2", 30, false);
private final TextField certification3 = createTextField("Certification 3", 30, false);
private final TextField certification4 = createTextField("Certification 4", 30, false);
private final TextField recognition = createTextField("Recognition", 30, false);
private final TextField achievements = createTextField("Achievements", 30, false);
private final TextField language = createTextField("Language", 30, false);
private final TextField languageLevel = createTextField("Language Level", 30, false);
private final TextField cod = createTextField("Code", 30, false);
private final TextField leadManager = createTextField("Lead Manager", 30, false);
private final TextField project = createTextField("Project", 30, false);
private final DatePicker dateOfEntry = new DatePicker("Date of Entry");
private final DatePicker dateOfExit = new DatePicker("Date of Exit");
private final TextField contractType = createTextField("Contract Type", 30, false);
private final TextField seniority = createTextField("Seniority", 30, false);
private final TextField salary = createTextField("Salary", 30, false);
private final TextField bankName = createTextField("Bank Name", 30, false);
private final TextField accountNumber = createTextField("Account Number", 30, false);
private final TextField gpss = createTextField("GPSS", 30, false);
private final TextField sss = createTextField("SSS", 30, false);
private final TextField beneficiaries = createTextField("Beneficiaries", 30, false);
public EmployeeView(final EmployeeService employeeService) { public EmployeeView(final EmployeeService employeeService) {
super(Employee.class); super(Employee.class);
this.employeeService = employeeService; this.employeeService = employeeService;
@ -181,34 +186,62 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
HorizontalLayout mainLayout = new HorizontalLayout(); HorizontalLayout mainLayout = new HorizontalLayout();
VerticalLayout contentLayout1 = createContentLayout(); VerticalLayout contentLayout1 = createContentLayout();
VerticalLayout contentLayout2 = createContentLayout(); VerticalLayout contentLayout2 = createContentLayout();
VerticalLayout contentLayout3 = createContentLayout();
contentLayout1.add( contentLayout1.add(
mt, infoPer,
fs, infoGenr,
firstName, upload, profileImagePreview,
lastName, firstName, lastName,
status, gender, status,
birthday, birthday, age,
age, birthCity, residenceAddress, localAddress,
birthCity, maritalStatus, ci, issuedIn, numberOfChildren,
maritalStatus, phoneNumber, personalEmail,
numberOfChildren, cod, position, team, leadManager, project,
residenceAddress, contEmerg,
phoneNumber, emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail);
personalEmail,
position,
team, gender, status, ci, issuedIn);
contentLayout2.add( contentLayout2.add(
ss, emergencyCName, emergencyCAddress, infProf,
emergencyCPhone, emergencyCEmail, pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, titulos,
pTitle1, pTitle2, pTitle3,
pStudy1, pStudy2, pStudy3,
certif,
certification1, certification2, certification3, certification4, certification1, certification2, certification3, certification4,
recognition, achievements, language, languageLevel, logros,
cod, leadManager, project, dateOfEntry, dateOfExit, recognition, achievements,
contractType, seniority, salary, bankName, accountNumber, idioma,
gpss, sss, beneficiaries, si, upload, language, languageLevel
profileImagePreview, saveButton, editButton); );
contentLayout3.add(
infoAdm,
infoCont,
dateOfEntry, dateOfExit,
contractType, seniority, salary,
datBanc,
bankName, accountNumber,
datGest,
gpss, sss, beneficiaries
);
mainLayout.add(contentLayout1, contentLayout2); mainLayout.add(contentLayout1, infProf,
titulos,
pTitle1, pTitle2, pTitle3,
pStudy1, pStudy2, pStudy3,
certif,
certification1, certification2, certification3, certification4,
logros,
recognition, achievements,
idioma,
language, languageLevel,
infoAdm,
infoCont,
dateOfEntry, dateOfExit,
contractType, seniority, salary,
datBanc,
bankName, accountNumber,
datGest,
gpss, sss, beneficiaries, saveButton, editButton);
addClassName("main-layout"); addClassName("main-layout");
} }
@ -223,7 +256,15 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
ComboBox<Employee.Status> comboBox = new ComboBox<>("Estado"); ComboBox<Employee.Status> comboBox = new ComboBox<>("Estado");
comboBox.setItems(Employee.Status.values()); comboBox.setItems(Employee.Status.values());
comboBox.setItemLabelGenerator(Employee.Status::name); comboBox.setItemLabelGenerator(Employee.Status::name);
comboBox.setRequiredIndicatorVisible(true); // Indicador de campo requerido comboBox.setRequiredIndicatorVisible(true);
return comboBox;
}
private ComboBox<Employee.Gender> createGenderComboBox() {
ComboBox<Employee.Gender> comboBox = new ComboBox<>("Genero");
comboBox.setItems(Employee.Gender.values());
comboBox.setItemLabelGenerator(Employee.Gender::name);
comboBox.setRequiredIndicatorVisible(true);
return comboBox; return comboBox;
} }
@ -429,16 +470,26 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
@Override @Override
protected List<Component> getFormComponents() { protected List<Component> getFormComponents() {
return List.of( return List.of(
mt, fs, userName, firstName, lastName, status, birthday, age, birthCity, maritalStatus, infoPer,
residenceAddress, phoneNumber, personalEmail, position, team, ss, emergencyCName, infoGenr,
emergencyCAddress, emergencyCPhone, emergencyCEmail, age, upload, profileImagePreview,
gender, status, ci, issuedIn, firstName, lastName,
pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, gender, status,
certification1, certification2, certification3, certification4, birthday, age,
recognition, achievements, language, languageLevel, birthCity, residenceAddress, localAddress,
cod, leadManager, project, dateOfEntry, dateOfExit, maritalStatus, ci, issuedIn, numberOfChildren,
contractType, seniority, salary, bankName, accountNumber, phoneNumber, personalEmail,
gpss, sss, beneficiaries, si, upload, profileImagePreview, cod, position, team, leadManager, project,
contEmerg, emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail,
infProf,
titulos, pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3,
certif, certification1, certification2, certification3, certification4,
logros, recognition, achievements,
idioma, language, languageLevel,
infoAdm,
infoCont, dateOfEntry, dateOfExit, contractType, seniority, salary,
datBanc, bankName, accountNumber,
datGest, gpss, sss, beneficiaries,
saveButton, editButton saveButton, editButton
); );
} }