2022-08-26 17:10:05 -05:00
|
|
|
import { Menus } from '../../imports/api/menu.js';
|
2024-07-23 14:59:43 -05:00
|
|
|
import { M } from '../lib/assets/materialize.js';
|
2022-08-26 17:10:05 -05:00
|
|
|
|
|
|
|
|
Template.mainMenuTbl.onCreated(function() {
|
|
|
|
|
this.subscribe("myMenus");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.mainMenuTbl.onRendered(function() {
|
|
|
|
|
Session.set("menuEditMode", false);
|
2024-07-23 14:59:43 -05:00
|
|
|
var elems = document.querySelectorAll('.modal');
|
|
|
|
|
var instances = M.Modal.init(elems, {});
|
2022-08-26 17:10:05 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.mainMenuTbl.helpers({
|
|
|
|
|
myMenus: function() {
|
|
|
|
|
return Menus.find({});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.mainMenuTbl.events({
|
|
|
|
|
'click li.collection-item' (event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
let sender = event.target;
|
|
|
|
|
// console.log("Sender origination from: ");
|
|
|
|
|
// console.log(sender.localName);
|
|
|
|
|
if (sender.localName == "li") {
|
|
|
|
|
let menuId = event.currentTarget.id;
|
|
|
|
|
if (menuId == "addMenu") {
|
2024-07-23 14:59:43 -05:00
|
|
|
// console.log("add menu clicked");
|
2022-08-26 17:10:05 -05:00
|
|
|
} else {
|
|
|
|
|
console.log("menuId is: " + menuId);
|
|
|
|
|
Session.set("menuId", menuId);
|
|
|
|
|
Meteor.setTimeout(function() {
|
|
|
|
|
FlowRouter.go('/menuitems');
|
|
|
|
|
}, 100);
|
|
|
|
|
}
|
2022-08-29 16:50:30 -05:00
|
|
|
} else if (sender.localName == "i") {
|
|
|
|
|
let menuId = this._id;
|
|
|
|
|
Meteor.call("markMenu.complete", menuId, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log(" ERROR: can't mark menu complete: " + err);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(" SUCCESS marking menu complete.");
|
2022-08-30 16:17:53 -05:00
|
|
|
Meteor.call('setAllMade.menuItem', menuId, function(err, result) {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.log(" ERROR: cannot set all items as made: " + err);
|
|
|
|
|
} else {
|
|
|
|
|
console.log(" SUCCESS setting all items made.");
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-08-29 16:50:30 -05:00
|
|
|
}
|
|
|
|
|
});
|
2022-08-26 17:10:05 -05:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
});
|