Removed Categories and Locations

This commit is contained in:
Brian McGonagill 2024-07-06 11:13:35 -05:00
parent c916c278a2
commit 2b1022f513
23 changed files with 4 additions and 637 deletions

View file

@ -1,7 +1,5 @@
import { Products } from '../../../imports/api/products.js';
import { Stores } from '../../../imports/api/stores.js';
import { Categories } from '../../../imports/api/category.js';
import { Locations } from '../../../imports/api/location.js';
Template.prodMgmtForm.onCreated(function() {
this.subscribe("myProducts");
@ -26,12 +24,6 @@ Template.prodMgmtForm.helpers({
prodNameErr: function() {
return Session.get("prodNameRed");
},
category: function() {
return Categories.find({});
},
locations: function() {
return Locations.find({});
},
prodEditMode: function() {
return Session.get("prodEditMode");
},
@ -41,17 +33,7 @@ Template.prodMgmtForm.events({
'click .saveProdMgmt' (event) {
event.preventDefault();
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
if (cat == null) {
cat = "";
}
if (location == null) {
location = "";
}
if (store == null) {
store = "";
@ -61,15 +43,13 @@ Template.prodMgmtForm.events({
Session.set("prodNameRed", true);
return;
} else {
Meteor.call('add.product', name, cat, store, location, function(err, result) {
Meteor.call('add.product', name, store, function(err, result) {
if (err) {
// console.log(" ERROR: can't add product: " + err);
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
@ -78,8 +58,7 @@ Template.prodMgmtForm.events({
'click .editProdMgmt' (event) {
event.preventDefault();
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
let prodId = Session.get("prodEditId");
@ -105,9 +84,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
Session.set("prodEditMode", false);
}
@ -118,9 +95,7 @@ Template.prodMgmtForm.events({
// event.preventDefault();
if (event.which === 13) {
let name = $("#prodName").val();
let cat = $("#prodCategory").val();
let store = $("#prodStore").val();
let location = $("#prodLocation").val();
let prodId = Session.get("prodEditId");
let prodEditMode = Session.get("prodEditMode");
console.log(" ---- got the submit event for products.");
@ -147,9 +122,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
@ -160,9 +133,7 @@ Template.prodMgmtForm.events({
} else {
// console.log(" SUCCESS adding product.");
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
}
});
@ -173,9 +144,7 @@ Template.prodMgmtForm.events({
'click .cancelProdMgmt' (event) {
event.preventDefault();
$("#prodName").val("");
$("#prodCategory").val("");
$("#prodStore").val("");
$("#prodLocation").val("");
$('select').formSelect();
},
'change #prodStore' (event) {
@ -188,26 +157,6 @@ Template.prodMgmtForm.events({
$('#modalStore').modal('open');
}
},
'change #prodLocation' (event) {
event.preventDefault();
let val = $("#prodLocation").val();
if (val == "addNewLocation") {
$("#prodLocation").val("");
// open a modal to enter store information.
$('#modalLocation').modal('open');
}
},
'change #prodCategory' (event) {
event.preventDefault();
let val = $("#prodCategory").val();
if (val == "addNewCat") {
$("#prodCategory").val("");
// open a modal to enter store information.
$('#modalCategory').modal('open');
}
},
'click .modal-close' (event) {
$('select').formSelect();
}