LT-67: Migrating DIMSE inputs to components
This commit is contained in:
parent
c3d7c2af09
commit
e5eb98cbc0
@ -1,5 +1,5 @@
|
||||
Template.serverInformationDicomWeb.onRendered(function() {
|
||||
var instance = Template.instance();
|
||||
Template.serverInformationDicomWeb.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
instance.autorun(function() {
|
||||
const mode = instance.data.mode.get();
|
||||
if (mode === 'edit') {
|
||||
|
||||
@ -5,39 +5,41 @@
|
||||
<button class="btn btn-primary pull-right js-new-peer">New peer</button>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row">
|
||||
{{#group class='row' key='peers' arrayValues=true}}
|
||||
{{#each peer in instance.peers.get}}
|
||||
<div class="col-lg-6">
|
||||
{{#group class='col-lg-6'}}
|
||||
<div class="panel panel-default panel-body">
|
||||
<div class="row">
|
||||
{{>serverInformationFormField name=(concat "peers[]." @index ".aeTitle") label="AE title"}}
|
||||
{{>serverInformationFormField name=(concat "peers[]." @index ".hostAE") label="AE host"}}
|
||||
{{>serverInformationFormField name=(concat "peers[]." @index ".host") label="Host"}}
|
||||
{{>serverInformationFormField name=(concat "peers[]." @index ".port") label="Port"}}
|
||||
<div class="col-lg-6">
|
||||
{{>inputText class='form-control' key='aeTitle'}}
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
{{>inputText class='form-control' key='hostAE'}}
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
{{>inputText class='form-control' key='host'}}
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
{{>inputText class='form-control' key='port'}}
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<strong>Settings</strong>
|
||||
<div class="form-group">
|
||||
<div class="form-control clearfix">
|
||||
<div class="checkbox pull-left">
|
||||
<label>
|
||||
<input type="checkbox" name="peers[].{{@index}}.default">
|
||||
<span>Default</span>
|
||||
</label>
|
||||
{{>inputCheckbox key='default'}}
|
||||
</div>
|
||||
<div class="checkbox pull-left">
|
||||
<label>
|
||||
<input type="checkbox" name="peers[].{{@index}}.server">
|
||||
<span>Server</span>
|
||||
</label>
|
||||
{{>inputCheckbox key='server'}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/group}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/group}}
|
||||
</div>
|
||||
<hr>
|
||||
</template>
|
||||
|
||||
@ -1,29 +1,29 @@
|
||||
Template.serverInformationDimse.onCreated(function() {
|
||||
var instance = Template.instance();
|
||||
Template.serverInformationDimse.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
instance.peers = new ReactiveVar([]);
|
||||
instance.autorun(function() {
|
||||
var currentItem = instance.data.currentItem.get();
|
||||
instance.autorun(() => {
|
||||
const currentItem = instance.data.currentItem.get();
|
||||
if (currentItem) {
|
||||
instance.peers.set(currentItem.peers || []);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.serverInformationDimse.onRendered(function() {
|
||||
var instance = Template.instance();
|
||||
instance.autorun(function() {
|
||||
var mode = instance.data.mode.get();
|
||||
Template.serverInformationDimse.onRendered(() => {
|
||||
const instance = Template.instance();
|
||||
instance.autorun(() => {
|
||||
const mode = instance.data.mode.get();
|
||||
if (mode === 'edit') {
|
||||
var data = instance.data.currentItem.get();
|
||||
FormUtils.setFormData(instance.data.$form, data);
|
||||
const data = instance.data.currentItem.get();
|
||||
instance.data.form.value(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.serverInformationDimse.events({
|
||||
'click .js-new-peer': function(event, instance) {
|
||||
'click .js-new-peer'(event, instance) {
|
||||
event.preventDefault();
|
||||
var peers = instance.peers.get();
|
||||
const peers = instance.peers.get();
|
||||
peers.push({});
|
||||
instance.peers.set(peers);
|
||||
}
|
||||
|
||||
@ -29,22 +29,30 @@ OHIF.mixins.group = new OHIF.Mixin({
|
||||
// Get or set the child components values
|
||||
component.value = value => {
|
||||
const isGet = _.isUndefined(value);
|
||||
const isArray = instance.data.arrayValues;
|
||||
const result = isArray ? [] : {};
|
||||
|
||||
if (isGet) {
|
||||
const result = {};
|
||||
component.registeredItems.forEach(child => {
|
||||
const key = child.templateInstance.data.key;
|
||||
if (key) {
|
||||
result[key] = child.value();
|
||||
if (!isArray) {
|
||||
const key = child.templateInstance.data.key;
|
||||
if (key) {
|
||||
result[key] = child.value();
|
||||
}
|
||||
} else {
|
||||
result.push(child.value());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
const groupValue = typeof value === 'object' ? value : {};
|
||||
const groupValue = typeof value === 'object' ? value : result;
|
||||
let i = 0;
|
||||
component.registeredItems.forEach(child => {
|
||||
const key = child.templateInstance.data.key;
|
||||
const key = isArray ? i : child.templateInstance.data.key;
|
||||
const childValue = _.isUndefined(groupValue[key]) ? null : groupValue[key];
|
||||
child.value(childValue);
|
||||
i++;
|
||||
});
|
||||
component.$element.trigger('change');
|
||||
};
|
||||
|
||||
@ -52,10 +52,13 @@ OHIF.mixins.schemaData = new OHIF.Mixin({
|
||||
const parent = OHIF.blaze.getParentComponent(Blaze.currentView);
|
||||
|
||||
// Get he parent component key
|
||||
let parentKey = parent && parent.templateInstance.data.pathKey;
|
||||
const parentKey = parent && parent.templateInstance.data.pathKey;
|
||||
|
||||
// Check if the parent is an array group
|
||||
const isParentArray = parent && parent.templateInstance.data.arrayValues;
|
||||
|
||||
// Set the path key for this component
|
||||
data.pathKey = data.key || '';
|
||||
data.pathKey = data.key || (isParentArray ? '$' : '');
|
||||
if (data.pathKey && typeof parentKey === 'string') {
|
||||
const prefix = parentKey ? `${parentKey}.` : '';
|
||||
data.pathKey = `${prefix}${data.pathKey}`;
|
||||
@ -107,7 +110,7 @@ OHIF.mixins.schemaData = new OHIF.Mixin({
|
||||
const component = instance.component;
|
||||
|
||||
// Get the current schema data using component's key
|
||||
const currentSchema = getCurrentSchema(component.parent, instance.data.key);
|
||||
const currentSchema = getCurrentSchema(component.parent, instance.data.pathKey);
|
||||
|
||||
// Stop here if there's no schema data for current key
|
||||
if (!currentSchema) {
|
||||
|
||||
@ -81,11 +81,11 @@ export const DICOMWebServer = new SimpleSchema({
|
||||
export const DIMSEPeer = new SimpleSchema({
|
||||
aeTitle: {
|
||||
type: String,
|
||||
label: 'Application Entity (AE) Title',
|
||||
label: 'AE Title',
|
||||
},
|
||||
hostAE: {
|
||||
type: String,
|
||||
label: 'Application Entity (AE) Host',
|
||||
label: 'AE Host',
|
||||
optional: true
|
||||
},
|
||||
host: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user