nothing is fucking working fuck everything

This commit is contained in:
filippo-ferrari 2024-07-09 22:50:05 +02:00
parent 69986a9027
commit 913ee13d33
4 changed files with 17 additions and 14 deletions

View file

@ -6,6 +6,7 @@ import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -37,4 +38,8 @@ public class CategoryService {
public Page<Category> list(Pageable pageable){ public Page<Category> list(Pageable pageable){
return categoryRepository.findAll(pageable); return categoryRepository.findAll(pageable);
} }
public Collection<String> findNames() {
return categoryRepository.findAll().stream().map(Category::getName).toList();
}
} }

View file

@ -69,4 +69,8 @@ public class PersonService {
final var debit = this.expenseService.findUnpaidDebtByUser(person).stream().map(Expense::getCost).reduce(BigDecimal.ZERO, BigDecimal::add); final var debit = this.expenseService.findUnpaidDebtByUser(person).stream().map(Expense::getCost).reduce(BigDecimal.ZERO, BigDecimal::add);
return credit.subtract(debit); return credit.subtract(debit);
} }
public List<String> findNames() {
return personRepository.findAll().stream().map(Person::getFirstName).toList();
}
} }

View file

@ -82,7 +82,10 @@ public class ExpensesView extends Div implements BeforeEnterObserver {
this.eventService = eventService; this.eventService = eventService;
addClassNames("expenses-view"); 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 // Create UI
SplitLayout splitLayout = new SplitLayout(); SplitLayout splitLayout = new SplitLayout();

View file

@ -3,8 +3,6 @@ package com.application.munera.views.expenses;
import com.application.munera.data.Category; import com.application.munera.data.Category;
import com.application.munera.data.Expense; import com.application.munera.data.Expense;
import com.application.munera.data.Person; 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.Component;
import com.vaadin.flow.component.Text; import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.button.Button; 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.component.textfield.TextField;
import com.vaadin.flow.theme.lumo.LumoUtility; import com.vaadin.flow.theme.lumo.LumoUtility;
import jakarta.persistence.criteria.*; import jakarta.persistence.criteria.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import java.util.ArrayList; 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 MultiSelectComboBox<Person> creditors = new MultiSelectComboBox<>("Creditors");
private final CheckboxGroup<String> isResolved = new CheckboxGroup<>("Role"); private final CheckboxGroup<String> isResolved = new CheckboxGroup<>("Role");
@Autowired public Filters(Runnable onSearch, List<Category> categoriesNames, List<Person> creditorsNames) {
private PersonService personService;
@Autowired
private CategoryService categoryService;
public Filters(Runnable onSearch) {
setWidthFull(); setWidthFull();
addClassName("filter-layout"); addClassName("filter-layout");
addClassNames(LumoUtility.Padding.Horizontal.LARGE, LumoUtility.Padding.Vertical.MEDIUM, addClassNames(LumoUtility.Padding.Horizontal.LARGE, LumoUtility.Padding.Vertical.MEDIUM,
LumoUtility.BoxSizing.BORDER); LumoUtility.BoxSizing.BORDER);
name.setPlaceholder("Expense's name"); name.setPlaceholder("Expense's name");
final var names = creditorsNames.stream().map(Person::getFirstName).toArray();
creditors.setItems((creditorsNames));
creditors.setItems(this.personService.findAllAsList());
category.setItems(this.categoryService.findAll());
isResolved.setItems("Worker", "Supervisor", "Manager", "External"); isResolved.setItems("Worker", "Supervisor", "Manager", "External");
isResolved.addClassName("double-width"); isResolved.addClassName("double-width");