From bfa4ac04d379289958fc24adf66b1476337a95dd Mon Sep 17 00:00:00 2001 From: Robert Goldmann <deadlocker@gmx.de> Date: Sun, 22 May 2022 18:18:28 +0200 Subject: [PATCH] #681 - added new hotkey to open global account select --- .../hotkeys/GlobalAccountSelectHotKey.java | 61 +++++++++++++++++++ .../hotkeys/HotKeysController.java | 2 + .../resources/languages/base_de.properties | 5 ++ .../resources/languages/base_en.properties | 5 ++ .../src/main/resources/static/js/hotkeys.js | 8 +++ .../src/main/resources/templates/hotkeys.ftl | 35 +++++------ 6 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 BudgetMasterServer/src/main/java/de/deadlocker8/budgetmaster/hotkeys/GlobalAccountSelectHotKey.java 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 000000000..908b07b92 --- /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 1ffdf9581..afb1712dc 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 6bd31dac8..54cce7594 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 c79600afc..ecbc1eba7 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 6f6f7534c..ae66b3288 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 afba98b73..6362b2838 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 -- GitLab