diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/GlobalAccountSelectHotKey.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/GlobalAccountSelectHotKey.java new file mode 100644 index 0000000000000000000000000000000000000000..908b07b923333ee354659b37ba7f5d252230d373 --- /dev/null +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/GlobalAccountSelectHotKey.java @@ -0,0 +1,61 @@ +package de.deadlocker8.budgetmaster.hotkeys; + +import de.thecodelabs.utils.util.Localization; + +import java.text.MessageFormat; + +public enum GlobalAccountSelectHotKey implements HotKey +{ + OPEN("hotkeys.global.account.select.open", false), + ACCOUNT_BY_NUMBER("hotkeys.global.account.select.by.number", false); + + private final String localizationKey; + private final boolean hasModifier; + + GlobalAccountSelectHotKey(String localizationKey, boolean hasModifier) + { + this.localizationKey = localizationKey; + this.hasModifier = hasModifier; + } + + @Override + public String getModifierLocalized() + { + if(hasModifier) + { + return getLocalized("modifier"); + } + return null; + } + + @Override + public String getKeyLocalized() + { + return getLocalized("key"); + } + + @Override + public String getTextLocalized() + { + return getLocalized(null); + } + + private String getLocalized(String keySuffix) + { + if(keySuffix == null) + { + return Localization.getString(localizationKey); + } + + return Localization.getString(MessageFormat.format("{0}.{1}", localizationKey, keySuffix)); + } + + @Override + public String toString() + { + return "GlobalDatePickerHotKey{" + + "localizationKey='" + localizationKey + '\'' + + ", hasModifier=" + hasModifier + + "} " + super.toString(); + } +} diff --git a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/HotKeysController.java b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/HotKeysController.java index 1ffdf9581093dd16461026e4f2d14d6dcb2bae21..afb1712dca7168bb83608a04a73e1292879baa75 100644 --- a/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/HotKeysController.java +++ b/BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/HotKeysController.java @@ -14,6 +14,7 @@ public class HotKeysController extends BaseController { public static final String HOTKEYS_GENERAL = "hotkeysGeneral"; public static final String HOTKEYS_DATEPICKER = "hotkeysGlobalDatePicker"; + public static final String HOTKEYS_ACCOUNT_SELECT = "hotkeysAccountSelect"; } private static class ReturnValues @@ -26,6 +27,7 @@ public class HotKeysController extends BaseController { model.addAttribute(ModelAttributes.HOTKEYS_GENERAL, GeneralHotKey.values()); model.addAttribute(ModelAttributes.HOTKEYS_DATEPICKER, GlobalDatePickerHotKey.values()); + model.addAttribute(ModelAttributes.HOTKEYS_ACCOUNT_SELECT, GlobalAccountSelectHotKey.values()); return ReturnValues.HOTKEYS; } } \ No newline at end of file diff --git a/BudgetMasterServer/src/main/resources/languages/base_de.properties b/BudgetMasterServer/src/main/resources/languages/base_de.properties index 6bd31dac8a13c3d3fc8287d4150a1e9e8fbbb40c..54cce75940462f367486a525cd154609eced89e9 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_de.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_de.properties @@ -534,6 +534,11 @@ hotkeys.global.datepicker.next.month.key=Pfeiltaste rechts hotkeys.global.datepicker.next.month=Nächster Monat hotkeys.global.datepicker.today.key=0 hotkeys.global.datepicker.today=Aktueller Monat +hotkeys.global.account.select=Kontoauswahl +hotkeys.global.account.select.open.key=a +hotkeys.global.account.select.open=Kontoauswahl öffnen +hotkeys.global.account.select.by.number.key=0 - 9 +hotkeys.global.account.select.by.number=Konto auswählen # charts diff --git a/BudgetMasterServer/src/main/resources/languages/base_en.properties b/BudgetMasterServer/src/main/resources/languages/base_en.properties index c79600afcc9f0876e5fbefec840427464a8286d7..ecbc1eba763981f8bec5f5820f2d3216a1333600 100644 --- a/BudgetMasterServer/src/main/resources/languages/base_en.properties +++ b/BudgetMasterServer/src/main/resources/languages/base_en.properties @@ -535,6 +535,11 @@ hotkeys.global.datepicker.next.month.key=Right arrow key hotkeys.global.datepicker.next.month=Next month hotkeys.global.datepicker.today.key=0 hotkeys.global.datepicker.today=Current month +hotkeys.global.account.select=Account selection +hotkeys.global.account.select.open.key=a +hotkeys.global.account.select.open=Open account select +hotkeys.global.account.select.by.number.key=0 - 9 +hotkeys.global.account.select.by.number=Choose account # charts chart.dispay.type=Display type diff --git a/BudgetMasterServer/src/main/resources/static/js/hotkeys.js b/BudgetMasterServer/src/main/resources/static/js/hotkeys.js index 6f6f7534cf4d7e5cc67e0e6dc85bb657bdaae50e..ae66b32889709a35c96f47f6499cae0892811e6a 100644 --- a/BudgetMasterServer/src/main/resources/static/js/hotkeys.js +++ b/BudgetMasterServer/src/main/resources/static/js/hotkeys.js @@ -55,6 +55,14 @@ Mousetrap.bind('o', function() } }); +Mousetrap.bind('a', function() +{ + if(areHotKeysEnabled()) + { + document.getElementById('globalAccountSelect').click(); + } +}); + let saveTransactionOrTemplateButton = document.getElementById('button-save-transaction'); if(saveTransactionOrTemplateButton !== null) { diff --git a/BudgetMasterServer/src/main/resources/templates/hotkeys.ftl b/BudgetMasterServer/src/main/resources/templates/hotkeys.ftl index afba98b7340fd971f59a108b9da867bd7502c636..6362b283882e98402127f15d9bcaccbd7cfef1f5 100644 --- a/BudgetMasterServer/src/main/resources/templates/hotkeys.ftl +++ b/BudgetMasterServer/src/main/resources/templates/hotkeys.ftl @@ -20,27 +20,11 @@ <@header.content> <br> - <div class="row"> - <div class="col s12 headline center-align">${locale.getString("hotkeys.general")}</div> - </div> - - <#list hotkeysGeneral as hotKey> - <div class="row"> - <@cellKeyWithModifier hotKey.getModifierLocalized()!'' hotKey.getKeyLocalized()/> - <div class="col s8 m5 l5">${hotKey.getTextLocalized()}</div> - </div> - </#list> + <@listHotKeys locale.getString("hotkeys.general") hotkeysGeneral/> - <div class="row"> - <div class="col s12 headline center-align">${locale.getString("hotkeys.global.datepicker")}</div> - </div> + <@listHotKeys locale.getString("hotkeys.global.datepicker") hotkeysGlobalDatePicker/> - <#list hotkeysGlobalDatePicker as hotKey> - <div class="row"> - <@cellKeyWithModifier hotKey.getModifierLocalized()!'' hotKey.getKeyLocalized()/> - <div class="col s8 m5 l5">${hotKey.getTextLocalized()}</div> - </div> - </#list> + <@listHotKeys locale.getString("hotkeys.global.account.select") hotkeysAccountSelect/> </@header.content> </div> </main> @@ -65,4 +49,17 @@ </#if> <div class="keyboard-key">${key}</div> </div> +</#macro> + +<#macro listHotKeys headline hotKeys> + <div class="row"> + <div class="col s12 headline center-align">${headline}</div> + </div> + + <#list hotKeys as hotKey> + <div class="row"> + <@cellKeyWithModifier hotKey.getModifierLocalized()!'' hotKey.getKeyLocalized()/> + <div class="col s8 m5 l5">${hotKey.getTextLocalized()}</div> + </div> + </#list> </#macro> \ No newline at end of file