From 3f8350a79b830972ecd97f3ef88b79562446819a Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 5 Jan 2017 15:33:13 -0200 Subject: [PATCH] LT-115: Fixing hidden fortawesome icons for sub tools --- .../toolbarSectionButton.html | 16 +++++----- .../toolbarSectionButton.js | 29 +++++++++++++------ 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html index 6e6e01441..4899fed77 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html +++ b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html @@ -7,13 +7,15 @@ title="{{this.tooltipTitle}}">
- {{#if this.svgLink}} - - - - {{else}} - - {{/if}} + {{#let svg=svgLink icon=iconClasses}} + {{#if svg}} + + + + {{else}} + + {{/if}} + {{/let}}
{{this.title}} diff --git a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js index b015269ab..a565356f3 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js +++ b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js @@ -17,6 +17,20 @@ Template.toolbarSectionButton.onCreated(() => { // Check if the current tool or a sub tool is the active one return isCurrentTool || isSubTool; }; + + instance.getActiveToolSubProperty = (propertyName, activeToolId) => { + const instance = Template.instance(); + const subTools = instance.data.subTools; + const defaultProperty = instance.data[propertyName]; + const currentId = instance.data.id; + + if (subTools && activeToolId !== currentId && instance.isActive(activeToolId)) { + const subTool = _.findWhere(subTools, { id: activeToolId }); + return subTool ? subTool[propertyName] : defaultProperty; + } else { + return defaultProperty; + } + }; }); Template.toolbarSectionButton.helpers({ @@ -29,17 +43,14 @@ Template.toolbarSectionButton.helpers({ svgLink() { const instance = Template.instance(); - const subTools = instance.data.subTools; - const defaultSvgLink = instance.data.svgLink; const activeToolId = Session.get('ToolManagerActiveTool'); - const currentId = instance.data.id; + return instance.getActiveToolSubProperty('svgLink', activeToolId); + }, - if (subTools && activeToolId !== currentId && instance.isActive(activeToolId)) { - const subTool = _.findWhere(subTools, { id: activeToolId }); - return subTool ? subTool.svgLink : defaultSvgLink; - } else { - return defaultSvgLink; - } + iconClasses() { + const instance = Template.instance(); + const activeToolId = Session.get('ToolManagerActiveTool'); + return instance.getActiveToolSubProperty('iconClasses', activeToolId); }, disableButton() {