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

#274 - list search results

parent c1183b6d
No related branches found
No related tags found
No related merge requests found
Pipeline #1410 passed
package de.deadlocker8.budgetmaster.search;
import de.deadlocker8.budgetmaster.accounts.AccountService;
import de.deadlocker8.budgetmaster.accounts.AccountType;
import de.deadlocker8.budgetmaster.controller.BaseController;
import de.deadlocker8.budgetmaster.services.HelpersService;
import de.deadlocker8.budgetmaster.filter.FilterConfiguration;
import de.deadlocker8.budgetmaster.transactions.Transaction;
import de.deadlocker8.budgetmaster.transactions.TransactionService;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
......@@ -9,21 +14,33 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
@Controller
public class SearchController extends BaseController
{
private final HelpersService helpers;
private final TransactionService transactionService;
private final AccountService accountService;
@Autowired
public SearchController(HelpersService helpers)
public SearchController(TransactionService transactionService, AccountService accountService)
{
this.transactionService = transactionService;
this.accountService = accountService;
}
@RequestMapping(value = "/search", method = RequestMethod.GET)
public String get(Model model, @ModelAttribute("NewSearch") Search search)
{
this.helpers = helpers;
return "redirect:/";
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
public String post(Model model, @ModelAttribute("NewSearch") Search search)
{
List<Transaction> transactions = transactionService.getTransactionsForAccountUntilDate(accountService.getRepository().findAllByType(AccountType.ALL).get(0), DateTime.now(), FilterConfiguration.DEFAULT);
model.addAttribute("transactions", transactions);
model.addAttribute("searchText", search.getSearchText());
return "search/search";
}
......
......@@ -208,6 +208,8 @@ datepicker.label.month=Monat:
datepicker.label.year=Jahr:
datepicker.button.confirm=bernehmen
search.for=Fr
# ABOUT
about=ber {0}
about.roadmap.link=Roadmap ffnen
......
......@@ -209,6 +209,8 @@ datepicker.label.month=Month:
datepicker.label.year=Year:
datepicker.button.confirm=Apply
search.for=For
# ABOUT
about=About {0}
about.roadmap.link=Open Roadmap
......
.search-result {
background-color: #666666;
}
\ No newline at end of file
.search-result {
background-color: #fafafa;
}
\ No newline at end of file
......@@ -2,12 +2,17 @@
<head>
<#import "../helpers/header.ftl" as header>
<@header.header "BudgetMaster"/>
<@header.style "transactions"/>
<@header.style "categories"/>
<@header.style "search"/>
<#import "/spring.ftl" as s>
</head>
<body class="budgetmaster-blue-light">
<#import "../helpers/navbar.ftl" as navbar>
<@navbar.navbar "home" settings/>
<#import "../transactions/transactionsMacros.ftl" as transactionsMacros>
<main>
<div class="card main-card background-color">
<div class="container">
......@@ -18,7 +23,41 @@
<div class="container">
<div class="row">
<div class="col s12">
${searchText}
<div class="headline center-align">${locale.getString("search.for")} "${searchText}"</div>
</div>
</div>
<div class="row transaction-container">
<div class="col s12">
<#list transactions as transaction>
<div class="card-panel search-result">
<div class="hide-on-large-only">
<div class="row valign-wrapper">
<div class="col s3 center-align bold transaction-text">
${dateService.getDateStringWithoutYear(transaction.date)}
</div>
<@transactionsMacros.transactionType transaction/>
<@transactionsMacros.transactionLinks transaction/>
</div>
<div class="row valign-wrapper no-margin-bottom">
<@transactionsMacros.transactionCategory transaction "center-align"/>
<@transactionsMacros.transactionNameAndDescription transaction/>
<@transactionsMacros.transactionAmount transaction transaction.getAccount()/>
</div>
</div>
<div class="hide-on-med-and-down">
<div class="row valign-wrapper no-margin-bottom">
<div class="col l1 xl1 bold transaction-text transaction-line-height">
${dateService.getDateStringWithoutYear(transaction.date)}
</div>
<@transactionsMacros.transactionCategory transaction "left-align"/>
<@transactionsMacros.transactionType transaction/>
<@transactionsMacros.transactionNameAndDescription transaction/>
<@transactionsMacros.transactionAmount transaction transaction.getAccount()/>
<@transactionsMacros.transactionLinks transaction/>
</div>
</div>
</div>
</#list>
</div>
</div>
</div>
......
......@@ -66,7 +66,7 @@
</div>
<div class="hide-on-med-and-down">
<div class="row valign-wrapper transaction-row">
<div class="col l1 xl1 bold transaction-text">
<div class="col l1 xl1 bold transaction-text transaction-line-height">
${dateService.getDateStringWithoutYear(transaction.date)}
</div>
<@transactionsMacros.transactionCategory transaction "left-align"/>
......
......@@ -60,6 +60,14 @@
</div>
</#macro>
<#macro transactionLinks transaction>
<div class="col s8 l2 xl1 right-align transaction-buttons no-wrap">
<a href="<@s.url '/transactions/${transaction.ID?c}/edit'/>" class="btn-flat no-padding text-color"><i class="material-icons left">open_in_new</i></a>
<a href="<@s.url '/transactions/${transaction.ID?c}/edit'/>" class="btn-flat no-padding text-color"><i class="material-icons left no-margin">edit</i></a>
</div>
</#macro>
<#macro placeholder transactions>
<#assign isOnlyRest = transactions?size == 1 && transactions[0].category.type.name() == "REST"/>
<#if isOnlyRest>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment