LT-67: Replacing servers list form by components and API instances
This commit is contained in:
1 parent
e6cb4e873a
commit
72bafdd014
6 files changed
+90
-93
No files matched your search
+2
-2
@@ -1,5 +1,5 @@
|
||||
<template name="serverInformationForm">
|
||||
{{#form class='server-information-form' schema=instance.currentSchema}}
|
||||
{{#form class='server-information-form' schema=instance.currentSchema api=instance.api}}
|
||||
{{>inputHidden key='_id'}}
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
@@ -20,7 +20,7 @@
|
||||
{{/if}}
|
||||
{{#if this.serverType.get}}
|
||||
<div>
|
||||
<input type="submit" class="btn btn-primary" value="Save">
|
||||
{{#button class='btn-primary' action='save'}}Save{{/button}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/form}}
|
||||
|
||||
+21
-24
@@ -7,6 +7,27 @@ import { DIMSEServer as dimseSchema } from 'meteor/worklist/both/schema';
|
||||
Template.serverInformationForm.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
|
||||
instance.api = {
|
||||
save() {
|
||||
// Stop here if the form validation fails
|
||||
if (!instance.data.form.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current form data
|
||||
const formData = instance.data.form.value();
|
||||
|
||||
// Call the save method
|
||||
Meteor.call('serverSave', formData, function(error) {
|
||||
if (error) {
|
||||
// TODO: check for errors: not-authorized, data-write
|
||||
}
|
||||
|
||||
instance.data.resetState();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
instance.currentSchema = new ReactiveVar(dicomSchema);
|
||||
});
|
||||
|
||||
@@ -49,27 +70,3 @@ Template.serverInformationForm.onRendered(() => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Template.serverInformationForm.events({
|
||||
submit(event, instance) {
|
||||
event.preventDefault();
|
||||
|
||||
// Stop here if the form validation fails
|
||||
if (!instance.data.form.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current form data
|
||||
const formData = instance.data.form.value();
|
||||
|
||||
// Call the save method
|
||||
Meteor.call('serverSave', formData, function(error) {
|
||||
if (error) {
|
||||
// TODO: check for errors: not-authorized, data-write
|
||||
console.log('>>>>ERROR', error);
|
||||
}
|
||||
|
||||
instance.data.resetState();
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user