From 831f9ec9a55637fed852af1e28e2c85815eb5372 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 26 Sep 2024 21:47:43 -0400 Subject: [PATCH] merge conflicts --- .../primefactorsolutions/model/Employee.java | 14 +- .../views/EmployeeView.java | 233 +++++++++++------- 2 files changed, 152 insertions(+), 95 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 1a76c42..142492e 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -23,8 +23,7 @@ private LocalDate birthday; private String birthCity; private String age; - @Enumerated(EnumType.STRING) - private MaritalStatus maritalStatus; + private String residenceAddress; private String phoneNumber; private String personalEmail; @@ -37,8 +36,6 @@ private String numberOfChildren; private String departmentAndProvinceResidence; - private String gender; - private String ci; private String issuedIn; @@ -123,12 +120,21 @@ ACTIVE, INACTIVE } + @Enumerated(EnumType.STRING) + private MaritalStatus maritalStatus; public enum MaritalStatus { SINGLE, MARRIED, WIDOWED, DIVORCED } + @Enumerated(EnumType.STRING) + private Gender gender; + public enum Gender { + MALE, + FEMALE + } + public Status getStatus() { return status; } diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index a024f02..26bde89 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -6,7 +6,6 @@ import com.vaadin.flow.component.Component; import com.vaadin.flow.component.button.Button; import com.vaadin.flow.component.button.ButtonVariant; 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.H3; import com.vaadin.flow.component.html.Image; @@ -37,89 +36,95 @@ import java.util.UUID; @PageTitle("Employee") @Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class) public class EmployeeView extends BeanValidationForm implements HasUrlParameter { - - 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; // 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 firstName = createTextField("Nombres: ", 30, true); private final TextField lastName = createTextField("Apellidos", 30, true); private final ComboBox status = createStatusComboBox(); + private final ComboBox gender = createGenderComboBox(); 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 residenceAddress = createTextField("Dirección de Domicilio Actual", 50, false); + private final TextField localAddress = createTextField("Dep/Provincia de Residencia", 10, false); private final ComboBox 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 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 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 emergencyCAddress = createTextField("Dirección de Contacto", 50, false); private final TextField emergencyCPhone = createTextField("Teléfono de Contacto", 8, false); private final EmailField emergencyCEmail = createEmailField("Email de Contacto"); - private final MemoryBuffer buffer = new MemoryBuffer(); private final Upload upload = new Upload(buffer); 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 editButton = new Button(EDIT_BUTTON_TEXT, e -> enableEditMode()); - private final H2 mt = new H2("Información General del Empleado"); - private final H3 fs = new H3("Información Personal"); - private final H3 ss = new H3("Datos de Contacto de Emergencia"); - private final H3 si = new H3("Foto del Empleado"); + //ALERTAS + 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 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) { super(Employee.class); this.employeeService = employeeService; @@ -181,34 +186,62 @@ public class EmployeeView extends BeanValidationForm implements HasUrl HorizontalLayout mainLayout = new HorizontalLayout(); VerticalLayout contentLayout1 = createContentLayout(); VerticalLayout contentLayout2 = createContentLayout(); + VerticalLayout contentLayout3 = createContentLayout(); contentLayout1.add( - mt, - fs, - firstName, - lastName, - status, - birthday, - age, - birthCity, - maritalStatus, - numberOfChildren, - residenceAddress, - phoneNumber, - personalEmail, - position, - team, gender, status, ci, issuedIn); + infoPer, + infoGenr, + upload, profileImagePreview, + firstName, lastName, + gender, status, + birthday, age, + birthCity, residenceAddress, localAddress, + maritalStatus, ci, issuedIn, numberOfChildren, + phoneNumber, personalEmail, + cod, position, team, leadManager, project, + contEmerg, + emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail); contentLayout2.add( - ss, emergencyCName, emergencyCAddress, - emergencyCPhone, emergencyCEmail, pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, + infProf, + titulos, + pTitle1, pTitle2, pTitle3, + pStudy1, pStudy2, pStudy3, + certif, certification1, certification2, certification3, certification4, - recognition, achievements, language, languageLevel, - cod, leadManager, project, dateOfEntry, dateOfExit, - contractType, seniority, salary, bankName, accountNumber, - gpss, sss, beneficiaries, si, upload, - profileImagePreview, saveButton, editButton); + logros, + recognition, achievements, + idioma, + language, languageLevel + ); + 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"); } @@ -223,7 +256,15 @@ public class EmployeeView extends BeanValidationForm implements HasUrl ComboBox comboBox = new ComboBox<>("Estado"); comboBox.setItems(Employee.Status.values()); comboBox.setItemLabelGenerator(Employee.Status::name); - comboBox.setRequiredIndicatorVisible(true); // Indicador de campo requerido + comboBox.setRequiredIndicatorVisible(true); + return comboBox; + } + + private ComboBox createGenderComboBox() { + ComboBox comboBox = new ComboBox<>("Genero"); + comboBox.setItems(Employee.Gender.values()); + comboBox.setItemLabelGenerator(Employee.Gender::name); + comboBox.setRequiredIndicatorVisible(true); return comboBox; } @@ -429,16 +470,26 @@ public class EmployeeView extends BeanValidationForm implements HasUrl @Override protected List getFormComponents() { return List.of( - mt, fs, username, firstName, lastName, status, birthday, age, birthCity, maritalStatus, - residenceAddress, phoneNumber, personalEmail, position, team, ss, emergencyCName, - emergencyCAddress, emergencyCPhone, emergencyCEmail, age, - gender, status, ci, issuedIn, - pTitle1, pTitle2, pTitle3, pStudy1, pStudy2, pStudy3, - certification1, certification2, certification3, certification4, - recognition, achievements, language, languageLevel, - cod, leadManager, project, dateOfEntry, dateOfExit, - contractType, seniority, salary, bankName, accountNumber, - gpss, sss, beneficiaries, si, upload, profileImagePreview, + infoPer, + infoGenr, + upload, profileImagePreview, + firstName, lastName, + gender, status, + birthday, age, + birthCity, residenceAddress, localAddress, + maritalStatus, ci, issuedIn, numberOfChildren, + phoneNumber, personalEmail, + 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 ); }