Allowing visible attribute on dropdown items

This commit is contained in:
Bruno Alves de Faria 2017-04-13 17:38:34 -03:00
parent 4fd18c61aa
commit b7d1e91848
4 changed files with 39 additions and 22 deletions

View File

@ -32,7 +32,7 @@ OHIF.mixins.action = new OHIF.Mixin({
// Stop here calling the action if it's a function // Stop here calling the action if it's a function
if (typeof action === 'function') { if (typeof action === 'function') {
component.actionResult = action.call(this, params); component.actionResult = action.call(event.currentTarget, params);
return component.actionResult; return component.actionResult;
} }
@ -40,7 +40,7 @@ OHIF.mixins.action = new OHIF.Mixin({
if (!api || !action || typeof api[action] !== 'function') return; if (!api || !action || typeof api[action] !== 'function') return;
// Call the defined action function // 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 // Prepend a spinner into the action element content if it's a promise
if (component.actionResult instanceof Promise) { if (component.actionResult instanceof Promise) {

View File

@ -10,6 +10,7 @@
{{>UI.contentBlock}} {{>UI.contentBlock}}
{{else}} {{else}}
{{#each item in this.items}} {{#each item in this.items}}
{{#if isVisible item}}
{{#if item.separatorBefore}} {{#if item.separatorBefore}}
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
{{/if}} {{/if}}
@ -31,6 +32,7 @@
{{#if item.separatorAfter}} {{#if item.separatorAfter}}
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
{{/if}} {{/if}}
{{/if}}
{{/each}} {{/each}}
{{/if}} {{/if}}
</ul> </ul>

View File

@ -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;
}
});

View File

@ -16,6 +16,7 @@ import './dialog/unsavedChangesDialog.html';
import './dialog/unsavedChangesDialog.js'; import './dialog/unsavedChangesDialog.js';
import './dropdown/form.html'; import './dropdown/form.html';
import './dropdown/form.js';
import './form/button.html'; import './form/button.html';
import './form/form.html'; import './form/form.html';