From b7d1e91848755ab46da983f0e4cc7f7677af139a Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Thu, 13 Apr 2017 17:38:34 -0300 Subject: [PATCH] Allowing visible attribute on dropdown items --- .../client/components/base/mixins/action.js | 4 +- .../components/bootstrap/dropdown/form.html | 42 ++++++++++--------- .../components/bootstrap/dropdown/form.js | 14 +++++++ .../client/components/bootstrap/index.js | 1 + 4 files changed, 39 insertions(+), 22 deletions(-) create mode 100644 Packages/ohif-core/client/components/bootstrap/dropdown/form.js diff --git a/Packages/ohif-core/client/components/base/mixins/action.js b/Packages/ohif-core/client/components/base/mixins/action.js index 26e139bd8..a2ac27758 100644 --- a/Packages/ohif-core/client/components/base/mixins/action.js +++ b/Packages/ohif-core/client/components/base/mixins/action.js @@ -32,7 +32,7 @@ OHIF.mixins.action = new OHIF.Mixin({ // Stop here calling the action if it's a function if (typeof action === 'function') { - component.actionResult = action.call(this, params); + component.actionResult = action.call(event.currentTarget, params); return component.actionResult; } @@ -40,7 +40,7 @@ OHIF.mixins.action = new OHIF.Mixin({ if (!api || !action || typeof api[action] !== 'function') return; // Call the defined action function - component.actionResult = api[action].call(this, params); + component.actionResult = api[action].call(event.currentTarget, params); // Prepend a spinner into the action element content if it's a promise if (component.actionResult instanceof Promise) { diff --git a/Packages/ohif-core/client/components/bootstrap/dropdown/form.html b/Packages/ohif-core/client/components/bootstrap/dropdown/form.html index ac7d668d9..1744f7e6d 100644 --- a/Packages/ohif-core/client/components/bootstrap/dropdown/form.html +++ b/Packages/ohif-core/client/components/bootstrap/dropdown/form.html @@ -10,26 +10,28 @@ {{>UI.contentBlock}} {{else}} {{#each item in this.items}} - {{#if item.separatorBefore}} - - {{/if}} -
  • - {{#link item}} - {{#if item.icon}} - - {{/if}} - {{#if item.iconSvgUse}} - - - - {{/if}} - {{#if item.text}} - {{item.text}} - {{/if}} - {{/link}} -
  • - {{#if item.separatorAfter}} - + {{#if isVisible item}} + {{#if item.separatorBefore}} + + {{/if}} +
  • + {{#link item}} + {{#if item.icon}} + + {{/if}} + {{#if item.iconSvgUse}} + + + + {{/if}} + {{#if item.text}} + {{item.text}} + {{/if}} + {{/link}} +
  • + {{#if item.separatorAfter}} + + {{/if}} {{/if}} {{/each}} {{/if}} diff --git a/Packages/ohif-core/client/components/bootstrap/dropdown/form.js b/Packages/ohif-core/client/components/bootstrap/dropdown/form.js new file mode 100644 index 000000000..5c0f6dd48 --- /dev/null +++ b/Packages/ohif-core/client/components/bootstrap/dropdown/form.js @@ -0,0 +1,14 @@ +import { Template } from 'meteor/templating'; + +Template.dropdownFormMenu.helpers({ + isVisible(item) { + let isVisible = true; + if (typeof item.visible === 'function') { + isVisible = item.visible(); + } else if (typeof item.visible !== 'undefined') { + isVisible = !!item.visible; + } + + return isVisible; + } +}); diff --git a/Packages/ohif-core/client/components/bootstrap/index.js b/Packages/ohif-core/client/components/bootstrap/index.js index a85beb554..2de8cc008 100644 --- a/Packages/ohif-core/client/components/bootstrap/index.js +++ b/Packages/ohif-core/client/components/bootstrap/index.js @@ -16,6 +16,7 @@ import './dialog/unsavedChangesDialog.html'; import './dialog/unsavedChangesDialog.js'; import './dropdown/form.html'; +import './dropdown/form.js'; import './form/button.html'; import './form/form.html';