Fixes and updates.
This commit is contained in:
@@ -126,6 +126,9 @@ Template.Batch.helpers({
|
||||
},
|
||||
isDeleted: function() {
|
||||
return this.deletedAt;
|
||||
},
|
||||
jdate: function() {
|
||||
return moment(this.date, "YYYYMMDD").format("YYDDDD");
|
||||
}
|
||||
});
|
||||
Template.Batch.events({
|
||||
@@ -157,6 +160,8 @@ Template.Batch.events({
|
||||
Template.BatchEditor.onCreated(function() {
|
||||
});
|
||||
Template.BatchEditor.onRendered(function() {
|
||||
//Not working????
|
||||
//this.$('.editorForm').validator();
|
||||
});
|
||||
Template.BatchEditor.helpers({
|
||||
name: function() {
|
||||
@@ -181,15 +186,30 @@ Template.BatchEditor.events({
|
||||
'click .editorCancel': function(event, template) {
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
},
|
||||
'click input[type="submit"]': function(event, template) {
|
||||
event.preventDefault();
|
||||
template.$('.insertForm').data('bs.validator').validate(function(isValid) {
|
||||
if(isValid) {
|
||||
//Allow the user to edit the comment and the amount produced. Sometimes jars pop after the product cools and these things need to be recorded.
|
||||
'click .editorApply': function(event, template) {
|
||||
//template.$('.editorForm').data('bs.validator').validate(function(isValid) {
|
||||
// if(isValid) {
|
||||
let id = template.data._id;
|
||||
let amount = parseInt(template.$('input.amount').val());
|
||||
let comment = template.$('#batchEditorComment').val();
|
||||
|
||||
//TODO
|
||||
}
|
||||
});
|
||||
console.log(id + " " + amount + " " + comment);
|
||||
|
||||
if(Number.isInteger(amount) && amount > 0) {
|
||||
|
||||
Meteor.call('updateBatch', id, amount, comment, function(error) {
|
||||
if(error) sAlert.error("Failed to update the batch!\n" + error);
|
||||
else {
|
||||
sAlert.success("Production batch updated.");
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
sAlert.error("Amount must be a number greater than zero.");
|
||||
}
|
||||
// }
|
||||
//});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user