nothing is fucking working fuck everything
This commit is contained in:
parent
69986a9027
commit
913ee13d33
4 changed files with 17 additions and 14 deletions
|
@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -37,4 +38,8 @@ public class CategoryService {
|
|||
public Page<Category> list(Pageable pageable){
|
||||
return categoryRepository.findAll(pageable);
|
||||
}
|
||||
|
||||
public Collection<String> findNames() {
|
||||
return categoryRepository.findAll().stream().map(Category::getName).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,4 +69,8 @@ public class PersonService {
|
|||
final var debit = this.expenseService.findUnpaidDebtByUser(person).stream().map(Expense::getCost).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
return credit.subtract(debit);
|
||||
}
|
||||
|
||||
public List<String> findNames() {
|
||||
return personRepository.findAll().stream().map(Person::getFirstName).toList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,10 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
|
|||
this.eventService = eventService;
|
||||
addClassNames("expenses-view");
|
||||
|
||||
Filters filters = new Filters(this::refreshGrid);
|
||||
final var categoriesNames = this.categoryService.findAll();
|
||||
final var creditorsNames = this.personService.findAllAsList();
|
||||
Filters filters = new Filters(this::refreshGrid, categoriesNames, creditorsNames);
|
||||
|
||||
// Create UI
|
||||
SplitLayout splitLayout = new SplitLayout();
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package com.application.munera.views.expenses;
|
|||
import com.application.munera.data.Category;
|
||||
import com.application.munera.data.Expense;
|
||||
import com.application.munera.data.Person;
|
||||
import com.application.munera.services.CategoryService;
|
||||
import com.application.munera.services.PersonService;
|
||||
import com.vaadin.flow.component.Component;
|
||||
import com.vaadin.flow.component.Text;
|
||||
import com.vaadin.flow.component.button.Button;
|
||||
|
@ -19,7 +17,6 @@ import com.vaadin.flow.component.orderedlayout.FlexLayout;
|
|||
import com.vaadin.flow.component.textfield.TextField;
|
||||
import com.vaadin.flow.theme.lumo.LumoUtility;
|
||||
import jakarta.persistence.criteria.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,21 +31,15 @@ public class Filters extends Div implements Specification<Expense> {
|
|||
private final MultiSelectComboBox<Person> creditors = new MultiSelectComboBox<>("Creditors");
|
||||
private final CheckboxGroup<String> isResolved = new CheckboxGroup<>("Role");
|
||||
|
||||
@Autowired
|
||||
private PersonService personService;
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
public Filters(Runnable onSearch) {
|
||||
public Filters(Runnable onSearch, List<Category> categoriesNames, List<Person> creditorsNames) {
|
||||
setWidthFull();
|
||||
addClassName("filter-layout");
|
||||
addClassNames(LumoUtility.Padding.Horizontal.LARGE, LumoUtility.Padding.Vertical.MEDIUM,
|
||||
LumoUtility.BoxSizing.BORDER);
|
||||
name.setPlaceholder("Expense's name");
|
||||
|
||||
creditors.setItems(this.personService.findAllAsList());
|
||||
category.setItems(this.categoryService.findAll());
|
||||
final var names = creditorsNames.stream().map(Person::getFirstName).toArray();
|
||||
creditors.setItems((creditorsNames));
|
||||
|
||||
isResolved.setItems("Worker", "Supervisor", "Manager", "External");
|
||||
isResolved.addClassName("double-width");
|
||||
|
||||
|
|
Loading…
Reference in a new issue