LT-67: Migrating the remaining DicomWEB inputs to components

This commit is contained in:
Bruno Alves de Faria 2016-08-30 11:03:57 -03:00
parent 18516b47f0
commit 9e2ab2d21a
4 changed files with 31 additions and 19 deletions

View File

@ -30,28 +30,21 @@
<hr> <hr>
<h4>Request options</h4> <h4>Request options</h4>
<div class="row"> <div class="row">
{{>serverInformationFormField name="requestOptions.auth" label="Authentication"}} <div class="col-lg-6">
{{>inputText labelClass='form-group' key='requestOptions.auth'}}
</div>
<div class="col-lg-6"> <div class="col-lg-6">
<strong>Logging options</strong> <strong>Logging options</strong>
<div class="form-group"> <div class="form-group">
<div class="form-control clearfix"> <div class="form-control clearfix">
<div class="checkbox pull-left"> <div class="checkbox pull-left">
<label> {{>inputCheckbox key='requestOptions.logRequests'}}
<input type="checkbox" name="requestOptions.logRequests">
<span>Requests</span>
</label>
</div> </div>
<div class="checkbox pull-left"> <div class="checkbox pull-left">
<label> {{>inputCheckbox key='requestOptions.logResponses'}}
<input type="checkbox" name="requestOptions.logResponses">
<span>Responses</span>
</label>
</div> </div>
<div class="checkbox pull-left"> <div class="checkbox pull-left">
<label> {{>inputCheckbox key='requestOptions.logTiming'}}
<input type="checkbox" name="requestOptions.logTiming">
<span>Timing</span>
</label>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,10 +1,10 @@
Template.serverInformationDicomWeb.onRendered(function() { Template.serverInformationDicomWeb.onRendered(function() {
var instance = Template.instance(); var instance = Template.instance();
instance.autorun(function() { instance.autorun(function() {
var mode = instance.data.mode.get(); const mode = instance.data.mode.get();
if (mode === 'edit') { if (mode === 'edit') {
var data = instance.data.currentItem.get(); const data = instance.data.currentItem.get();
FormUtils.setFormData(instance.data.$form, data); instance.data.form.value(data);
} }
}); });
}); });

View File

@ -1,5 +1,6 @@
import { Template } from 'meteor/templating'; import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var'; import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { DICOMWebServer as dicomSchema } from 'meteor/worklist/both/schema'; import { DICOMWebServer as dicomSchema } from 'meteor/worklist/both/schema';
import { DIMSEServer as dimseSchema } from 'meteor/worklist/both/schema'; import { DIMSEServer as dimseSchema } from 'meteor/worklist/both/schema';
@ -12,7 +13,7 @@ Template.serverInformationForm.onCreated(() => {
Template.serverInformationForm.onRendered(() => { Template.serverInformationForm.onRendered(() => {
const instance = Template.instance(); const instance = Template.instance();
instance.data.$form = instance.$('form'); instance.data.$form = instance.$('form:first');
instance.data.form = instance.data.$form.data('component'); instance.data.form = instance.data.$form.data('component');
// Handle the server type // Handle the server type
@ -21,7 +22,7 @@ Template.serverInformationForm.onRendered(() => {
const typeComponent = instance.$('[data-key=type]').data('component'); const typeComponent = instance.$('[data-key=type]').data('component');
// Run this computation every time the user change the server type // Run this computation every time the user change the server type
typeComponent.changeObserver.depend(); typeComponent.depend();
// Get the current server type value // Get the current server type value
const type = typeComponent.value(); const type = typeComponent.value();
@ -43,7 +44,7 @@ Template.serverInformationForm.onRendered(() => {
// Check if it is on edit mode and load the saved data // Check if it is on edit mode and load the saved data
if (mode === 'edit') { if (mode === 'edit') {
var data = instance.data.currentItem.get(); const data = instance.data.currentItem.get();
instance.data.form.value(data); instance.data.form.value(data);
} }
}); });

View File

@ -26,6 +26,24 @@ OHIF.mixins.form = new OHIF.Mixin({
component.schema = schema && schema.newContext(); component.schema = schema && schema.newContext();
}); });
// Get a registered item in form by its key
component.item = itemKey => {
let found;
// Iterate over each registered form item
component.registeredItems.forEach(child => {
const key = child.templateInstance.data.key;
// Change the found item if current key is the same as given
if (key === itemKey) {
found = child;
}
});
// Return the found item or undefined if it was not found
return found;
};
// Check if the form data is valid in its schema // Check if the form data is valid in its schema
component.validate = () => { component.validate = () => {
// Assume validation result as true // Assume validation result as true