Compare commits
No commits in common. "ba57c7a5a944a4473a8b5611c00020024b5b09ab" and "c0e770bf758d15e500bc6e213eec59a165f771a9" have entirely different histories.
ba57c7a5a9
...
c0e770bf75
@ -1,6 +1,5 @@
|
||||
package com.primefactorsolutions.service;
|
||||
|
||||
import com.primefactorsolutions.model.Candidate;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.repositories.EmployeeRepository;
|
||||
import lombok.Data;
|
||||
@ -19,9 +18,8 @@ public class EmployeeService {
|
||||
this.employeeRepository = employeeRepository;
|
||||
}
|
||||
|
||||
public Employee createOrUpdate(final Employee employee) {
|
||||
final Employee saved = employeeRepository.save(employee);
|
||||
return saved;
|
||||
public Employee createOrUpdate(final Employee assessment) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Employee> getEmployees() {
|
||||
|
@ -3,20 +3,16 @@ package com.primefactorsolutions.views;
|
||||
import com.primefactorsolutions.model.Employee;
|
||||
import com.primefactorsolutions.service.EmployeeService;
|
||||
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.HasUrlParameter;
|
||||
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.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.vaadin.firitin.form.BeanValidationForm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@SpringComponent
|
||||
@PermitAll
|
||||
@ -24,36 +20,22 @@ import java.util.UUID;
|
||||
@PageTitle("Employee")
|
||||
@Route(value = "/employees", layout = MainLayout.class)
|
||||
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) {
|
||||
super(Employee.class);
|
||||
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
|
||||
protected List<Component> getFormComponents() {
|
||||
return List.of(name);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameter(final BeforeEvent beforeEvent, final String s) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class EmployeesListView extends Main {
|
||||
hf.add(next);
|
||||
final Button addEmployee = new Button("Add Employee");
|
||||
addEmployee.addClickListener((ComponentEventListener<ClickEvent<Button>>) buttonClickEvent -> {
|
||||
this.getUI().get().navigate(EmployeeView.class, "new");
|
||||
//this.getUI().get().navigate(EmployeeView.class, "new");
|
||||
});
|
||||
hf.add(addEmployee);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user