Skip to content
Snippets Groups Projects
Commit c7d5799d authored by Robert Goldmann's avatar Robert Goldmann
Browse files

#293 - added basic filter page including type, repeating and categories

parent 90df17b3
No related branches found
No related tags found
No related merge requests found
Pipeline #597 passed
package de.deadlocker8.budgetmaster.controller;
import de.deadlocker8.budgetmaster.entities.category.Category;
import de.deadlocker8.budgetmaster.filter.FilterCategory;
import de.deadlocker8.budgetmaster.filter.FilterConfiguration;
import de.deadlocker8.budgetmaster.services.CategoryService;
import de.deadlocker8.budgetmaster.services.HelpersService;
import de.deadlocker8.budgetmaster.services.TransactionService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
@Controller
public class FilterController extends BaseController
{
@Autowired
private TransactionService transactionService;
@Autowired
private CategoryService categoryService;
@Autowired
private HelpersService helpers;
@RequestMapping("/filter")
public String filter(Model model, @CookieValue(value = "currentDate", required = false) String cookieDate)
{
DateTime date = helpers.getDateTimeFromCookie(cookieDate);
model.addAttribute("currentDate", date);
List<Category> categories = categoryService.getRepository().findAllByOrderByNameAsc();
List<FilterCategory> filterCategories = new ArrayList<>();
for(Category category : categories)
{
filterCategories.add(new FilterCategory(category.getID(), category.getName(), false));
}
FilterConfiguration filterConfiguration = new FilterConfiguration();
filterConfiguration.setIncludeIncome(true);
filterConfiguration.setIncludeExpenditure(true);
filterConfiguration.setIncludeNotRepeating(true);
filterConfiguration.setIncludeRepeating(true);
filterConfiguration.setFilterCategories(filterCategories);
model.addAttribute("filterConfiguration", filterConfiguration);
return "filter/filter";
}
@RequestMapping(value = "/filter/apply", method = RequestMethod.POST)
public String post(HttpServletResponse response, @ModelAttribute("NewFilterConfiguration") FilterConfiguration filterConfiguration)
{
System.out.println(filterConfiguration);
return "redirect:/filter";
}
}
\ No newline at end of file
package de.deadlocker8.budgetmaster.filter;
public class FilterCategory
{
private Integer ID;
private String name;
private boolean include;
public FilterCategory()
{
}
public FilterCategory(Integer ID, String name, boolean include)
{
this.ID = ID;
this.name = name;
this.include = include;
}
public Integer getID()
{
return ID;
}
public void setID(Integer ID)
{
this.ID = ID;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public boolean isInclude()
{
return include;
}
public void setInclude(boolean include)
{
this.include = include;
}
@Override
public String toString()
{
return "FilterCategory{" +
"ID=" + ID +
", name='" + name + '\'' +
", include=" + include +
'}';
}
}
package de.deadlocker8.budgetmaster.filter;
import java.util.List;
public class FilterConfiguration
{
private boolean includeIncome;
private boolean includeExpenditure;
private boolean includeNotRepeating;
private boolean includeRepeating;
private List<FilterCategory> filterCategories;
public FilterConfiguration()
{
}
public FilterConfiguration(boolean includeIncome, boolean includeExpenditure, boolean includeNotRepeating, boolean includeRepeating, List<FilterCategory> filterCategories)
{
this.includeIncome = includeIncome;
this.includeExpenditure = includeExpenditure;
this.includeNotRepeating = includeNotRepeating;
this.includeRepeating = includeRepeating;
this.filterCategories = filterCategories;
}
public boolean isIncludeIncome()
{
return includeIncome;
}
public void setIncludeIncome(boolean includeIncome)
{
this.includeIncome = includeIncome;
}
public boolean isIncludeExpenditure()
{
return includeExpenditure;
}
public void setIncludeExpenditure(boolean includeExpenditure)
{
this.includeExpenditure = includeExpenditure;
}
public boolean isIncludeNotRepeating()
{
return includeNotRepeating;
}
public void setIncludeNotRepeating(boolean includeNotRepeating)
{
this.includeNotRepeating = includeNotRepeating;
}
public boolean isIncludeRepeating()
{
return includeRepeating;
}
public void setIncludeRepeating(boolean includeRepeating)
{
this.includeRepeating = includeRepeating;
}
public List<FilterCategory> getFilterCategories()
{
return filterCategories;
}
public void setFilterCategories(List<FilterCategory> filterCategories)
{
this.filterCategories = filterCategories;
}
@Override
public String toString()
{
return "FilterConfiguration{" +
"includeIncome=" + includeIncome +
", includeExpenditure=" + includeExpenditure +
", includeNotRepeating=" + includeNotRepeating +
", includeRepeating=" + includeRepeating +
", filterCategories=" + filterCategories +
'}';
}
}
......@@ -240,6 +240,21 @@ report.budget.rest=Restbudget:
# filter
filter.active=Filter aktiv
filter.apply=Filter anwenden
filter.type=Art
filter.type.income=Einnahme
filter.type.expenditure=Ausgabe
filter.repeating=Wiederholung
filter.repeating.false=nicht wiederholend
filter.repeating.true=wiederholend
filter.categories=Kategorien
filter.categories.button.all=Alle
filter.categories.button.none=Keine
filter.name=Name
filter.tags=Tags
filter.tags.button.all=Alle
filter.tags.button.none=Keine
filter.button.reset=Zurcksetzen
# home menu
home.menu.accounts=Konten erlauben es mehrere Buchungen zu gruppieren. Du kannst so viele Konten erstellen, wie du mchtest. Zum Erstellen, Aktualisieren oder Lschen von Accounts klicke hier.
......
......@@ -239,6 +239,21 @@ report.budget.rest=Remaining Budget:
# filter
filter.active=Filter active
filer.apply=Apply Filter
filter.type=Type
filter.type.income=Income
filter.type.expenditure=Expenditure
filter.repeating=Repeating
filter.repeating.false=not repeating
filter.repeating.true=repeating
filter.categories=Categories
filter.categories.button.all=All
filter.categories.button.none=None
filter.name=Name
filter.tags=Tags
filter.tags.button.all=All
filter.tags.button.none=None
filter.button.reset=Reset
# home menu
home.menu.accounts=Accounts allow you to group multiple transactions. You can create as many accounts as you want. Create, update and delete them by clicking here.
......
.collapsible-header-status {
position: absolute;
right: 15px;
font-weight: bold;
}
.collapsible-header {
position: relative;
}
\ No newline at end of file
$(document).ready(function () {
$('.collapsible').collapsible();
});
<html>
<head>
<#import "../helpers/header.ftl" as header>
<@header.header "BudgetMaster"/>
<@header.style "filter"/>
<#import "/spring.ftl" as s>
</head>
<body class="budgetmaster-blue-light">
<#import "../helpers/navbar.ftl" as navbar>
<@navbar.navbar ""/>
<main>
<div class="card main-card background-color">
<div class="container">
<form name="NewFilterConfiguration" action="<@s.url '/filter/apply'/>" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<div class="row">
<div class="s12">
<ul class="collapsible">
<li>
<div class="collapsible-header">
<i class="fas fa-piggy-bank"></i>
${locale.getString("filter.type")}
<div class="collapsible-header-status">1/2</div>
</div>
<div class="collapsible-body">
<div class="row no-margin">
<div class="col s6 m6 l6">
<label>
<input type="checkbox" name="includeIncome" <#if filterConfiguration.isIncludeIncome()>checked="checked"</#if>>
<span class="text-color">${locale.getString('filter.type.income')}</span>
</label>
</div>
<div class="col s6 m6 l6">
<label>
<input type="checkbox" name="includeExpenditure" <#if filterConfiguration.isIncludeExpenditure()>checked="checked"</#if>>
<span class="text-color">${locale.getString('filter.type.expenditure')}</span>
</label>
</div>
</div>
</div>
</li>
<li>
<div class="collapsible-header">
<i class="material-icons">repeat</i>
${locale.getString("filter.repeating")}
<div class="collapsible-header-status">1/2</div>
</div>
<div class="collapsible-body">
<div class="row no-margin">
<div class="col s6 m6 l6">
<label>
<input type="checkbox" name="includeNotRepeating" <#if filterConfiguration.isIncludeNotRepeating()>checked="checked"</#if>>
<span class="text-color">${locale.getString('filter.repeating.false')}</span>
</label>
</div>
<div class="col s6 m6 l6">
<label>
<input type="checkbox" name="includeRepeating" <#if filterConfiguration.isIncludeRepeating()>checked="checked"</#if>>
<span class="text-color">${locale.getString('filter.repeating.true')}</span>
</label>
</div>
</div>
</div>
</li>
<li>
<div class="collapsible-header">
<i class="material-icons">label</i>
${locale.getString("filter.categories")}
<div class="collapsible-header-status">1/2</div>
</div>
<div class="collapsible-body">
<div class="row no-margin">
<div class="col s12">
<#list filterConfiguration.getFilterCategories() as filterCategory>
<div>
<label>
<input type="checkbox" name="filterCategories['${filterCategory?index}'].include">
<span class="text-color">${filterCategory.getName()}</span>
</label>
<input type="hidden" name="filterCategories['${filterCategory?index}'].ID" value="${filterCategory.getID()}"/>
<input type="hidden" name="filterCategories['${filterCategory?index}'].name" value="${filterCategory.getName()}"/>
</div>
</#list>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
<#-- button save -->
<div class="row valign-wrapper">
<div class="col s12 center-align">
<button class="btn waves-effect waves-light budgetmaster-blue" type="submit" name="buttonSave">
<i class="fas fa-filter left"></i>${locale.getString("filter.apply")}
</button>
</div>
</div>
</form>
</div>
</div>
</main>
<!-- Scripts-->
<#import "../helpers/scripts.ftl" as scripts>
<@scripts.scripts/>
<script src="<@s.url '/js/filter.js'/>"></script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment