Fixed Editing products

This commit is contained in:
Brian McGonagill 2024-07-06 11:47:45 -05:00
parent 2b1022f513
commit 909030ea0f

View file

@ -4,8 +4,6 @@ import { Stores } from '../../../imports/api/stores.js';
Template.prodMgmtForm.onCreated(function() { Template.prodMgmtForm.onCreated(function() {
this.subscribe("myProducts"); this.subscribe("myProducts");
this.subscribe("storeInfo"); this.subscribe("storeInfo");
this.subscribe("myCategories");
this.subscribe("myLocations");
}); });
Template.prodMgmtForm.onRendered(function() { Template.prodMgmtForm.onRendered(function() {
@ -58,17 +56,8 @@ Template.prodMgmtForm.events({
'click .editProdMgmt' (event) { 'click .editProdMgmt' (event) {
event.preventDefault(); event.preventDefault();
let name = $("#prodName").val(); let name = $("#prodName").val();
let location = $("#prodLocation").val();
let prodId = Session.get("prodEditId"); let prodId = Session.get("prodEditId");
let store = $("#prodStore").val();
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) { if (store == null) {
store = ""; store = "";
@ -78,7 +67,7 @@ Template.prodMgmtForm.events({
Session.set("prodNameRed", true); Session.set("prodNameRed", true);
return; return;
} else { } else {
Meteor.call('edit.product', prodId, name, cat, store, location, function(err, result) { Meteor.call('edit.product', prodId, name, store, function(err, result) {
if (err) { if (err) {
// console.log(" ERROR: can't add product: " + err); // console.log(" ERROR: can't add product: " + err);
} else { } else {
@ -99,13 +88,6 @@ Template.prodMgmtForm.events({
let prodId = Session.get("prodEditId"); let prodId = Session.get("prodEditId");
let prodEditMode = Session.get("prodEditMode"); let prodEditMode = Session.get("prodEditMode");
console.log(" ---- got the submit event for products."); console.log(" ---- got the submit event for products.");
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) { if (store == null) {
store = ""; store = "";
@ -116,7 +98,7 @@ Template.prodMgmtForm.events({
return; return;
} else { } else {
if (prodEditMode == true) { if (prodEditMode == true) {
Meteor.call('edit.product', prodId, name, cat, store, location, function(err, result) { Meteor.call('edit.product', prodId, name, store, function(err, result) {
if (err) { if (err) {
// console.log(" ERROR: can't add product: " + err); // console.log(" ERROR: can't add product: " + err);
} else { } else {
@ -127,7 +109,7 @@ Template.prodMgmtForm.events({
} }
}); });
} else { } else {
Meteor.call('add.product', name, cat, store, location, function(err, result) { Meteor.call('add.product', name, store, function(err, result) {
if (err) { if (err) {
// console.log(" ERROR: can't add product: " + err); // console.log(" ERROR: can't add product: " + err);
} else { } else {