From 4a2be7caddbf4bc0256eddf750eae64df482f6ce Mon Sep 17 00:00:00 2001
From: Robert Goldmann <deadlocker@gmx.de>
Date: Mon, 9 Mar 2020 20:29:10 +0100
Subject: [PATCH] #388 - added new option for new transaction button "from
 template" + hotkey

---
 src/main/resources/languages/_de.properties               | 4 ++++
 src/main/resources/languages/_en.properties               | 3 +++
 src/main/resources/static/js/hotkeys.js                   | 8 ++++++++
 src/main/resources/templates/hotkeys.ftl                  | 4 ++++
 .../templates/transactions/transactionsMacros.ftl         | 4 ++++
 5 files changed, 23 insertions(+)

diff --git a/src/main/resources/languages/_de.properties b/src/main/resources/languages/_de.properties
index 88a7358c8..646e92888 100644
--- a/src/main/resources/languages/_de.properties
+++ b/src/main/resources/languages/_de.properties
@@ -40,6 +40,7 @@ title.transaction.new.normal=Buchung
 title.transaction.new.repeating=Wiederholend
 title.transaction.new.repeating.long=Wiederholende Buchung
 title.transaction.new.transfer=Umbuchung
+title.transaction.new.from.template=Aus Vorlage
 title.datepicker.year=Jahr wählen
 title.datepicker.month=Monat wählen
 title.account.new=Neues Konto
@@ -331,11 +332,14 @@ hotkeys.transactions.new.repeating=Neue widerholende Buchung anlegen
 hotkeys.transactions.new.repeating.key=r
 hotkeys.transactions.new.transfer=Neue Umbuchung anlegen
 hotkeys.transactions.new.transfer.key=t
+hotkeys.transactions.new.template=Neue Buchung aus Vorlage anlegen
+hotkeys.transactions.new.template.key=v
 hotkeys.transactions.filter=Filtern
 hotkeys.transactions.filter.key=f
 hotkeys.search=Suchen
 hotkeys.search.key=s
 
+
 # charts
 charts.default.accountSumPerDay=Kontostand pro Tag
 charts.default.accountSumPerDay.localization='{"axisY": "Summe in "'}
diff --git a/src/main/resources/languages/_en.properties b/src/main/resources/languages/_en.properties
index 2565df424..d5c026f21 100644
--- a/src/main/resources/languages/_en.properties
+++ b/src/main/resources/languages/_en.properties
@@ -40,6 +40,7 @@ title.transaction.new.normal=Transaction
 title.transaction.new.repeating=Recurring
 title.transaction.new.repeating.long=Recurring Transaction
 title.transaction.new.transfer=Transfer
+title.transaction.new.from.template=From template
 title.datepicker.year=Choose year
 title.datepicker.month=Choose month
 title.account.new=New Account
@@ -331,6 +332,8 @@ hotkeys.transactions.new.repeating=Create a recuring transaction
 hotkeys.transactions.new.repeating.key=r
 hotkeys.transactions.new.transfer=Create a transfer
 hotkeys.transactions.new.transfer.key=t
+hotkeys.transactions.new.template=Create a transaction from template
+hotkeys.transactions.new.template.key=v
 hotkeys.transactions.filter=Filter
 hotkeys.transactions.filter.key=f
 hotkeys.search=Search
diff --git a/src/main/resources/static/js/hotkeys.js b/src/main/resources/static/js/hotkeys.js
index f88d4f559..176d87c6e 100644
--- a/src/main/resources/static/js/hotkeys.js
+++ b/src/main/resources/static/js/hotkeys.js
@@ -22,6 +22,14 @@ Mousetrap.bind('t', function()
     }
 });
 
+Mousetrap.bind('v', function()
+{
+    if(areHotKeysEnabled())
+    {
+        window.location.href = rootURL + '/transactions/newTransaction/template';
+    }
+});
+
 Mousetrap.bind('f', function()
 {
     if(areHotKeysEnabled())
diff --git a/src/main/resources/templates/hotkeys.ftl b/src/main/resources/templates/hotkeys.ftl
index 71f5393ec..b4d2fbc2e 100644
--- a/src/main/resources/templates/hotkeys.ftl
+++ b/src/main/resources/templates/hotkeys.ftl
@@ -30,6 +30,10 @@
                     <@cellKey locale.getString("hotkeys.transactions.new.transfer.key")/>
                     <div class="col s8 m5 l5">${locale.getString("hotkeys.transactions.new.transfer")}</div>
                 </div>
+                <div class="row">
+                    <@cellKey locale.getString("hotkeys.transactions.new.template.key")/>
+                    <div class="col s8 m5 l5">${locale.getString("hotkeys.transactions.new.template")}</div>
+                </div>
                 <div class="row">
                     <@cellKey locale.getString("hotkeys.transactions.filter.key")/>
                     <div class="col s8 m5 l5">${locale.getString("hotkeys.transactions.filter")}</div>
diff --git a/src/main/resources/templates/transactions/transactionsMacros.ftl b/src/main/resources/templates/transactions/transactionsMacros.ftl
index a78c95c7e..ce06728f5 100644
--- a/src/main/resources/templates/transactions/transactionsMacros.ftl
+++ b/src/main/resources/templates/transactions/transactionsMacros.ftl
@@ -137,6 +137,10 @@
             <i class="material-icons left">add</i>${locale.getString("title.transaction.new.short")}
         </a>
         <ul class="${listClasses}">
+            <li>
+                <a href="<@s.url '/transactions/newTransaction/template'/>" class="btn-floating btn budgetmaster-baby-blue"><i class="material-icons">file_copy</i></a>
+                <a href="<@s.url '/transactions/newTransaction/template'/>" class="btn-floating btn mobile-fab-tip no-wrap">${locale.getString("title.transaction.new.from.template")}</a>
+            </li>
             <li>
                 <a href="<@s.url '/transactions/newTransaction/transfer'/>" class="btn-floating btn budgetmaster-dark-green"><i class="material-icons">swap_horiz</i></a>
                 <a href="<@s.url '/transactions/newTransaction/transfer'/>" class="btn-floating btn mobile-fab-tip no-wrap">${locale.getString("title.transaction.new.transfer")}</a>
-- 
GitLab