LT-67: Migrating DICOMWeb form inputs to components

This commit is contained in:
Bruno Alves de Faria committed 2016-08-29 18:22:40 -03:00
1 parent 6cbfc1c180
commit 4e70e62b7b
7 files changed
+97 -77

No files matched your search

+1 -2
View File
@@ -1,6 +1,5 @@
import { SimpleSchema } from 'meteor/aldeed:simple-schema';
SimpleSchema.extendOptions({
valuesLabels: Match.Optional([String]),
emptyOption: Match.Optional(Boolean)
valuesLabels: Match.Optional([String])
});
@@ -7,43 +7,6 @@ import { Template } from 'meteor/templating';
OHIF.mixins.select = new OHIF.Mixin({
dependencies: 'formItem',
composition: {
onCreated() {
const instance = Template.instance();
// Check if this select will include an empty option
if (instance.data.emptyOption) {
// Get the option items
let items = instance.data.items;
// Check if the items are reactive and get them if true
const isReactive = items instanceof ReactiveVar;
if (isReactive) {
items = items.get();
}
// Check if there is already an empty option on items list
const query = {
value: ''
};
if (!_.findWhere(items, query)) {
// Clone the current items
const newItems = _.clone(items);
newItems.unshift({
label: 'Select',
value: ''
});
// Set the new items list including the empty option
if (isReactive) {
instance.data.items.set(newItems);
} else {
instance.data.items = newItems;
}
}
}
},
onRendered() {
const instance = Template.instance();
const component = instance.component;
@@ -51,6 +14,5 @@ OHIF.mixins.select = new OHIF.Mixin({
// Set the element to be controlled
component.$element = instance.$('select:first');
}
}
});
@@ -8,6 +8,43 @@ import { $ } from 'meteor/jquery';
OHIF.mixins.select2 = new OHIF.Mixin({
dependencies: 'select',
composition: {
onCreated() {
const instance = Template.instance();
// Check if this select will include a placeholder
const placeholder = instance.data.options && instance.data.options.placeholder;
if (placeholder) {
// Get the option items
let items = instance.data.items;
// Check if the items are reactive and get them if true
const isReactive = items instanceof ReactiveVar;
if (isReactive) {
items = items.get();
}
// Check if there is already an empty option on items list
const query = {
value: ''
};
if (!_.findWhere(items, query)) {
// Clone the current items
const newItems = _.clone(items) || [];
newItems.unshift({
label: placeholder,
value: ''
});
// Set the new items list including the empty option
if (isReactive) {
instance.data.items.set(newItems);
} else {
instance.data.items = newItems;
}
}
}
},
onRendered() {
const instance = Template.instance();
const component = instance.component;