From e55e2ad05ad784ce3899378d438fbc198e6cf2da Mon Sep 17 00:00:00 2001 From: ladeirarodolfo <39910206+ladeirarodolfo@users.noreply.github.com> Date: Mon, 25 Jun 2018 07:08:38 -0300 Subject: [PATCH] feat(subtools) Changing toolBarSection to accept custom template subtools. I.e. coder could pass his own template as part of subtools for specific tool button (#211) --- .../toolbarSectionButton.html | 20 ++++++++++++------- .../toolbarSectionButton.js | 11 ++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html index ea00874c2..d3fd7e644 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html +++ b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.html @@ -3,7 +3,7 @@ {{>UI.dynamic template=this.buttonTemplateName data=this}} {{else}}
{{#let svg=svgLink icon=iconClasses}} @@ -18,18 +18,24 @@
{{this.title}} - {{#if this.subTools}} + {{#if hasSubTools}} {{/if}}
- {{#if this.subTools}} + {{#if hasSubTools}}
- {{#each subTool in this.subTools}} - {{>toolbarSectionButton subTool}} - {{/each}} + {{#if this.subToolsTemplateName}} + {{>UI.dynamic template=this.subToolsTemplateName data=this}} + {{else}} + {{#if this.subTools}} + {{#each subTool in this.subTools}} + {{>toolbarSectionButton subTool}} + {{/each}} + {{/if}} + {{/if}}
-
+
{{/if}} {{/if}} diff --git a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js index bdf47cc2f..6d3dcadae 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js +++ b/Packages/ohif-viewerbase/client/components/viewer/toolbarSectionButton/toolbarSectionButton.js @@ -106,6 +106,10 @@ Template.toolbarSectionButton.helpers({ const isCommandDisabled = OHIF.commands.isDisabled(instance.data.id); const isFunctionDisabled = instance.data.disableFunction && instance.data.disableFunction(); return isCommandDisabled || isFunctionDisabled; + }, + + hasSubTools() { + return this.subTools || this.subToolsTemplateName; } }); @@ -113,9 +117,12 @@ Template.toolbarSectionButton.events({ 'click .toolbarSectionButton:not(.expandable)'(event, instance) { // Prevent the event from bubbling to parent tools event.stopPropagation(); + const $currentTarget = $(event.currentTarget); - // Stop here if the button is disabled - if ($(event.currentTarget).hasClass('disabled')) return; + // Stop here if the button is disabled or customAction + if ($currentTarget.hasClass('disabled') || $currentTarget.hasClass('customAction')) { + return; + } // Run the command attached to the button OHIF.commands.run(instance.data.id);