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

#681 - added new hotkey to open global account select

parent a1683dc6
No related branches found
No related tags found
No related merge requests found
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();
}
}
...@@ -14,6 +14,7 @@ public class HotKeysController extends BaseController ...@@ -14,6 +14,7 @@ public class HotKeysController extends BaseController
{ {
public static final String HOTKEYS_GENERAL = "hotkeysGeneral"; public static final String HOTKEYS_GENERAL = "hotkeysGeneral";
public static final String HOTKEYS_DATEPICKER = "hotkeysGlobalDatePicker"; public static final String HOTKEYS_DATEPICKER = "hotkeysGlobalDatePicker";
public static final String HOTKEYS_ACCOUNT_SELECT = "hotkeysAccountSelect";
} }
private static class ReturnValues private static class ReturnValues
...@@ -26,6 +27,7 @@ public class HotKeysController extends BaseController ...@@ -26,6 +27,7 @@ public class HotKeysController extends BaseController
{ {
model.addAttribute(ModelAttributes.HOTKEYS_GENERAL, GeneralHotKey.values()); model.addAttribute(ModelAttributes.HOTKEYS_GENERAL, GeneralHotKey.values());
model.addAttribute(ModelAttributes.HOTKEYS_DATEPICKER, GlobalDatePickerHotKey.values()); model.addAttribute(ModelAttributes.HOTKEYS_DATEPICKER, GlobalDatePickerHotKey.values());
model.addAttribute(ModelAttributes.HOTKEYS_ACCOUNT_SELECT, GlobalAccountSelectHotKey.values());
return ReturnValues.HOTKEYS; return ReturnValues.HOTKEYS;
} }
} }
\ No newline at end of file
...@@ -534,6 +534,11 @@ hotkeys.global.datepicker.next.month.key=Pfeiltaste rechts ...@@ -534,6 +534,11 @@ hotkeys.global.datepicker.next.month.key=Pfeiltaste rechts
hotkeys.global.datepicker.next.month=Nächster Monat hotkeys.global.datepicker.next.month=Nächster Monat
hotkeys.global.datepicker.today.key=0 hotkeys.global.datepicker.today.key=0
hotkeys.global.datepicker.today=Aktueller Monat 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 # charts
......
...@@ -535,6 +535,11 @@ hotkeys.global.datepicker.next.month.key=Right arrow key ...@@ -535,6 +535,11 @@ hotkeys.global.datepicker.next.month.key=Right arrow key
hotkeys.global.datepicker.next.month=Next month hotkeys.global.datepicker.next.month=Next month
hotkeys.global.datepicker.today.key=0 hotkeys.global.datepicker.today.key=0
hotkeys.global.datepicker.today=Current month 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 # charts
chart.dispay.type=Display type chart.dispay.type=Display type
......
...@@ -55,6 +55,14 @@ Mousetrap.bind('o', function() ...@@ -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'); let saveTransactionOrTemplateButton = document.getElementById('button-save-transaction');
if(saveTransactionOrTemplateButton !== null) if(saveTransactionOrTemplateButton !== null)
{ {
......
...@@ -20,27 +20,11 @@ ...@@ -20,27 +20,11 @@
<@header.content> <@header.content>
<br> <br>
<div class="row"> <@listHotKeys locale.getString("hotkeys.general") hotkeysGeneral/>
<div class="col s12 headline center-align">${locale.getString("hotkeys.general")}</div>
</div>
<#list hotkeysGeneral as hotKey> <@listHotKeys locale.getString("hotkeys.global.datepicker") hotkeysGlobalDatePicker/>
<div class="row">
<@cellKeyWithModifier hotKey.getModifierLocalized()!'' hotKey.getKeyLocalized()/>
<div class="col s8 m5 l5">${hotKey.getTextLocalized()}</div>
</div>
</#list>
<div class="row"> <@listHotKeys locale.getString("hotkeys.global.account.select") hotkeysAccountSelect/>
<div class="col s12 headline center-align">${locale.getString("hotkeys.global.datepicker")}</div>
</div>
<#list hotkeysGlobalDatePicker as hotKey>
<div class="row">
<@cellKeyWithModifier hotKey.getModifierLocalized()!'' hotKey.getKeyLocalized()/>
<div class="col s8 m5 l5">${hotKey.getTextLocalized()}</div>
</div>
</#list>
</@header.content> </@header.content>
</div> </div>
</main> </main>
...@@ -66,3 +50,16 @@ ...@@ -66,3 +50,16 @@
<div class="keyboard-key">${key}</div> <div class="keyboard-key">${key}</div>
</div> </div>
</#macro> </#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment