From 451242bea43413ccd6af8f8e4ebb4eff5534c323 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Wed, 18 Sep 2024 10:27:49 -0400 Subject: [PATCH 01/18] custom userdetails implementation --- .../config/SecurityConfig.java | 28 +++++++++++- .../primefactorsolutions/model/Employee.java | 44 ++++++++++++++++++- .../repositories/EmployeeRepository.java | 2 + .../service/EmployeeService.java | 21 +++++++-- .../views/EmployeeView.java | 4 +- .../views/MainLayout.java | 25 +++++++++-- src/main/resources/data.sql | 34 +++++++------- 7 files changed, 130 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java index 8d10f24..6bcfa06 100644 --- a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java +++ b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java @@ -1,17 +1,26 @@ package com.primefactorsolutions.config; +import com.primefactorsolutions.model.Employee; +import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.views.LoginView; import com.vaadin.flow.spring.security.VaadinWebSecurity; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; +import org.springframework.ldap.core.DirContextOperations; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.ldap.LdapBindAuthenticationManagerFactory; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.ldap.DefaultSpringSecurityContextSource; +import org.springframework.security.ldap.userdetails.LdapUserDetailsMapper; +import org.springframework.security.ldap.userdetails.UserDetailsContextMapper; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; +import java.util.Collection; + @EnableWebSecurity @Configuration public class SecurityConfig extends VaadinWebSecurity { @@ -37,13 +46,30 @@ public class SecurityConfig extends VaadinWebSecurity { } @Bean - public AuthenticationManager authenticationManager() { + public AuthenticationManager authenticationManager(final UserDetailsContextMapper userDetailsContextMapper) { DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource( "ldap://localhost:8389/dc=primefactorsolutions,dc=com"); contextSource.setCacheEnvironmentProperties(false); LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource); factory.setUserDnPatterns("uid={0},ou=users"); + factory.setUserDetailsContextMapper(userDetailsContextMapper); return factory.createAuthenticationManager(); } + + @Bean + public UserDetailsContextMapper userDetailsContextMapper(final EmployeeService employeeService) { + return new LdapUserDetailsMapper() { + @Override + public UserDetails mapUserFromContext(final DirContextOperations ctx, final String username, + final Collection authorities) { + final UserDetails details = super.mapUserFromContext(ctx, username, authorities); + final Employee employee = employeeService.getDetachedEmployeeByUsername(details.getUsername()); + + System.out.println(">>>>>" + employee + ">>>" + employee.getId()); + + return employee == null ? details : employee; + } + }; + } } diff --git a/src/main/java/com/primefactorsolutions/model/Employee.java b/src/main/java/com/primefactorsolutions/model/Employee.java index 4f5a49e..a8d568f 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -1,19 +1,23 @@ package com.primefactorsolutions.model; + import com.google.common.collect.Lists; import jakarta.persistence.*; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; + import org.springframework.security.core.GrantedAuthority; + import org.springframework.security.core.userdetails.UserDetails; import java.time.LocalDate; + import java.util.Collection; @Data @Entity @AllArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = true) - public class Employee extends BaseEntity { - private String userName; + public class Employee extends BaseEntity implements UserDetails { + private String username; private String firstName; private String lastName; private LocalDate birthday; @@ -33,6 +37,42 @@ private String profileImage; @Enumerated(EnumType.STRING) private Status status; + + @Override + public Collection getAuthorities() { + return Lists.newArrayList(); + } + + @Override + public String getPassword() { + return null; + } + + @Override + public String getUsername() { + return this.username; + } + + @Override + public boolean isAccountNonExpired() { + return true; + } + + @Override + public boolean isAccountNonLocked() { + return true; + } + + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @Override + public boolean isEnabled() { + return true; + } + public enum Status { ACTIVE, INACTIVE diff --git a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java index 323ac5b..e27a88b 100644 --- a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java +++ b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java @@ -3,7 +3,9 @@ package com.primefactorsolutions.repositories; import com.primefactorsolutions.model.Employee; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; import java.util.UUID; public interface EmployeeRepository extends JpaRepository { + Optional findByUsername(String username); } diff --git a/src/main/java/com/primefactorsolutions/service/EmployeeService.java b/src/main/java/com/primefactorsolutions/service/EmployeeService.java index c30f9b8..94a1f64 100644 --- a/src/main/java/com/primefactorsolutions/service/EmployeeService.java +++ b/src/main/java/com/primefactorsolutions/service/EmployeeService.java @@ -1,5 +1,6 @@ package com.primefactorsolutions.service; import com.primefactorsolutions.model.Employee; +import jakarta.persistence.EntityManager; import lombok.AllArgsConstructor; import org.apache.commons.beanutils.BeanComparator; import com.primefactorsolutions.repositories.EmployeeRepository; @@ -19,16 +20,28 @@ import java.util.Collections; public class EmployeeService { private final EmployeeRepository employeeRepository; private final LdapTemplate ldapTemplate; + private final EntityManager entityManager; public static final String BASE_DN = "dc=primefactorsolutions,dc=com"; protected Name buildDn(final Employee employee) { return LdapNameBuilder.newInstance(BASE_DN) .add("ou", "users") - .add("uid", employee.getUserName()) + .add("uid", employee.getUsername()) .build(); } + public Employee getDetachedEmployeeByUsername(final String username) { + final Employee employee = employeeRepository.findByUsername(username).orElse(null); + + if (employee != null) { + entityManager.detach(employee); + return employee; + } + + return null; + } + public List findEmployees( final int start, final int pageSize, final String sortProperty, final boolean asc) { List employees = employeeRepository.findAll(); @@ -75,14 +88,14 @@ public class EmployeeService { attrs.put(ocattr); attrs.put("cn", String.format("%s %s", employee.getFirstName(), employee.getLastName())); attrs.put("sn", String.format("%s %s", employee.getFirstName(), employee.getLastName())); - attrs.put("uid", employee.getUserName()); - attrs.put("userpassword", String.format("%s%s", employee.getUserName(), 123)); + attrs.put("uid", employee.getUsername()); + attrs.put("userpassword", String.format("%s%s", employee.getUsername(), 123)); return attrs; } public void updatePassword(final Employee employee) { - final Attribute attr = new BasicAttribute("userpassword", employee.getUserName() + "123"); + final Attribute attr = new BasicAttribute("userpassword", employee.getUsername() + "123"); final ModificationItem item = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr); ldapTemplate.modifyAttributes(buildDn(employee), new ModificationItem[] {item}); diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 8b18f3b..969b84b 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -46,7 +46,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl private final EmployeeService employeeService; // TODO: campo usado para registrar al empleado en LDAP. Este campo podria estar en otro form eventualmente. - 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 lastName = createTextField("Apellidos", 30, true); private final ComboBox status = createStatusComboBox(); @@ -301,7 +301,7 @@ public class EmployeeView extends BeanValidationForm implements HasUrl @Override protected List getFormComponents() { return List.of( - mt, fs, userName, firstName, lastName, status, birthday, birthCity, maritalStatus, + mt, fs, username, firstName, lastName, status, birthday, birthCity, maritalStatus, residenceAddress, phoneNumber, personalEmail, position, team, ss, emergencyCName, emergencyCAddress, emergencyCPhone, emergencyCEmail, si, upload, profileImagePreview, saveButton, editButton diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index d96d150..e0dd6f6 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -1,5 +1,6 @@ package com.primefactorsolutions.views; +import com.primefactorsolutions.model.Employee; import com.vaadin.flow.component.applayout.AppLayout; import com.vaadin.flow.component.applayout.DrawerToggle; import com.vaadin.flow.component.button.Button; @@ -10,6 +11,7 @@ import com.vaadin.flow.component.html.Span; import com.vaadin.flow.component.orderedlayout.FlexComponent; import com.vaadin.flow.component.orderedlayout.HorizontalLayout; import com.vaadin.flow.component.orderedlayout.Scroller; +import com.vaadin.flow.component.shared.Tooltip; import com.vaadin.flow.component.sidenav.SideNav; import com.vaadin.flow.component.sidenav.SideNavItem; import com.vaadin.flow.router.PageTitle; @@ -18,6 +20,8 @@ import com.vaadin.flow.theme.lumo.LumoUtility; import org.springframework.security.core.userdetails.UserDetails; import org.vaadin.lineawesome.LineAwesomeIcon; +import java.util.UUID; + /** * The main view is a top-level placeholder for other views. */ @@ -44,10 +48,25 @@ public class MainLayout extends AppLayout { header = authContext.getAuthenticatedUser(UserDetails.class) .map(user -> { - Button logout = new Button("Logout", click -> this.authContext.logout()); - Span loggedUser = new Span("Welcome " + user.getUsername()); - HorizontalLayout hl = new HorizontalLayout(loggedUser, logout); + final Button logout = new Button("Logout", click -> this.authContext.logout()); + final Span loggedUser = new Span("Welcome " + user.getUsername()); + String employeeId = "N/A"; + + if (user instanceof Employee) { + final UUID uuid = ((Employee) user).getId(); + + if (uuid != null) { + employeeId = uuid.toString(); + } + } + + final Tooltip tooltip = Tooltip.forComponent(loggedUser) + .withText("Employee id: " + employeeId) + .withPosition(Tooltip.TooltipPosition.TOP_START); + + final HorizontalLayout hl = new HorizontalLayout(loggedUser, logout); hl.setJustifyContentMode(FlexComponent.JustifyContentMode.END); + return hl; }).orElseGet(HorizontalLayout::new); header.setAlignItems(FlexComponent.Alignment.STRETCH); diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql index ae045c3..2a243e7 100644 --- a/src/main/resources/data.sql +++ b/src/main/resources/data.sql @@ -9,19 +9,21 @@ insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4- insert into ASSESSMENT_QUESTIONS (assessment_id, question_id) values ('46b153f4-23fd-462f-8430-fbe67b83caab', '8a4b213c-ca81-4c38-b56d-d7028c2dde88'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE'); -insert into employee (id, version, user_name, first_name, last_name, status) values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE'); \ No newline at end of file +insert into employee (id, version, username, first_name, last_name, status) values ('5c6f11fe-c341-4be7-a9a6-bba0081ad7c6', 1, 'bob', 'Bob', 'Test', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('cba3efb7-32bc-44be-9fdc-fc5e4f211254', 1, 'ben', 'Ben', 'Test', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('e99b7af5-7d3a-4c0f-b8bc-e8d0388d8fc4', 1, 'jperez', 'Juan', 'Perez Condori', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('f6ab3c6d-7078-45f6-9b22-4e37637bfec6', 1, 'agarcia', 'Ana', 'Garcia Rojas', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('2e2293b1-3f9a-4f3d-abc8-32639b0a5e15', 1, 'clopez', 'Carlos', 'Lopez Mendoza', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('4b1c6c35-4627-4b35-b6e9-dc75c68b2c31', 1, 'mfernandez', 'Maria', 'Fernandez Villca', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('afc5c741-f70a-4394-853b-39d51b118927', 1, 'lgutierrez', 'Luis', 'Gutierrez Mamani', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('b2436b82-7b9f-4f0d-9463-f2c3173a45c3', 1, 'lmartinez', 'Laura', 'Martinez Paredes', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('6e6a8a4e-9f6b-44eb-8c69-40acfdc86756', 1, 'rsantos', 'Roberto', 'Santos Escobar', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('36b0d1c6-bdc0-4d98-94bb-08b9bce3f0d5', 1, 'vmorales', 'Valeria', 'Morales Ochoa', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('5a1c6d80-58b3-43e3-a5a5-24b4a2d1d54a', 1, 'jramirez', 'Jorge', 'Ramirez Tapia', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('9d6a5b2e-6d0b-4b89-8d6a-d3f3d1bfc047', 1, 'storres', 'Sandra', 'Torres Huanca', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('f8b3e0c0-0d5a-4e5c-bf9d-207b9b5e8279', 1, 'fquispe', 'Felipe', 'Quispe Huanca', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('cd80e1d0-9a08-44a6-bd63-2c63eaa003d4', 1, 'grivas', 'Gabriela', 'Rivas Arana', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('62d3c1b7-815e-4e96-8d7e-f8c4236bca55', 1, 'oflores', 'Oscar', 'Flores Quiroga', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('f20b7c5a-5a67-44f0-9ec1-4c1b8e80de05', 1, 'mvargas', 'Marta', 'Vargas Soria', 'ACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('19b5a76e-d7b1-4b76-8b02-4d0748e85809', 1, 'aespinoza', 'Andres', 'Espinoza Chura', 'INACTIVE'); +insert into employee (id, version, username, first_name, last_name, status) values ('5c1a7b82-832d-4f24-8377-54b77b91b6a8', 1, 'cvillanueva', 'Carla', 'Villanueva Arce', 'ACTIVE'); From 23e633cc5fe8289853a94993b948a3f036ad0a4c Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Wed, 18 Sep 2024 10:28:54 -0400 Subject: [PATCH 02/18] remove println --- .../java/com/primefactorsolutions/config/SecurityConfig.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java index 6bcfa06..f892d3f 100644 --- a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java +++ b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java @@ -66,8 +66,6 @@ public class SecurityConfig extends VaadinWebSecurity { final UserDetails details = super.mapUserFromContext(ctx, username, authorities); final Employee employee = employeeService.getDetachedEmployeeByUsername(details.getUsername()); - System.out.println(">>>>>" + employee + ">>>" + employee.getId()); - return employee == null ? details : employee; } }; From db4c43d35e49132823c70cdbc49e7b32825dc1cb Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 19 Sep 2024 22:28:57 -0400 Subject: [PATCH 03/18] adding builder action --- .gitea/workflows/build.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .gitea/workflows/build.yaml diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..b9e5360 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,18 @@ +name: Builder +run-name: ${{ gitea.actor }} building +on: + push: + branches: + - main + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" + - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: List files in the repository + run: | + ls ${{ gitea.workspace }} + - run: echo "This job's status is ${{ job.status }}." From ab0059b0d273638060ea520a7d9340c31fc2a73b Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 19 Sep 2024 22:31:22 -0400 Subject: [PATCH 04/18] fix workflow --- .gitea/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index b9e5360..c3bd9dc 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -7,7 +7,7 @@ on: jobs: Explore-Gitea-Actions: - runs-on: ubuntu-latest + runs-on: linux_amd64:host steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" From c1fb36591aa27e65f955c821cfdc17d95a8c3373 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 19 Sep 2024 22:39:57 -0400 Subject: [PATCH 05/18] fix workflow --- .gitea/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index c3bd9dc..b9e5360 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -7,7 +7,7 @@ on: jobs: Explore-Gitea-Actions: - runs-on: linux_amd64:host + runs-on: ubuntu-latest steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" From fc2784b728afd6e351a3a16fea449f48f342d620 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 19:52:20 -0400 Subject: [PATCH 06/18] fix workflow --- .gitea/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index b9e5360..05e9a66 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -7,7 +7,7 @@ on: jobs: Explore-Gitea-Actions: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" From ddd0f9e0ce6fd2ccdf684e728dc09c784a07522f Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 20:05:12 -0400 Subject: [PATCH 07/18] buidl workflow --- .gitea/workflows/build.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 05e9a66..5c39b6f 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -6,13 +6,11 @@ on: - main jobs: - Explore-Gitea-Actions: + Build-Project: runs-on: ubuntu-22.04 steps: - - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: List files in the repository + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Build package run: | - ls ${{ gitea.workspace }} + ./mvnw clean package -Pproduction - run: echo "This job's status is ${{ job.status }}." From 8cb89154345caa5cf1f3fc7d019874617da57af9 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 20:13:26 -0400 Subject: [PATCH 08/18] adding checkout step --- .gitea/workflows/build.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 5c39b6f..8f42597 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,6 +10,10 @@ jobs: runs-on: ubuntu-22.04 steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: checkout main + uses: actions/checkout@v4 + with: + ref: main - name: Build package run: | ./mvnw clean package -Pproduction From 9c4a7fc45c6fbbf4419fc7dd2afab57576c9ed2f Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 20:18:25 -0400 Subject: [PATCH 09/18] fix build --- .gitea/workflows/build.yaml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 8f42597..aa00b06 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,11 +10,7 @@ jobs: runs-on: ubuntu-22.04 steps: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: checkout main - uses: actions/checkout@v4 - with: - ref: main - name: Build package run: | - ./mvnw clean package -Pproduction + git clone https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction - run: echo "This job's status is ${{ job.status }}." From ff2db18f0a090615163e4303bd2e1a23f6c1dcc4 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 22:19:49 -0400 Subject: [PATCH 10/18] deploy workflow --- .gitea/workflows/build.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index aa00b06..019f9d0 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -12,5 +12,5 @@ jobs: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - name: Build package run: | - git clone https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction + git clone https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction && unlink /home/ubuntu/pfs-intra/app.jar && cp target/*.jar /home/ubuntu/pfs-intra/app.jar && sudo systemctl restart pfs-intra - run: echo "This job's status is ${{ job.status }}." From 16a9a91790084ab7b95d3093d1f472ce40124c5f Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Mon, 23 Sep 2024 22:37:32 -0400 Subject: [PATCH 11/18] fix tests --- .../com/primefactorsolutions/config/SecurityConfig.java | 9 ++++++--- src/main/resources/application-test.properties | 2 ++ .../com/primefactorsolutions/views/AbstractAppTests.java | 6 ++---- 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/application-test.properties diff --git a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java index f892d3f..f347ba3 100644 --- a/src/main/java/com/primefactorsolutions/config/SecurityConfig.java +++ b/src/main/java/com/primefactorsolutions/config/SecurityConfig.java @@ -4,6 +4,7 @@ import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.views.LoginView; import com.vaadin.flow.spring.security.VaadinWebSecurity; +import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; @@ -24,6 +25,8 @@ import java.util.Collection; @EnableWebSecurity @Configuration public class SecurityConfig extends VaadinWebSecurity { + @Value("${spring.ldap.url}") + private String ldapUrl; @Override protected void configure(final HttpSecurity http) throws Exception { @@ -47,10 +50,10 @@ public class SecurityConfig extends VaadinWebSecurity { @Bean public AuthenticationManager authenticationManager(final UserDetailsContextMapper userDetailsContextMapper) { - DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource( - "ldap://localhost:8389/dc=primefactorsolutions,dc=com"); + final DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource( + String.format("%s/dc=primefactorsolutions,dc=com", ldapUrl)); contextSource.setCacheEnvironmentProperties(false); - LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource); + final LdapBindAuthenticationManagerFactory factory = new LdapBindAuthenticationManagerFactory(contextSource); factory.setUserDnPatterns("uid={0},ou=users"); factory.setUserDetailsContextMapper(userDetailsContextMapper); diff --git a/src/main/resources/application-test.properties b/src/main/resources/application-test.properties new file mode 100644 index 0000000..fd2c3c7 --- /dev/null +++ b/src/main/resources/application-test.properties @@ -0,0 +1,2 @@ +spring.ldap.url=ldap://localhost:8391 +spring.ldap.embedded.port=8391 diff --git a/src/test/java/com/primefactorsolutions/views/AbstractAppTests.java b/src/test/java/com/primefactorsolutions/views/AbstractAppTests.java index f05c2ef..d51af1f 100644 --- a/src/test/java/com/primefactorsolutions/views/AbstractAppTests.java +++ b/src/test/java/com/primefactorsolutions/views/AbstractAppTests.java @@ -14,21 +14,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.ApplicationContext; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; -import com.github.mvysny.kaributesting.v10.MockVaadin; import com.github.mvysny.kaributesting.v10.Routes; import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.test.context.ActiveProfiles; -import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @SpringBootTest +@ActiveProfiles(value = "test") public class AbstractAppTests { private static final Routes routes = new Routes().autoDiscoverViews("com.primefactorsolutions"); From 5c903ba3607939aa2d9429782242193e773d8c0a Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Tue, 24 Sep 2024 22:00:06 -0400 Subject: [PATCH 12/18] adding pr build wf --- .gitea/workflows/build-pr.yaml | 14 ++++++++++++++ .gitea/workflows/build.yaml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/build-pr.yaml diff --git a/.gitea/workflows/build-pr.yaml b/.gitea/workflows/build-pr.yaml new file mode 100644 index 0000000..6e60fb7 --- /dev/null +++ b/.gitea/workflows/build-pr.yaml @@ -0,0 +1,14 @@ +name: PR Builder +run-name: ${{ gitea.actor }} building PR +on: [pull_request] + +jobs: + Build-PR: + runs-on: ubuntu-22.04 + steps: + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - name: Build PR + if: gitea.base_ref == 'main' + run: | + git clone --single-branch --branch ${{ gitea.head_ref }} https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction + - run: echo "This job's status is ${{ job.status }}." diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 019f9d0..e64cc3a 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -12,5 +12,5 @@ jobs: - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - name: Build package run: | - git clone https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction && unlink /home/ubuntu/pfs-intra/app.jar && cp target/*.jar /home/ubuntu/pfs-intra/app.jar && sudo systemctl restart pfs-intra + git clone --single-branch --branch main https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction && unlink /home/ubuntu/pfs-intra/app.jar && cp target/*.jar /home/ubuntu/pfs-intra/app.jar && sudo systemctl restart pfs-intra - run: echo "This job's status is ${{ job.status }}." From 439c1f135dadd6d5249d11dbabec96c298cd6a62 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Tue, 24 Sep 2024 22:11:30 -0400 Subject: [PATCH 13/18] adding wf details --- .gitea/workflows/build-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-pr.yaml b/.gitea/workflows/build-pr.yaml index 6e60fb7..d8b18f2 100644 --- a/.gitea/workflows/build-pr.yaml +++ b/.gitea/workflows/build-pr.yaml @@ -6,7 +6,7 @@ jobs: Build-PR: runs-on: ubuntu-22.04 steps: - - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event on branch ${{ gitea.head_ref }} and ref is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - name: Build PR if: gitea.base_ref == 'main' run: | From 2342984de5e6b71ab1140c0003ebce3a5ffa4a6d Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 26 Sep 2024 22:08:02 -0400 Subject: [PATCH 14/18] fix PR workflow --- .gitea/workflows/build-pr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-pr.yaml b/.gitea/workflows/build-pr.yaml index d8b18f2..90aad01 100644 --- a/.gitea/workflows/build-pr.yaml +++ b/.gitea/workflows/build-pr.yaml @@ -10,5 +10,5 @@ jobs: - name: Build PR if: gitea.base_ref == 'main' run: | - git clone --single-branch --branch ${{ gitea.head_ref }} https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction + git clone --single-branch --branch "${{ gitea.head_ref }}" https://git.primefactorsolutions.com/PFS/pfs-intra.git && cd pfs-intra && ./mvnw clean package -Pproduction - run: echo "This job's status is ${{ job.status }}." From a7d1c08f9090dd3c9965db810f14e881ebd93679 Mon Sep 17 00:00:00 2001 From: ricardo051199 Date: Tue, 10 Sep 2024 13:02:08 -0400 Subject: [PATCH 15/18] Crear views para el modulo de documentos --- .../views/CorporateDocumentsView.java | 16 ++++++++++++++++ .../views/GovernmentDocumentsView.java | 16 ++++++++++++++++ .../primefactorsolutions/views/MainLayout.java | 16 ++++++++++++++-- .../views/PersonalDocumentsView.java | 16 ++++++++++++++++ .../views/ProfessionalDocumentsView.java | 16 ++++++++++++++++ .../views/WorkDocumentsView.java | 16 ++++++++++++++++ 6 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/primefactorsolutions/views/CorporateDocumentsView.java create mode 100644 src/main/java/com/primefactorsolutions/views/GovernmentDocumentsView.java create mode 100644 src/main/java/com/primefactorsolutions/views/PersonalDocumentsView.java create mode 100644 src/main/java/com/primefactorsolutions/views/ProfessionalDocumentsView.java create mode 100644 src/main/java/com/primefactorsolutions/views/WorkDocumentsView.java diff --git a/src/main/java/com/primefactorsolutions/views/CorporateDocumentsView.java b/src/main/java/com/primefactorsolutions/views/CorporateDocumentsView.java new file mode 100644 index 0000000..7806438 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/CorporateDocumentsView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +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; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("CorporateDocuments") +@Route(value = "/corporate-documents/me", layout = MainLayout.class) +public class CorporateDocumentsView extends Main { +} diff --git a/src/main/java/com/primefactorsolutions/views/GovernmentDocumentsView.java b/src/main/java/com/primefactorsolutions/views/GovernmentDocumentsView.java new file mode 100644 index 0000000..a06e4bf --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/GovernmentDocumentsView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +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; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("GovernmentDocumentsView") +@Route(value = "/government-documents/me", layout = MainLayout.class) +public class GovernmentDocumentsView extends Main { +} diff --git a/src/main/java/com/primefactorsolutions/views/MainLayout.java b/src/main/java/com/primefactorsolutions/views/MainLayout.java index e0dd6f6..dfd4e31 100644 --- a/src/main/java/com/primefactorsolutions/views/MainLayout.java +++ b/src/main/java/com/primefactorsolutions/views/MainLayout.java @@ -107,17 +107,29 @@ public class MainLayout extends AppLayout { admin.addItem(new SideNavItem("Employees", EmployeesListView.class, LineAwesomeIcon.USER_EDIT_SOLID.create())); + SideNavItem documents = new SideNavItem("Documents", MainView.class, + LineAwesomeIcon.FILE_ALT_SOLID.create()); + documents.addItem(new SideNavItem("Personal Documents", PersonalDocumentsView.class, + LineAwesomeIcon.ID_CARD_SOLID.create())); + documents.addItem(new SideNavItem("Professional Documents", ProfessionalDocumentsView.class, + LineAwesomeIcon.BRIEFCASE_SOLID.create())); + documents.addItem(new SideNavItem("Work Documents", WorkDocumentsView.class, + LineAwesomeIcon.FOLDER_OPEN_SOLID.create())); + documents.addItem(new SideNavItem("Corporate Documents", CorporateDocumentsView.class, + LineAwesomeIcon.BUILDING_SOLID.create())); + documents.addItem(new SideNavItem("Government Documents", GovernmentDocumentsView.class, + LineAwesomeIcon.BALANCE_SCALE_SOLID.create())); + SideNavItem timeOff = new SideNavItem("My Time-off", TimeoffView.class, LineAwesomeIcon.PLANE_DEPARTURE_SOLID.create()); SideNavItem timesheet = new SideNavItem("My Timesheet", TimesheetView.class, LineAwesomeIcon.HOURGLASS_START_SOLID.create()); SideNavItem profile = new SideNavItem("My Profile", ProfileView.class, LineAwesomeIcon.USER_EDIT_SOLID.create()); - SideNavItem documents = new SideNavItem("My Documents", DocumentsView.class, - LineAwesomeIcon.SUITCASE_SOLID.create()); nav.addItem(new SideNavItem("Home", MainView.class, LineAwesomeIcon.HOME_SOLID.create())); nav.addItem(admin); + nav.addItem(documents); nav.addItem(recruiting); nav.addItem(profile); nav.addItem(timesheet); diff --git a/src/main/java/com/primefactorsolutions/views/PersonalDocumentsView.java b/src/main/java/com/primefactorsolutions/views/PersonalDocumentsView.java new file mode 100644 index 0000000..433b5c5 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/PersonalDocumentsView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +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; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("PersonalDocuments") +@Route(value = "/personal-documents/me", layout = MainLayout.class) +public class PersonalDocumentsView extends Main { +} diff --git a/src/main/java/com/primefactorsolutions/views/ProfessionalDocumentsView.java b/src/main/java/com/primefactorsolutions/views/ProfessionalDocumentsView.java new file mode 100644 index 0000000..2b2badd --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/ProfessionalDocumentsView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +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; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("ProfessionalDocuments") +@Route(value = "/professional-documents/me", layout = MainLayout.class) +public class ProfessionalDocumentsView extends Main { +} diff --git a/src/main/java/com/primefactorsolutions/views/WorkDocumentsView.java b/src/main/java/com/primefactorsolutions/views/WorkDocumentsView.java new file mode 100644 index 0000000..de23e08 --- /dev/null +++ b/src/main/java/com/primefactorsolutions/views/WorkDocumentsView.java @@ -0,0 +1,16 @@ +package com.primefactorsolutions.views; + +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; +import jakarta.annotation.security.PermitAll; +import org.springframework.context.annotation.Scope; + +@SpringComponent +@PermitAll +@Scope("prototype") +@PageTitle("WorkDocuments") +@Route(value = "/work-documents/me", layout = MainLayout.class) +public class WorkDocumentsView extends Main { +} From b4c27f8a9bdb46897be9249938ba17a9b4d28b1f Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 26 Sep 2024 21:45:44 -0400 Subject: [PATCH 16/18] merged conflicts --- .../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 a8d568f..1a76c42 100644 --- a/src/main/java/com/primefactorsolutions/model/Employee.java +++ b/src/main/java/com/primefactorsolutions/model/Employee.java @@ -22,6 +22,7 @@ private String lastName; private LocalDate birthday; private String birthCity; + private String age; @Enumerated(EnumType.STRING) private MaritalStatus maritalStatus; private String residenceAddress; @@ -33,6 +34,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 969b84b..a024f02 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 ); } From 831f9ec9a55637fed852af1e28e2c85815eb5372 Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 26 Sep 2024 21:47:43 -0400 Subject: [PATCH 17/18] 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 ); } From 25448fff4458b92f885d3217e80965f36445401e Mon Sep 17 00:00:00 2001 From: Alex Prudencio Date: Thu, 26 Sep 2024 21:54:10 -0400 Subject: [PATCH 18/18] fix readonly fields --- .../views/EmployeeView.java | 129 +++++++++--------- 1 file changed, 65 insertions(+), 64 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/views/EmployeeView.java b/src/main/java/com/primefactorsolutions/views/EmployeeView.java index 26bde89..3f057dc 100644 --- a/src/main/java/com/primefactorsolutions/views/EmployeeView.java +++ b/src/main/java/com/primefactorsolutions/views/EmployeeView.java @@ -382,38 +382,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); + age.setReadOnly(true); + gender.setReadOnly(true); + status.setReadOnly(true); + ci.setReadOnly(true); + issuedIn.setReadOnly(true); + pTitle1.setReadOnly(true); + pTitle2.setReadOnly(true); + pTitle3.setReadOnly(true); + pStudy1.setReadOnly(true); + pStudy2.setReadOnly(true); + pStudy3.setReadOnly(true); + certification1.setReadOnly(true); + certification2.setReadOnly(true); + certification3.setReadOnly(true); + certification4.setReadOnly(true); + recognition.setReadOnly(true); + achievements.setReadOnly(true); + language.setReadOnly(true); + languageLevel.setReadOnly(true); + cod.setReadOnly(true); + leadManager.setReadOnly(true); + project.setReadOnly(true); + dateOfEntry.setReadOnly(true); + dateOfExit.setReadOnly(true); + contractType.setReadOnly(true); + seniority.setReadOnly(true); + salary.setReadOnly(true); + bankName.setReadOnly(true); + accountNumber.setReadOnly(true); + gpss.setReadOnly(true); + sss.setReadOnly(true); + beneficiaries.setReadOnly(true); } private void setFieldsEditable() { @@ -433,43 +433,44 @@ 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); + age.setReadOnly(false); + gender.setReadOnly(false); + status.setReadOnly(false); + ci.setReadOnly(false); + issuedIn.setReadOnly(false); + pTitle1.setReadOnly(false); + pTitle2.setReadOnly(false); + pTitle3.setReadOnly(false); + pStudy1.setReadOnly(false); + pStudy2.setReadOnly(false); + pStudy3.setReadOnly(false); + certification1.setReadOnly(false); + certification2.setReadOnly(false); + certification3.setReadOnly(false); + certification4.setReadOnly(false); + recognition.setReadOnly(false); + achievements.setReadOnly(false); + language.setReadOnly(false); + languageLevel.setReadOnly(false); + cod.setReadOnly(false); + leadManager.setReadOnly(false); + project.setReadOnly(false); + dateOfEntry.setReadOnly(false); + dateOfExit.setReadOnly(false); + contractType.setReadOnly(false); + seniority.setReadOnly(false); + salary.setReadOnly(false); + bankName.setReadOnly(false); + accountNumber.setReadOnly(false); + gpss.setReadOnly(false); + sss.setReadOnly(false); + beneficiaries.setReadOnly(false); } @Override protected List getFormComponents() { return List.of( + username, infoPer, infoGenr, upload, profileImagePreview,