diff --git a/src/main/resources/languages/_de.properties b/src/main/resources/languages/_de.properties index 3725fd521a5c9bb6a4e3fa7027f43ea2ca4ed940..ad554dae3774865945f78b2089e970b0034e6db0 100644 --- a/src/main/resources/languages/_de.properties +++ b/src/main/resources/languages/_de.properties @@ -67,6 +67,7 @@ placeholder.seems.empty=Ganz schön leer hier... placeholder.advice=Füge {0} hinzu save.as.template=Vorlage erzeugen save.as.template.errorsInForm=Vorlage konnte nicht erstellt werden, da Fehler im Formular existieren! +transaction.change.type=Buchungstyp ändern # WEEK DAYS monday=Montag diff --git a/src/main/resources/languages/_en.properties b/src/main/resources/languages/_en.properties index a963468530558b1698bea13bb2e9312ac81f82c7..d0fcf399d62fc20c840a47e003cf3169c2369dfc 100644 --- a/src/main/resources/languages/_en.properties +++ b/src/main/resources/languages/_en.properties @@ -67,6 +67,7 @@ placeholder.seems.empty=It''s pretty empty here... placeholder.advice=Get started by adding {0} save.as.template=Create template save.as.template.errorsInForm=Template could not be created because errors exist in the form! +transaction.change.type=Change type # WEEK DAYS monday=Monday diff --git a/src/main/resources/static/css/dark/transactions.css b/src/main/resources/static/css/dark/transactions.css index 867ccdad1dc1d66d648e5aa8d33525b966e5bb31..6f616100810e8c3cc6e98f2b76276680e467cf16 100644 --- a/src/main/resources/static/css/dark/transactions.css +++ b/src/main/resources/static/css/dark/transactions.css @@ -106,6 +106,11 @@ width: auto; } +#transaction-actions-button .mobile-fab-tip { + margin-right: 4rem; + right: 0; +} + #button-new-transaction { height: 36px; width: auto; diff --git a/src/main/resources/static/css/transactions.css b/src/main/resources/static/css/transactions.css index 867ccdad1dc1d66d648e5aa8d33525b966e5bb31..6f616100810e8c3cc6e98f2b76276680e467cf16 100644 --- a/src/main/resources/static/css/transactions.css +++ b/src/main/resources/static/css/transactions.css @@ -106,6 +106,11 @@ width: auto; } +#transaction-actions-button .mobile-fab-tip { + margin-right: 4rem; + right: 0; +} + #button-new-transaction { height: 36px; width: auto; diff --git a/src/main/resources/static/js/templates.js b/src/main/resources/static/js/templates.js index 59114c2c7edc53943f6bfb6781591ff656130c49..2935786e9301184873a4c6d795a649abdb771061 100644 --- a/src/main/resources/static/js/templates.js +++ b/src/main/resources/static/js/templates.js @@ -7,26 +7,19 @@ $(document).ready(function() if($('#buttonSaveAsTemplate').length) { - $('#buttonSaveAsTemplate').click(function() + M.FloatingActionButton.init(document.querySelectorAll('#transaction-actions-button'), {}); + + $('.transaction-action').click(function() { - // check if transaction form is valid - let isValidForm = validateForm(true); - if(!isValidForm) + let actionType = $(this).attr('data-action-type'); + if(actionType === 'saveAsTemplate') { - $('#modalCreateFromTransaction').modal('close'); - M.toast({html: createTemplateWithErrorInForm}); - return; + openSaveAsTemplateModal(this); + } + else if(actionType === 'changeType') + { + changeTransactionType(this); } - - $.ajax({ - type: 'GET', - url: $('#buttonSaveAsTemplate').attr('data-url'), - data: {}, - success: function(data) - { - createAndOpenModal(data) - } - }); }); } @@ -198,4 +191,30 @@ function searchTemplates(searchText) { collapsible.classList.remove('hidden'); } +} + +function openSaveAsTemplateModal(item) +{ + // check if transaction form is valid + let isValidForm = validateForm(true); + if(!isValidForm) + { + $('#modalCreateFromTransaction').modal('close'); + M.toast({html: createTemplateWithErrorInForm}); + return; + } + + $.ajax({ + type: 'GET', + url: $(item).attr('data-url'), + data: {}, + success: function(data) + { + createAndOpenModal(data) + } + }); +} + +function changeTransactionType(item) +{ } \ No newline at end of file diff --git a/src/main/resources/static/js/transactions.js b/src/main/resources/static/js/transactions.js index 5c87becbb3255a975ee87629fcac90a1a0b0d640..be7e0d92579e3c788d2db854f6e3e5bf68bceccc 100644 --- a/src/main/resources/static/js/transactions.js +++ b/src/main/resources/static/js/transactions.js @@ -208,7 +208,7 @@ $(document).ready(function() document.getElementById("input-isPayment").value = 1; }); - M.FloatingActionButton.init(document.querySelectorAll('.fixed-action-btn'), { + M.FloatingActionButton.init(document.querySelectorAll('.new-transaction-button'), { direction: 'bottom', hoverEnabled: false }); diff --git a/src/main/resources/templates/transactions/newTransactionMacros.ftl b/src/main/resources/templates/transactions/newTransactionMacros.ftl index 1a8310ebb80b25926f4eaa2250d509559bf2b914..5ceadf98789b4382695466fad3d331b5fdc21578 100644 --- a/src/main/resources/templates/transactions/newTransactionMacros.ftl +++ b/src/main/resources/templates/transactions/newTransactionMacros.ftl @@ -375,10 +375,20 @@ </button> </#macro> -<#macro buttonTemplate> - <div class="fixed-action-btn"> - <a id="buttonSaveAsTemplate" class="btn-floating btn-large waves-effect waves-light budgetmaster-blue tooltipped" data-position="left" data-tooltip="${locale.getString("save.as.template")}" data-url="<@s.url '/templates/fromTransactionModal'/>"> - <i class="material-icons left">file_copy</i>${locale.getString("save")} +<#macro buttonTransactionActions> + <div class="fixed-action-btn" id="transaction-actions-button"> + <a id="buttonSaveAsTemplate" class="btn-floating btn-large waves-effect waves-light budgetmaster-blue"> + <i class="material-icons left">settings</i>${locale.getString("save")} </a> + <ul> + <li> + <a class="btn-floating btn transaction-action mobile-fab-tip no-wrap" data-action-type="changeType" data-url="<@s.url '/transactions/changeType'/>">${locale.getString("transaction.change.type")}</a> + <a class="btn-floating btn transaction-action budgetmaster-baby-blue" data-action-type="changeType" data-url="<@s.url '/transactions/changeType'/>"><i class="material-icons">shuffle</i></a> + </li> + <li> + <a class="btn-floating btn transaction-action mobile-fab-tip no-wrap" data-action-type="saveAsTemplate" data-url="<@s.url '/templates/fromTransactionModal'/>">${locale.getString("save.as.template")}</a> + <a class="btn-floating btn transaction-action budgetmaster-dark-orange" data-action-type="saveAsTemplate" data-url="<@s.url '/templates/fromTransactionModal'/>"><i class="material-icons">file_copy</i></a> + </li> + </ul> </div> </#macro> \ No newline at end of file diff --git a/src/main/resources/templates/transactions/newTransactionNormal.ftl b/src/main/resources/templates/transactions/newTransactionNormal.ftl index de0c60df2dae531afc40c8af0482e1385c238e08..2c9e4542ebe5dd20f41ec31c8c45146c5d6cae8c 100644 --- a/src/main/resources/templates/transactions/newTransactionNormal.ftl +++ b/src/main/resources/templates/transactions/newTransactionNormal.ftl @@ -61,7 +61,7 @@ <br> <#-- buttons --> <@newTransactionMacros.buttons '/transactions'/> - <@newTransactionMacros.buttonTemplate/> + <@newTransactionMacros.buttonTransactionActions/> </form> <div id="saveAsTemplateModalContainer"></div> diff --git a/src/main/resources/templates/transactions/newTransactionTransfer.ftl b/src/main/resources/templates/transactions/newTransactionTransfer.ftl index 970a734f17ebffb1a3393c5e8cd745288b75ba09..f579be86ba539784680ddc4f783ce12606349e5d 100644 --- a/src/main/resources/templates/transactions/newTransactionTransfer.ftl +++ b/src/main/resources/templates/transactions/newTransactionTransfer.ftl @@ -66,7 +66,7 @@ <br> <#-- buttons --> <@newTransactionMacros.buttons '/transactions'/> - <@newTransactionMacros.buttonTemplate/> + <@newTransactionMacros.buttonTransactionActions/> </form> <div id="saveAsTemplateModalContainer"></div>