diff --git a/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.html b/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.html index eda51afe9..9101be616 100644 --- a/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.html +++ b/Packages/lesiontracker/client/components/serverInformation/serverInformationForm/serverInformationForm.html @@ -6,7 +6,8 @@ {{>inputText labelClass='form-group' key='name'}}
- {{>inputSelect labelClass='form-group' key='type' hideSearch=true + {{>inputSelect labelClass='form-group' key='type' + hideSearch=true disabled=(eq this.mode.get 'edit') options=(clone placeholder='Choose a server type...')}}
diff --git a/Packages/ohif-core/both/schema.js b/Packages/ohif-core/both/schema.js index 6c2b354b7..ca1d9776e 100644 --- a/Packages/ohif-core/both/schema.js +++ b/Packages/ohif-core/both/schema.js @@ -1,5 +1,27 @@ import { SimpleSchema } from 'meteor/aldeed:simple-schema'; +/* + Extend the available options on schema definitions: + + * valuesLabels: Used in conjunction with allowedValues to define the text + label for each value (used on forms) + + * textOptional: Used to allow empty strings + + */ SimpleSchema.extendOptions({ - valuesLabels: Match.Optional([String]) + valuesLabels: Match.Optional([String]), + textOptional: Match.Optional(Boolean) +}); + +// Add default required validation for empty strings which can be bypassed +// using textOptional=true definition +SimpleSchema.addValidator(function() { + if ( + this.definition.optional !== true && + this.definition.textOptional !== true && + this.value === '' + ) { + return 'required'; + } }); diff --git a/Packages/ohif-core/client/components/base/mixins/group.js b/Packages/ohif-core/client/components/base/mixins/group.js index 79450cd7e..f64d3565e 100644 --- a/Packages/ohif-core/client/components/base/mixins/group.js +++ b/Packages/ohif-core/client/components/base/mixins/group.js @@ -30,23 +30,43 @@ OHIF.mixins.group = new OHIF.Mixin({ component.value = value => { const isGet = _.isUndefined(value); const isArray = instance.data.arrayValues; + + // Create the result data as array or object const result = isArray ? [] : {}; + // Get the group current value and return it if (isGet) { + // Iterate over each registered item and extract its value component.registeredItems.forEach(child => { - if (!isArray) { + // Check if it is an array or an object group + if (isArray) { + // Push the item value to the result array + result.push(child.value()); + } else { + // Get the item key const key = child.templateInstance.data.key; + + //Check if a key is set for the item if (key) { + // Add the item value to the result object result[key] = child.value(); } - } else { - result.push(child.value()); } }); + + // Return the resulting data as array or object return result; } + // Get the group current value const groupValue = typeof value === 'object' ? value : result; + + // Stop here if there is no value defined for this group + if (!groupValue) { + return; + } + + // Iterate over each registered item and set its value let i = 0; component.registeredItems.forEach(child => { const key = isArray ? i : child.templateInstance.data.key; @@ -54,6 +74,8 @@ OHIF.mixins.group = new OHIF.Mixin({ child.value(childValue); i++; }); + + // Trigger the change event after setting the new value component.$element.trigger('change'); }; diff --git a/Packages/ohif-core/client/components/base/templates/select.html b/Packages/ohif-core/client/components/base/templates/select.html index fa1535a33..3db0c7de0 100644 --- a/Packages/ohif-core/client/components/base/templates/select.html +++ b/Packages/ohif-core/client/components/base/templates/select.html @@ -4,6 +4,7 @@ class="{{this.class}}" name="{{this.name}}" multiple="{{#if this.multiple}}multiple{{/if}}" + disabled="{{#if this.disabled}}disabled{{/if}}" data-key="{{this.key}}" {{this.tagAttributes}} >