Creating Window Level Presets form

This commit is contained in:
Bruno Alves de Faria 2017-04-28 17:17:36 -03:00 committed by Erik Ziegler
parent 22f1e659fa
commit 4d9300f6c4
6 changed files with 43 additions and 5 deletions

View File

@ -1,5 +1,7 @@
<template name="hotkeysDialog">
{{#dialogSimple (extend this dialogClass='dialog-hotkeys' title='Keyboard Shortcuts')}}
{{>hotkeysForm this}}
<hr>
{{>windowLevelPresetsForm this}}
{{/dialogSimple}}
</template>

View File

@ -120,13 +120,14 @@ Template.hotkeysForm.helpers({
const commandsContext = OHIF.commands.getContext(contextName);
if (!hotkeysContext || !commandsContext) return hotkeysInputInformation;
const hotkeyDefinitions = hotkeysContext.definitions;
_.each(hotkeyDefinitions, (keyCombination, commandName) => {
const commands = Object.keys(OHIF.hotkeys.defaults[contextName] || {});
commands.forEach(commandName => {
const commandDefinitions = commandsContext[commandName];
if (!commandDefinitions) return;
hotkeysInputInformation.push({
key: commandName,
label: commandDefinitions.name,
value: keyCombination
value: hotkeyDefinitions[commandName] || ''
});
});
return hotkeysInputInformation;

View File

@ -0,0 +1,10 @@
<template name="windowLevelPresetsForm">
{{#form (extend this class='form-themed' api=instance.api)}}
{{>inputText label='W/L Preset 1' key='WLPreset1'}}
<hr>
<div class="clearfix">
{{#button class='btn btn-primary pull-right' action='save'}}Save{{/button}}
{{#button class='btn btn-secondary pull-right m-r-1' action='resetDefaults'}}Reset to Defaults{{/button}}
</div>
{{/form}}
</template>

View File

@ -0,0 +1,25 @@
import { Template } from 'meteor/templating';
import { OHIF } from 'meteor/ohif:core';
Template.windowLevelPresetsForm.onCreated(() => {
const instance = Template.instance();
instance.api = {
save() {
const form = instance.$('form').first().data('component');
const definitions = form.value();
// TODO: return save method with promise
},
resetDefaults() {
const dialogOptions = {
title: 'Reset Window Level Presets to Default',
message: 'Are you sure you want to reset all the window level presets to their defaults?'
};
return OHIF.ui.showDialog('dialogConfirm', dialogOptions).then(() => {
// TODO: return reset method with promise
});
}
};
});

View File

@ -402,9 +402,6 @@ export const toolManager = {
toolManager.init();
}
// Prevent changing if tool is already active
if (tool === toolManager.getActiveTool()) return;
/**
* TODO: Add textMarkerDialogs template to OHIF's
*/

View File

@ -191,6 +191,9 @@ Package.onUse(function(api) {
api.addFiles('client/components/viewer/studyTimepointBrowser/studyTimepointStudy.styl', 'client');
api.addFiles('client/components/viewer/studyTimepointBrowser/studyTimepointStudy.js', 'client');
api.addFiles('client/components/viewer/windowLevelPresets/form.html', 'client');
api.addFiles('client/components/viewer/windowLevelPresets/form.js', 'client');
api.export('dialogPolyfill', 'client');
api.mainModule('main.js', 'client');