From 8bf4a97c88aa106c5323878b6471fef85a858525 Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Thu, 26 Sep 2024 07:51:03 -0400 Subject: [PATCH] =?UTF-8?q?#4=20Perfil=20de=20Empleado=20-=20A=C3=B1adir?= =?UTF-8?q?=20nuevos=20Campos=20para=20el=20formulario=20de=20registro=20d?= =?UTF-8?q?el=20empleado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../primefactorsolutions/model/Employee.java | 46 ++++++ .../views/EmployeeView.java | 143 +++++++++++++++++- 2 files changed, 185 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 4f5a49e..5069969 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -18,6 +18,7 @@ private String lastName; private LocalDate birthday; private String birthCity; + private String age; @Enumerated(EnumType.STRING) private MaritalStatus maritalStatus; private String residenceAddress; @@ -29,6 +30,51 @@ private String emergencyCAddress; private String emergencyCPhone; private String emergencyCEmail; + private String numberOfChildren; + private String departmentAndProvinceResidence; + + private String gender; + + private String ci; + private String issuedIn; + + private String pTitle1; + private String pTitle2; + private String pTitle3; + + private String pStudy1; + private String pStudy2; + private String pStudy3; + + private String certification1; + private String certification2; + private String certification3; + private String certification4; + + private String recognition; + private String achievements; + + private String language; + private String languageLevel; + + private String cod; + private String leadManager; + private String project; + + private LocalDate dateOfEntry; + private LocalDate dateOfExit; + + private String contractType; + private Integer seniority; + private Double salary; + + private String bankName; + private String accountNumber; + + private String gpss; + private String sss; + private String beneficiaries; + @Column(columnDefinition = "TEXT") private String profileImage; @Enumerated(EnumType.STRING) diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 8b18f3b..bc8618e 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -6,6 +6,7 @@ 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; @@ -75,6 +76,50 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final H3 ss = new H3("Datos de Contacto de Emergencia"); private final H3 si = new H3("Foto del Empleado"); + + 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; @@ -92,6 +137,18 @@ public class EmployeeView extends BeanValidationForm implements HasUrl configureUpload(); saveButton.setVisible(true); editButton.setVisible(true); + + birthday.addValueChangeListener(event -> calculateAge()); + + } + + private void calculateAge() { + if (birthday.getValue() != null) { + int currentYear = java.time.LocalDate.now().getYear(); + int birthYear = birthday.getValue().getYear(); + int ages = currentYear - birthYear; + age.setValue(String.valueOf(ages)); + } } private void configureUpload() { @@ -132,16 +189,23 @@ public class EmployeeView extends BeanValidationForm implements HasUrl lastName, status, birthday, + age, birthCity, maritalStatus, + numberOfChildren, residenceAddress, phoneNumber, personalEmail, position, - team); + team, gender, status, ci, issuedIn); contentLayout2.add( ss, emergencyCName, emergencyCAddress, - emergencyCPhone, emergencyCEmail, si, upload, + emergencyCPhone, emergencyCEmail, 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, saveButton, editButton); mainLayout.add(contentLayout1, contentLayout2); @@ -277,6 +341,38 @@ public class EmployeeView extends BeanValidationForm implements HasUrl emergencyCEmail.setReadOnly(true); upload.setVisible(true); profileImagePreview.setVisible(true); + age.setVisible(true); + gender.setVisible(true); + status.setVisible(true); + ci.setVisible(true); + issuedIn.setVisible(true); + pTitle1.setVisible(true); + pTitle2.setVisible(true); + pTitle3.setVisible(true); + pStudy1.setVisible(true); + pStudy2.setVisible(true); + pStudy3.setVisible(true); + certification1.setVisible(true); + certification2.setVisible(true); + certification3.setVisible(true); + certification4.setVisible(true); + recognition.setVisible(true); + achievements.setVisible(true); + language.setVisible(true); + languageLevel.setVisible(true); + cod.setVisible(true); + leadManager.setVisible(true); + project.setVisible(true); + dateOfEntry.setVisible(true); + dateOfExit.setVisible(true); + contractType.setVisible(true); + seniority.setVisible(true); + salary.setVisible(true); + bankName.setVisible(true); + accountNumber.setVisible(true); + gpss.setVisible(true); + sss.setVisible(true); + beneficiaries.setVisible(true); } private void setFieldsEditable() { @@ -296,14 +392,53 @@ public class EmployeeView extends BeanValidationForm implements HasUrl emergencyCPhone.setReadOnly(false); emergencyCEmail.setReadOnly(false); upload.setVisible(true); + age.setVisible(false); + gender.setVisible(false); + status.setVisible(false); + ci.setVisible(false); + issuedIn.setVisible(false); + pTitle1.setVisible(false); + pTitle2.setVisible(false); + pTitle3.setVisible(false); + pStudy1.setVisible(false); + pStudy2.setVisible(false); + pStudy3.setVisible(false); + certification1.setVisible(false); + certification2.setVisible(false); + certification3.setVisible(false); + certification4.setVisible(false); + recognition.setVisible(false); + achievements.setVisible(false); + language.setVisible(false); + languageLevel.setVisible(false); + cod.setVisible(false); + leadManager.setVisible(false); + project.setVisible(false); + dateOfEntry.setVisible(false); + dateOfExit.setVisible(false); + contractType.setVisible(false); + seniority.setVisible(false); + salary.setVisible(false); + bankName.setVisible(false); + accountNumber.setVisible(false); + gpss.setVisible(false); + sss.setVisible(false); + beneficiaries.setVisible(false); } @Override protected List getFormComponents() { return List.of( - mt, fs, userName, firstName, lastName, status, birthday, birthCity, maritalStatus, + mt, fs, userName, firstName, lastName, status, birthday, age, birthCity, maritalStatus, residenceAddress, phoneNumber, personalEmail, position, team, ss, emergencyCName, - emergencyCAddress, emergencyCPhone, emergencyCEmail, si, upload, profileImagePreview, + 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, saveButton, editButton ); }