Fixes and updates.

This commit is contained in:
Wynne Crisman
2020-01-16 09:31:12 -08:00
parent 2e57558ef4
commit a20e42e360
25 changed files with 346 additions and 820 deletions

View File

@@ -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.");
}
// }
//});
}
});