Updated menus to work better with list item linking

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.
This commit is contained in:
Brian McGonagill 2024-08-14 11:38:13 -05:00
parent 3f6618d906
commit 88fa7c1d22
13 changed files with 216 additions and 149 deletions

View file

@ -1,11 +1,13 @@
import { MenuItems } from '../../imports/api/menuItems.js';
import { M } from '../lib/assets/materialize.js';
import { UserLast } from '../../imports/api/userLast.js';
import { Menus } from '../../imports/api/menu.js';
Template.menuItemsTbl.onCreated(function() {
this.autorun( () => {
this.subscribe("myMenuItems", Session.get("menuId"));
});
this.subscribe("menuItems");
this.subscribe("userLastView");
});
@ -30,7 +32,7 @@ Template.menuItemsTbl.helpers({
} else {
menuId = UserLast.findOne({ view: "Menu" }).viewId;
}
let menuInfo = MenuItems.find({ menuId: menuId }, { sort: { serveDateActual: 1 }});
let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }});
if (menuInfo) {
return menuInfo
}
@ -40,18 +42,22 @@ Template.menuItemsTbl.helpers({
Template.menuItemsTbl.events({
'click .deleteMenuItem' (event) {
event.preventDefault();
Session.set("deleteId", this._id);
Session.set("method", "delete.menuItem");
Session.set("item", this.itemName);
let theseIds = Session.get("menuId") + "_" + this.menuItemId;
console.log("These Ids: " + theseIds);
Session.set("deleteId", theseIds);
Session.set("method", "delete.itemFromMenu");
Session.set("item", this.menuItemName);
Session.set("view", "Menu Items");
},
'click .linkToProducts' (event) {
event.preventDefault();
Session.set("menuItemId", this._id);
Session.set("menuItemId", this.menuItemId);
Session.set("menuItemName", this.menuItemName);
console.log("menu item name = " + this.menuItemName);
},
'click .addProdsToList' (event) {
event.preventDefault();
// console.log("Menu Iteme Id sent is: " + this._id);
Session.set("menuItemId", this._id);
Session.set("menuItemId", this.menuItemId);
}
});
});