Compare commits

..

No commits in common. "ba57c7a5a944a4473a8b5611c00020024b5b09ab" and "c0e770bf758d15e500bc6e213eec59a165f771a9" have entirely different histories.

3 changed files with 10 additions and 30 deletions

View File

@ -1,6 +1,5 @@
package com.primefactorsolutions.service; package com.primefactorsolutions.service;
import com.primefactorsolutions.model.Candidate;
import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.model.Employee;
import com.primefactorsolutions.repositories.EmployeeRepository; import com.primefactorsolutions.repositories.EmployeeRepository;
import lombok.Data; import lombok.Data;
@ -19,9 +18,8 @@ public class EmployeeService {
this.employeeRepository = employeeRepository; this.employeeRepository = employeeRepository;
} }
public Employee createOrUpdate(final Employee employee) { public Employee createOrUpdate(final Employee assessment) {
final Employee saved = employeeRepository.save(employee); return null;
return saved;
} }
public List<Employee> getEmployees() { public List<Employee> getEmployees() {

View File

@ -3,20 +3,16 @@ package com.primefactorsolutions.views;
import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.model.Employee;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.vaadin.flow.component.Component; import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.textfield.EmailField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.BeforeEvent; import com.vaadin.flow.router.BeforeEvent;
import com.vaadin.flow.router.HasUrlParameter; import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route; import com.vaadin.flow.router.Route;
import com.vaadin.flow.spring.annotation.SpringComponent; import com.vaadin.flow.spring.annotation.SpringComponent;
import jakarta.annotation.security.PermitAll; import jakarta.annotation.security.PermitAll;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.Scope;
import org.vaadin.firitin.form.BeanValidationForm; import org.vaadin.firitin.form.BeanValidationForm;
import java.util.List; import java.util.List;
import java.util.UUID;
@SpringComponent @SpringComponent
@PermitAll @PermitAll
@ -24,36 +20,22 @@ import java.util.UUID;
@PageTitle("Employee") @PageTitle("Employee")
@Route(value = "/employees", layout = MainLayout.class) @Route(value = "/employees", layout = MainLayout.class)
public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> { public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> {
private final EmployeeService employeeService;
private TextField name = null; private final EmployeeService employeeService;
public EmployeeView(final EmployeeService employeeService) { public EmployeeView(final EmployeeService employeeService) {
super(Employee.class); super(Employee.class);
this.employeeService = employeeService; this.employeeService = employeeService;
name = new TextField();
name.setWidthFull();
name.setLabel("Name");
setSavedHandler((SavedHandler<Employee>) employee -> {
final Employee saved = employeeService.createOrUpdate(employee);
setEntityWithEnabledSave(saved);
});
}
@Override
public void setParameter(final BeforeEvent beforeEvent, final String s) {
if (StringUtils.isNotBlank(s) && !"new".equals(s)) {
var employee = employeeService.getEmployee(UUID.fromString(s));
setEntityWithEnabledSave(employee);
} else {
setEntityWithEnabledSave(new Employee());
}
} }
@Override @Override
protected List<Component> getFormComponents() { protected List<Component> getFormComponents() {
return List.of(name); return null;
}
@Override
public void setParameter(final BeforeEvent beforeEvent, final String s) {
} }
} }

View File

@ -117,7 +117,7 @@ public class EmployeesListView extends Main {
hf.add(next); hf.add(next);
final Button addEmployee = new Button("Add Employee"); final Button addEmployee = new Button("Add Employee");
addEmployee.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> { addEmployee.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
this.getUI().get().navigate(EmployeeView.class, "new"); //this.getUI().get().navigate(EmployeeView.class, "new");
}); });
hf.add(addEmployee); hf.add(addEmployee);