diff --git a/src/main/java/de/deadlocker8/budgetmaster/search/SearchController.java b/src/main/java/de/deadlocker8/budgetmaster/search/SearchController.java index c94a934e53563f2cd968aa320ef859103d4932e2..63aef3f053430f2db1c0ec8f4daa258dcc258672 100644 --- a/src/main/java/de/deadlocker8/budgetmaster/search/SearchController.java +++ b/src/main/java/de/deadlocker8/budgetmaster/search/SearchController.java @@ -1,7 +1,12 @@ 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"; } diff --git a/src/main/resources/languages/_de.properties b/src/main/resources/languages/_de.properties index 92130c70938bfd6e4d64a06467c2866fade36179..3662b61d0de89272b949098867e658f359158323 100644 --- a/src/main/resources/languages/_de.properties +++ b/src/main/resources/languages/_de.properties @@ -208,6 +208,8 @@ datepicker.label.month=Monat: datepicker.label.year=Jahr: datepicker.button.confirm=�bernehmen +search.for=F�r + # ABOUT about=�ber {0} about.roadmap.link=Roadmap �ffnen diff --git a/src/main/resources/languages/_en.properties b/src/main/resources/languages/_en.properties index 981f41bb5959622901ec4344bede9b8cedd0a69f..d90a8f65b7341dda6e040612cb8f1724bd36e138 100644 --- a/src/main/resources/languages/_en.properties +++ b/src/main/resources/languages/_en.properties @@ -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 diff --git a/src/main/resources/static/css/dark/search.css b/src/main/resources/static/css/dark/search.css new file mode 100644 index 0000000000000000000000000000000000000000..3e89401fa9d976945bc10a9bd709a699583c16e3 --- /dev/null +++ b/src/main/resources/static/css/dark/search.css @@ -0,0 +1,3 @@ +.search-result { + background-color: #666666; +} \ No newline at end of file diff --git a/src/main/resources/static/css/search.css b/src/main/resources/static/css/search.css new file mode 100644 index 0000000000000000000000000000000000000000..0bbc97ebab3c5ef663af6029b7e51230a7ef9858 --- /dev/null +++ b/src/main/resources/static/css/search.css @@ -0,0 +1,3 @@ +.search-result { + background-color: #fafafa; +} \ No newline at end of file diff --git a/src/main/resources/templates/search/search.ftl b/src/main/resources/templates/search/search.ftl index 175bf0972f7af8e8260ebe7a8d7b84e648e57ea7..0eb01f8189f367d62b6c2a3e4bac5a1d48b4ca66 100644 --- a/src/main/resources/templates/search/search.ftl +++ b/src/main/resources/templates/search/search.ftl @@ -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> diff --git a/src/main/resources/templates/transactions/transactions.ftl b/src/main/resources/templates/transactions/transactions.ftl index 8390f9bf8a7160e8a49f98ea5bc592d256a3ed18..4ef1f97bfeb18274089057f9904491df2e1b6491 100644 --- a/src/main/resources/templates/transactions/transactions.ftl +++ b/src/main/resources/templates/transactions/transactions.ftl @@ -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"/> diff --git a/src/main/resources/templates/transactions/transactionsMacros.ftl b/src/main/resources/templates/transactions/transactionsMacros.ftl index a10463f960ce8637c7fd5f6ad6292787a0bbc02f..3dbc1d068823047ba3c113258c4874306ad1096f 100644 --- a/src/main/resources/templates/transactions/transactionsMacros.ftl +++ b/src/main/resources/templates/transactions/transactionsMacros.ftl @@ -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>