arreglar-funcionalidad #84

Merged
alex merged 14 commits from arreglar-funcionalidad into main 2024-11-28 02:52:23 +00:00
2 changed files with 37 additions and 3 deletions
Showing only changes of commit 9c1921df9a - Show all commits

View File

@ -102,6 +102,7 @@ public class Employee extends BaseEntity implements UserDetails {
private String bankName;
@Pattern(regexp = "^[0-9]+$", message = "El número de cuenta debe contener solo números")
private String accountNumber;
private String customContractType;
private String gpss;
private String sss;
@ -114,6 +115,10 @@ public class Employee extends BaseEntity implements UserDetails {
@Enumerated(EnumType.STRING)
private Status status;
public void setCustomContractType(String customContractType) {
this.customContractType = customContractType;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return Lists.newArrayList();

View File

@ -106,10 +106,11 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
private final VDatePicker dateOfEntry = new VDatePicker("Fecha de Ingreso");
private final VDatePicker dateOfExit = new VDatePicker("Fecha de Retiro");
private final ComboBox<Employee.ContractType> contractType = createContractTypeComboBox();
private final TextField customContractType = createCustomContractTypeField();
private final TextField seniority = createTextField("Antiguedad", 30, false);
private final TextField salaryTotal = createTextField("Salario Total", 10, false);
private final TextField salaryBasic = createTextField("Salario Basico", 10, false);
private final TextField antiguedad = createTextField("Descuento por Antiguedad", 10, false);
private final TextField antiguedad = createTextField("Bono de Antiguedad", 10, false);
private final TextField bonoProfesional = createTextField("Bono Profesional", 30, false);
private final TextField bankName = createTextField("Banco", 30, false);
private final TextField accountNumber = createTextField("Nro. de Cuenta", 30, false);
@ -383,10 +384,30 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
comboBox.setItemLabelGenerator(Employee.ContractType::name);
comboBox.setRequiredIndicatorVisible(true);
comboBox.setWidth("300px");
comboBox.setMinWidth("200px");
comboBox.addValueChangeListener(event -> handleContractTypeChange(event.getValue()));
return comboBox;
}
private TextField createCustomContractTypeField() {
TextField textField = new TextField("Especificar Tipo de Contrato");
textField.setPlaceholder("Ingrese el tipo de contrato...");
textField.setVisible(false);
textField.setWidth("300px");
return textField;
}
private void handleContractTypeChange(Employee.ContractType selectedType) {
if (selectedType == Employee.ContractType.OTROS) {
customContractType.setVisible(true);
customContractType.setRequired(true);
} else {
customContractType.setVisible(false);
customContractType.clear();
customContractType.setRequired(false);
}
}
private VerticalLayout createContentLayout() {
VerticalLayout contentLayout = new VerticalLayout();
contentLayout.setWidth("100%");
@ -464,6 +485,12 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
employee.setBonoProfesional(bonoProfesional.getValue());
employee.setAntiguedad(antiguedad.getValue());
employee.setSalarytotal((salaryTotal.getValue()));
employee.setContractType(contractType.getValue());
if (contractType.getValue() == Employee.ContractType.OTROS) {
employee.setCustomContractType(customContractType.getValue());
} else {
employee.setCustomContractType(null);
}
employeeService.createOrUpdate(employee);
Notification.show(NOTIFICATION_SAVE_SUCCESS);
getUI().ifPresent(ui -> ui.navigate(EmployeesListView.class));
@ -575,6 +602,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
dateOfEntry.setReadOnly(true);
dateOfExit.setReadOnly(true);
contractType.setReadOnly(true);
customContractType.setReadOnly(true);
seniority.setReadOnly(true);
salaryTotal.setReadOnly(true);
salaryBasic.setReadOnly(true);
@ -637,6 +665,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
dateOfEntry.setReadOnly(false);
dateOfExit.setReadOnly(false);
contractType.setReadOnly(false);
customContractType.setReadOnly(false);
seniority.setReadOnly(false);
salaryTotal.setReadOnly(false);
salaryBasic.setReadOnly(false);
@ -671,7 +700,7 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
idioma, language1, language1Level, language2, language2Level,
infoAdm,
cod, position, team, leadManager,
infoCont, dateOfEntry, dateOfExit, contractType, seniority,
infoCont, dateOfEntry, dateOfExit, seniority, contractType, customContractType,
salaryBasic, bonoProfesional, antiguedad, salaryTotal,
datBanc, bankName, accountNumber,
datGest, gpss, sss, beneficiarie1, beneficiarie2,