mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 16:28:50 +00:00
Lots of changes made (almost a refactor <--- four letter word to me... - Menu Items collection is now the "permanent" storage location for menu item for any day. So, if i set Green Chile Chicken Enchiladas, Beans, and Rice as an item for a day, it will be stored as a Menu Item for later use. - Linking menu items to items that can be added to a shopping list - This has been updated to be more reusable. So as you re-choose a menu item that's already got list items linked, it just shows up for you to use to build a shopping list as needed. - Deleting menu items from a menu - changed to delete them only from the menu, and not from the database. - Dashboard updated to pull today's menu item from the menu, and not the menu item list.
74 lines
2.8 KiB
JavaScript
74 lines
2.8 KiB
JavaScript
import { M } from '../lib/assets/materialize.js';
|
|
import { Products } from '../../imports/api/products.js';
|
|
import { MenuItems } from '../../imports/api/menuItems';
|
|
import { MenuProdLinks } from '../../imports/api/menuProdLinks.js';
|
|
|
|
Template.modalLinkProducts.onCreated(function() {
|
|
this.subscribe("myMenuItems");
|
|
this.subscribe("myProducts");
|
|
this.subscribe("menuProdLinkData");
|
|
});
|
|
|
|
Template.modalLinkProducts.onRendered(function() {
|
|
var elems = document.querySelectorAll('.modal');
|
|
var instances = M.Modal.init(elems, {});
|
|
|
|
var elemse = document.querySelectorAll('select');
|
|
var instancese = M.FormSelect.init(elemse, {
|
|
dropdownOptions: 4,
|
|
});
|
|
|
|
setTimeout(function() {
|
|
var instances = M.Modal.init(elems, {});
|
|
var instancese = M.FormSelect.init(elemse, {
|
|
dropdownOptions: 4,
|
|
});
|
|
}, 250);
|
|
});
|
|
|
|
Template.modalLinkProducts.helpers({
|
|
products: function() {
|
|
return Products.find({});
|
|
}
|
|
});
|
|
|
|
Template.modalLinkProducts.events({
|
|
'click #saveLink' (event) {
|
|
event.preventDefault();
|
|
let menuItemId = Session.get("menuItemId");
|
|
let menuItemName = Session.get("menuItemName");
|
|
let linkSelect = document.getElementById('prodForMenu');
|
|
let linkObjArray = [];
|
|
let links = M.FormSelect.getInstance(linkSelect).getSelectedValues();
|
|
if (typeof links != undefined && links != [] && links != null) {
|
|
// let's split these links into their parts, and make an array of objects
|
|
for (i=0; i<links.length; i++) {
|
|
let linkArray = links[i].split('|');
|
|
let key = linkArray[0];
|
|
let value = linkArray[1];
|
|
let linkObj = { prodId: key, prodName: value };
|
|
linkObjArray.push(linkObj);
|
|
}
|
|
|
|
Meteor.call("add.menuProdLinks", menuItemId, menuItemName, linkObjArray, function(err, result) {
|
|
if (err) {
|
|
console.log(" ERROR adding product links to this menu item: " + err);
|
|
} else {
|
|
Meteor.call('update.menuItemLinked', menuItemId, true, function(err, result) {
|
|
if (err) {
|
|
console.log(" ERROR adding link to menu item: " + err);
|
|
} else {
|
|
Meteor.call('link.inMenu', menuItemId, true, function(error, nresult) {
|
|
if (error) {
|
|
console.log(" ERROR adding link to menu sub-item: " + error);
|
|
} else {
|
|
showSnackbar("Products added to Menu Item successfully!", "green");
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|