OHIF-332: Users should be able to see all available hotkeys and language settings in one place (#1895)

* OHIF-330: Update Modal Styles

* feat/ohif-332: finish raw ui

* feat/ohif-332: update mode configuration strategy

* feat/ohif-332: fix hotkey errors

* feat/ohif-332: update hotkey logic with recent merged changes

* feat/ohif-322: wrap

* feat/ohif-322: add disable state

* ohif-332: cr updates

* ohif-332: disable

* ohif-332: cr updates

* ohif-332: extract header component

* ohif-332: cr update to fix merge conflicts and design issue

Co-authored-by: Rodrigo Antinarelli <rodrigoantinarelli@gmail.com>
This commit is contained in:
Igor OctavianoandRodrigo Antinarelli authored and GitHub committed 2020-08-19 15:02:59 -04:00
1 parent ae3d05ebf7
commit 3e944780dc
37 files changed
+913 -256

No files matched your search

+23 -7
View File
@@ -61,8 +61,7 @@ export class HotkeysManager {
*/
setHotkeys(hotkeyDefinitions = []) {
try {
const definitions = this._getValidDefinitions(hotkeyDefinitions);
const definitions = this.getValidDefinitions(hotkeyDefinitions);
definitions.forEach(definition => this.registerHotkeys(definition));
} catch (error) {
const { UINotificationService } = this._servicesManager.services;
@@ -81,8 +80,7 @@ export class HotkeysManager {
* @param {HotkeyDefinition[] | Object} [hotkeyDefinitions=[]] Contains hotkeys definitions
*/
setDefaultHotKeys(hotkeyDefinitions = []) {
const definitions = this._getValidDefinitions(hotkeyDefinitions);
const definitions = this.getValidDefinitions(hotkeyDefinitions);
this.hotkeyDefaults = definitions;
}
@@ -92,7 +90,7 @@ export class HotkeysManager {
*
* @param {HotkeyDefinition[] | Object} [hotkeyDefinitions=[]] Contains hotkeys definitions
*/
_getValidDefinitions(hotkeyDefinitions) {
getValidDefinitions(hotkeyDefinitions) {
const definitions = Array.isArray(hotkeyDefinitions)
? [...hotkeyDefinitions]
: this._parseToArrayLike(hotkeyDefinitions);
@@ -100,6 +98,24 @@ export class HotkeysManager {
return definitions;
}
/**
* Take hotkey definitions that can be an array and make sure that it
* returns an object of hotkeys definitions
*
* @param {HotkeyDefinition[]} [hotkeyDefinitions=[]] Contains hotkeys definitions
* @returns {Object}
*/
getValidHotkeyDefinitions(hotkeyDefinitions) {
const definitions = this.getValidDefinitions(hotkeyDefinitions);
const objectDefinitions = {};
definitions.forEach(definition => {
const { commandName, commandOptions } = definition;
const commandHash = objectHash({ commandName, commandOptions });
objectDefinitions[commandHash] = definition;
});
return objectDefinitions;
}
/**
* It parses given object containing hotkeyDefinition to array like.
* Each property of given object will be mapped to an object of an array. And its property name will be the value of a property named as commandName
@@ -147,7 +163,7 @@ export class HotkeysManager {
* @param {String} extension
* @returns {undefined}
*/
registerHotkeys({ commandName, commandOptions = {}, keys, label } = {}, extension) {
registerHotkeys({ commandName, commandOptions = {}, keys, label, isEditable } = {}, extension) {
if (!commandName) {
log.warn(`[hotkeys] No command was defined for hotkey "${keys}"`);
return;
@@ -164,7 +180,7 @@ export class HotkeysManager {
}
// Set definition & bind
this.hotkeyDefinitions[commandHash] = { keys, label };
this.hotkeyDefinitions[commandHash] = { commandName, commandOptions, keys, label, isEditable };
this._bindHotkeys(commandName, commandOptions, keys);
log.info(`[hotkeys] Binding ${commandName} with ${options} options to ${keys}`);
}