2022-08-15 18:07:39 -05:00
|
|
|
import { Categories } from '../../../imports/api/category.js';
|
|
|
|
|
|
|
|
|
|
Template.catMgmtTbl.onCreated(function() {
|
|
|
|
|
this.subscribe("myCategories");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.catMgmtTbl.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.catMgmtTbl.helpers({
|
|
|
|
|
cats: function() {
|
|
|
|
|
return Categories.find({});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.catMgmtTbl.events({
|
2022-08-23 13:41:21 -05:00
|
|
|
'click .deleteCategory' (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Meteor.call('delete.category', this._id, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log(" ERROR deleting category: " + err);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(" SUCCESS deleting the category.");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
'click .editCategory' (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
Session.set("categoryEditId", this._id);
|
|
|
|
|
Session.set("catEditMode", true);
|
|
|
|
|
let catInfo = Categories.findOne({ _id: this._id });
|
|
|
|
|
$("#catNameInp").val(catInfo.categoryName);
|
|
|
|
|
}
|
2022-08-15 18:07:39 -05:00
|
|
|
});
|