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

#338 - allow add/update of transfer templates

parent e60d6808
No related branches found
No related tags found
No related merge requests found
...@@ -153,7 +153,8 @@ public class TemplateController extends BaseController ...@@ -153,7 +153,8 @@ public class TemplateController extends BaseController
public String post(Model model, public String post(Model model,
@ModelAttribute("NewTemplate") Template template, BindingResult bindingResult, @ModelAttribute("NewTemplate") Template template, BindingResult bindingResult,
@RequestParam(value = "isPayment", required = false) boolean isPayment, @RequestParam(value = "isPayment", required = false) boolean isPayment,
@RequestParam(value = "includeAccount", required = false) boolean includeAccount) @RequestParam(value = "includeAccount", required = false) boolean includeAccount,
@RequestParam(value = "includeTransferAccount", required = false) boolean includeTransferAccount)
{ {
template.setTemplateName(template.getTemplateName().trim()); template.setTemplateName(template.getTemplateName().trim());
...@@ -186,6 +187,11 @@ public class TemplateController extends BaseController ...@@ -186,6 +187,11 @@ public class TemplateController extends BaseController
template.setAccount(null); template.setAccount(null);
} }
if(!includeTransferAccount)
{
template.setTransferAccount(null);
}
templateService.getRepository().save(template); templateService.getRepository().save(template);
return "redirect:/templates"; return "redirect:/templates";
} }
...@@ -200,13 +206,9 @@ public class TemplateController extends BaseController ...@@ -200,13 +206,9 @@ public class TemplateController extends BaseController
} }
Template template = templateOptional.get(); Template template = templateOptional.get();
templateService.prepareTemplateForNewTransaction(template, false);
templateService.prepareModelNewOrEdit(model, true, template, template.getAmount() <= 0, accountService.getAllAccountsAsc()); templateService.prepareModelNewOrEdit(model, true, template, template.getAmount() <= 0, accountService.getAllAccountsAsc());
if(template.isTransfer())
{
return "templates/newTransferTemplate";
}
return "templates/newTemplate"; return "templates/newTemplate";
} }
} }
\ No newline at end of file
...@@ -250,6 +250,7 @@ search.in.tags=Tags ...@@ -250,6 +250,7 @@ search.in.tags=Tags
template.checkbox.include.category=Kategorie übernehmen template.checkbox.include.category=Kategorie übernehmen
template.checkbox.include.account=Konto übernehmen template.checkbox.include.account=Konto übernehmen
template.checkbox.include.account.transfer=Zielkonto übernehmen
# ABOUT # ABOUT
about=Über {0} about=Über {0}
......
...@@ -250,6 +250,7 @@ search.in.tags=Tags ...@@ -250,6 +250,7 @@ search.in.tags=Tags
template.checkbox.include.category=Include category template.checkbox.include.category=Include category
template.checkbox.include.account=Include account template.checkbox.include.account=Include account
template.checkbox.include.account.transfer=Include destination account
# ABOUT # ABOUT
about=About {0} about=About {0}
......
...@@ -51,16 +51,26 @@ $(document).ready(function() ...@@ -51,16 +51,26 @@ $(document).ready(function()
if($("#include-account").length) if($("#include-account").length)
{ {
document.getElementById('include-account').addEventListener('change', (event) => handleIncludeAccountCheckbox('include-account', 'transaction-account')
}
if($("#include-transfer-account").length)
{
handleIncludeAccountCheckbox('include-transfer-account', 'transaction-transfer-account')
}
});
function handleIncludeAccountCheckbox(checkboxID, selectID)
{ {
let accountSelect = document.getElementById('transaction-account') document.getElementById(checkboxID).addEventListener('change', (event) =>
{
let accountSelect = document.getElementById(selectID)
let accountSelectInstance = M.FormSelect.getInstance(accountSelect); let accountSelectInstance = M.FormSelect.getInstance(accountSelect);
accountSelectInstance.destroy(); accountSelectInstance.destroy();
accountSelect.disabled = !event.target.checked; accountSelect.disabled = !event.target.checked;
M.FormSelect.init(document.querySelectorAll('#transaction-account'), {}); M.FormSelect.init(document.querySelectorAll('#' + selectID), {});
}); });
} }
});
function createAndOpenModal(data) function createAndOpenModal(data)
{ {
......
...@@ -58,6 +58,15 @@ ...@@ -58,6 +58,15 @@
<@newTransactionMacros.account accounts helpers.getCurrentAccountOrDefault() "transaction-account" "account" "", true/> <@newTransactionMacros.account accounts helpers.getCurrentAccountOrDefault() "transaction-account" "account" "", true/>
</#if> </#if>
<#-- transfer account -->
<#if template.getTransferAccount()??>
<@templateFunctions.templateIncludeAccountCheckbox "include-transfer-account" "includeTransferAccount" locale.getString('template.checkbox.include.account.transfer') true/>
<@newTransactionMacros.account accounts template.getTransferAccount() "transaction-transfer-account" "transferAccount" "" false/>
<#else>
<@templateFunctions.templateIncludeAccountCheckbox "include-transfer-account" "includeTransferAccount" locale.getString('template.checkbox.include.account.transfer') false/>
<@newTransactionMacros.account accounts helpers.getCurrentAccountOrDefault() "transaction-transfer-account" "transferAccount" "", true/>
</#if>
<br> <br>
<#-- buttons --> <#-- buttons -->
<@newTransactionMacros.buttons/> <@newTransactionMacros.buttons/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment