Replacing studyListContextMenu for dropdown

This commit is contained in:
Bruno Alves de Faria committed 2017-03-21 10:16:47 -03:00
1 parent 4daf7d8bf8
commit 485f82f64c
22 files changed
+250 -325

No files matched your search

@@ -20,11 +20,12 @@ OHIF.mixins.action = new OHIF.Mixin({
event.preventDefault();
const component = instance.component;
// Extract action, params and disabled state
const { action, params, disabled } = instance.data;
// Extract action, disabled state and params
const { action } = instance.data;
const params = instance.data.params ? instance.data.params : event;
// Stop here if the component is disabled
if (disabled) return;
if (component.$element.hasClass('disabled')) return;
// Get the current component's API
const api = component.getApi();
@@ -42,7 +42,8 @@ OHIF.mixins.dropdown = new OHIF.Mixin({
// Close the dropdown resolving or rejecting the promise
instance.close = (isResolve, result) => {
const method = instance.data[isResolve ? 'promiseResolve' : 'promiseReject'];
method(result);
const param = result instanceof Promise ? null : result;
method(param);
};
// Stop here and destroy the view if no items was given
@@ -52,7 +53,7 @@ OHIF.mixins.dropdown = new OHIF.Mixin({
dropdown.oncontextmenu = () => false;
const cssBefore = { 'z-index': 10000 };
const cssBefore = {};
if (event) {
cssBefore.position = 'fixed';
$dropdownMenu.bounded();
@@ -6,9 +6,13 @@
ul.dropdown-menu
display: block
z-index: 1000
transform(scale(0))
transition(transform 0.3s ease)
&.dropdown-menu-left
transform-origin(0% 0%)
&.dropdown-menu-right
transform-origin(100% 0%)
@@ -0,0 +1,38 @@
import { Tracker } from 'meteor/tracker';
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core';
class Dropdown {
constructor() {
this.observer = new Tracker.Dependency();
this._items = [];
this.observer.changed();
}
clearItems() {
this._items = [];
this.observer.changed();
}
setItems(items) {
this._items = items;
this.observer.changed();
}
addItem(item) {
this._items.push(item);
this.observer.changed();
}
removeItem(item) {
this._items = _.without(this._items, item);
this.observer.changed();
}
getItems() {
this.observer.depend();
return this._items;
}
}
OHIF.ui.Dropdown = Dropdown;
@@ -1,29 +0,0 @@
import { Template } from 'meteor/templating';
import { Blaze } from 'meteor/blaze';
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core';
OHIF.ui.showFormDropdown = (templateName, dropdownData) => {
// Check if the given template exists
const template = Template[templateName];
if (!template) {
throw {
name: 'TEMPLATE_NOT_FOUND',
message: `Template ${templateName} not found.`
};
}
// Prepare the method to destroy the view
let view;
const destroyView = () => Blaze.remove(view);
const templateData = _.extend({}, dropdownData, {
destroyView
});
// Render the dialog with the given template and data
view = Blaze.renderWithData(template, templateData, document.body);
// Return the dropdown element to enable position manipulation
const dropdown = view.firstNode();
return dropdown;
};
+2 -2
View File
@@ -4,7 +4,7 @@ import './dialog/display.js';
import './dialog/spatial.js';
import './dialog/unsavedChangesDialog.js';
import './draggable/draggable.js';
import './dropdown/dropdown.js';
import './dropdown/form.js';
import './dropdown/class.js';
import './dropdown/display.js';
import './resizable/resizable.js';
import './unsavedChanges/unsavedChanges.js';