Prototyped the barcode idea; Added a basic production system.
This commit is contained in:
@@ -12,7 +12,7 @@ Tracker.autorun(function() {
|
||||
});
|
||||
|
||||
Template.Products.onCreated(function() {
|
||||
Session.set(PREFIX + "displayNewProduct", false);
|
||||
Session.set(PREFIX + "displayNew", false);
|
||||
Session.set(PREFIX + "showHidden", false);
|
||||
Session.set(PREFIX + "queryLimit", QUERY_LIMIT);
|
||||
});
|
||||
@@ -25,8 +25,8 @@ Template.Products.onRendered(function() {
|
||||
});
|
||||
});
|
||||
Template.Products.helpers({
|
||||
displayNewProduct: function() {
|
||||
return Session.get(PREFIX + "displayNewProduct");
|
||||
displayNew: function() {
|
||||
return Session.get(PREFIX + "displayNew");
|
||||
},
|
||||
products: function() {
|
||||
let skipCount = Session.get(PREFIX + 'skipCount') || 0;
|
||||
@@ -68,16 +68,16 @@ Template.Products.events({
|
||||
event.preventDefault();
|
||||
Session.set(PREFIX + 'queryLimit', Session.get(PREFIX + "queryLimit") + QUERY_LIMIT_INCREMENT);
|
||||
},
|
||||
'click .newProductButton': function(event, template) {
|
||||
if(template.$('.newProductButton').hasClass('active')) {
|
||||
Session.set(PREFIX + 'displayNewProduct', false);
|
||||
'click .newButton': function(event, template) {
|
||||
if(template.$('.newButton').hasClass('active')) {
|
||||
Session.set(PREFIX + 'displayNew', false);
|
||||
}
|
||||
else {
|
||||
Session.set(PREFIX + 'displayNewProduct', true);
|
||||
Session.set(PREFIX + "editedProduct", undefined); //Clear the edited product so that only one editor is open at a time.
|
||||
Session.set(PREFIX + 'displayNew', true);
|
||||
Session.set(PREFIX + "editedId", undefined); //Clear the edited product so that only one editor is open at a time.
|
||||
Session.set(PREFIX + "convertedProduct", undefined); //Clear the converted product so that only one editor is open at a time.
|
||||
}
|
||||
template.$('.newProductButton').toggleClass('active');
|
||||
template.$('.newButton').toggleClass('active');
|
||||
},
|
||||
'change input[name="showHidden"]': function(event, template) {
|
||||
//console.log("changed " + $(event.target).prop('checked'));
|
||||
@@ -166,9 +166,9 @@ Template.Product.helpers({
|
||||
return result;
|
||||
},
|
||||
editing: function() {
|
||||
let editedProduct = Session.get(PREFIX + "editedProduct");
|
||||
let editedId = Session.get(PREFIX + "editedId");
|
||||
|
||||
return editedProduct == this._id;
|
||||
return editedId == this._id;
|
||||
},
|
||||
converting: function() {
|
||||
let convertedProduct = Session.get(PREFIX + "convertedProduct");
|
||||
@@ -181,10 +181,10 @@ Template.Product.helpers({
|
||||
});
|
||||
Template.Product.events({
|
||||
"click .actionEdit": function(event, template) {
|
||||
Session.set(PREFIX + "editedProduct", this._id);
|
||||
Session.set(PREFIX + 'displayNewProduct', false); //Ensure the new product editor is closed.
|
||||
Session.set(PREFIX + "editedId", this._id);
|
||||
Session.set(PREFIX + 'displayNew', false); //Ensure the new editor is closed.
|
||||
Session.set(PREFIX + "convertedProduct", undefined); //Clear the converted product so that only one editor is open at a time.
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
},
|
||||
"click .actionDeactivate": function(event, template) {
|
||||
Meteor.call('deactivateProduct', this._id, function(error, result) {
|
||||
@@ -206,9 +206,9 @@ Template.Product.events({
|
||||
},
|
||||
"click .actionConvert": function(event, template) {
|
||||
Session.set(PREFIX + "convertedProduct", this._id);
|
||||
Session.set(PREFIX + 'displayNewProduct', false); //Ensure the new product editor is closed.
|
||||
Session.set(PREFIX + "editedProduct", undefined); //Clear the edited product so that only one editor is open at a time.
|
||||
template.$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + 'displayNew', false); //Ensure the new editor is closed.
|
||||
Session.set(PREFIX + "editedId", undefined); //Clear the edited product so that only one editor is open at a time.
|
||||
template.$('.newButton').removeClass('active');
|
||||
},
|
||||
'click .actionHide': function(event, template) {
|
||||
Meteor.call('hideProduct', this._id, function(error, result) {
|
||||
@@ -249,9 +249,9 @@ Template.ProductEditor.helpers({
|
||||
});
|
||||
Template.ProductEditor.events({
|
||||
"click .editorCancel": function(event, template) {
|
||||
Session.set(PREFIX + "editedProduct", undefined);
|
||||
Session.set(PREFIX + 'displayNewProduct', false);
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
Session.set(PREFIX + 'displayNew', false);
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
},
|
||||
"click .editorApply": function(event, template) {
|
||||
let name = template.$("input[name='name']").val().trim();
|
||||
@@ -263,13 +263,13 @@ Template.ProductEditor.events({
|
||||
aliases = aliases.map((n)=>n.id);
|
||||
measures = measures.map((n)=>n.id);
|
||||
|
||||
if(Session.get(PREFIX + 'displayNewProduct')) {
|
||||
if(Session.get(PREFIX + 'displayNew')) {
|
||||
Meteor.call("createProduct", name, tags, aliases, measures, function(error, result) {
|
||||
if(error) sAlert.error(error);
|
||||
else {
|
||||
sAlert.success("Product created.");
|
||||
Session.set(PREFIX + 'displayNewProduct', false);
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + 'displayNew', false);
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -278,8 +278,8 @@ Template.ProductEditor.events({
|
||||
if(error) sAlert.error(error);
|
||||
else {
|
||||
sAlert.success("Product updated.");
|
||||
Session.set(PREFIX + "editedProduct", undefined);
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -296,10 +296,10 @@ Template.ConvertProduct.onRendered(function() {
|
||||
});
|
||||
Template.ConvertProduct.events({
|
||||
"click .editorCancel": function(event, template) {
|
||||
Session.set(PREFIX + "editedProduct", undefined);
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
Session.set(PREFIX + "convertedProduct", undefined);
|
||||
Session.set(PREFIX + 'displayNewProduct', false);
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + 'displayNew', false);
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
},
|
||||
"click .editorApply": function(event, template) {
|
||||
let productId = template.selectedProduct.get()._id;
|
||||
@@ -308,10 +308,10 @@ Template.ConvertProduct.events({
|
||||
if(error) sAlert.error(error);
|
||||
else {
|
||||
sAlert.success("Sales of this product were converted.");
|
||||
Session.set(PREFIX + "editedProduct", undefined);
|
||||
Session.set(PREFIX + "editedId", undefined);
|
||||
Session.set(PREFIX + "convertedProduct", undefined);
|
||||
Session.set(PREFIX + 'displayNewProduct', false);
|
||||
template.parentTemplate().$('.newProductButton').removeClass('active');
|
||||
Session.set(PREFIX + 'displayNew', false);
|
||||
template.parentTemplate().$('.newButton').removeClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user