Saving the hotkeys definitions

This commit is contained in:
Bruno Alves de Faria 2017-04-28 10:25:48 -03:00 committed by Erik Ziegler
parent 20f274962b
commit a77838d550
3 changed files with 13 additions and 2 deletions

View File

@ -22,7 +22,7 @@ export class HotkeysContext {
register(command, hotkey) {
if (!hotkey) {
return OHIF.log.warn(`No hotkey was defined for "${command}"`);
return;
}
if (!command) {

View File

@ -1,7 +1,9 @@
<template name="hotkeysForm">
{{#form (extend this class='form-themed')}}
{{#form (extend this class='form-themed' api=instance.api)}}
{{#each hotkeyInputInformation in getHotkeyInputInformationList}}
{{>inputText (extend hotkeyInputInformation class='hotkey')}}
{{/each}}
<hr>
{{#button class='btn btn-primary' action='save'}}Save{{/button}}
{{/form}}
</template>

View File

@ -7,6 +7,15 @@ import { OHIF } from 'meteor/ohif:core';
Template.hotkeysForm.onCreated(() => {
const instance = Template.instance();
instance.api = {
save() {
const { contextName } = instance.data;
const form = instance.$('form').first().data('component');
const definitions = form.value();
OHIF.hotkeys.store(contextName, definitions);
}
};
const rg = (start, end) => _.range(start, end + 1);
instance.allowedKeys = _.union(rg(32, 40), rg(48, 57), rg(65, 90), rg(112, 121), [123]);