2022-08-15 18:07:39 -05:00
|
|
|
import { Products } from '../../../imports/api/products.js';
|
|
|
|
|
|
|
|
|
|
Template.prodMgmtTbl.onCreated(function() {
|
|
|
|
|
this.subscribe("myProducts");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.prodMgmtTbl.onRendered(function() {
|
2022-08-23 13:41:21 -05:00
|
|
|
Meteor.setTimeout(function() {
|
|
|
|
|
$('.tooltipped').tooltip();
|
|
|
|
|
}, 150);
|
2022-08-15 18:07:39 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.prodMgmtTbl.helpers({
|
|
|
|
|
products: function() {
|
|
|
|
|
return Products.find({});
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.prodMgmtTbl.events({
|
2022-08-23 13:41:21 -05:00
|
|
|
'click .deleteProduct' (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Meteor.call('delete.product', this._id, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log(" ERROR deleting product: " + err);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(" SUCCESS deleting the product.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .editProduct' (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Session.set("prodEditMode", true);
|
|
|
|
|
Session.set("prodEditId", this._id);
|
|
|
|
|
let prodInfo = Products.findOne({ _id: this._id });
|
|
|
|
|
$("#prodName").val(prodInfo.prodName);
|
|
|
|
|
$("#prodCategory").val(prodInfo.prodCategory);
|
|
|
|
|
$("#prodLocation").val(prodInfo.prodLocation);
|
|
|
|
|
$("#prodStore").val(prodInfo.prodStore);
|
|
|
|
|
$('select').formSelect();
|
|
|
|
|
}
|
2022-08-15 18:07:39 -05:00
|
|
|
});
|