get_my/client/Dashboard/dashboard.js
Brian McGonagill 88fa7c1d22 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.
2024-08-14 11:38:13 -05:00

115 lines
3.3 KiB
JavaScript

import { Lists } from "../../imports/api/lists";
import { Products } from "../../imports/api/products";
import { Stores } from "../../imports/api/stores";
import { Menus } from '../../imports/api/menu.js';
import { MenuItems } from '../../imports/api/menuItems.js';
import moment from 'moment';
import { TaskItems } from "../../imports/api/tasks";
Template.dashboard.onCreated(function() {
this.subscribe("userList");
this.subscribe("myLists");
this.subscribe("myCategories");
this.subscribe("storeInfo");
this.subscribe("myProducts");
this.subscribe("myLocations");
// this.subscribe("myMenus");
this.subscribe("todayMenuItems");
this.subscribe("myTasks");
});
Template.dashboard.onRendered(function() {
});
Template.dashboard.helpers({
userCount: function() {
return Meteor.users.find().count();
},
listCount: function() {
return Lists.find().count();
},
storeCount: function() {
return Stores.find().count();
},
productCount: function() {
return Products.find().count();
},
catCount: function() {
return Categories.find().count();
},
locCount: function() {
return Locations.find().count();
},
mytaskitems: function() {
let today = moment(new Date()).format("MMM DD, YYYY");
return TaskItems.find({ isComplete: false, taskDate: today });
},
todayMenuItem: function() {
let myMenus = Menus.find({}).fetch();
console.dir(myMenus);
return myMenus;
},
todayDate: function() {
let now = new Date();
let todayDate = moment(now).format("MMM DD, YYYY");
return todayDate;
},
});
Template.dashboard.events({
"click .cardLink" (event) {
event.preventDefault();
let link = event.currentTarget.id;
switch(link) {
case "userMgmtLink":
FlowRouter.go('/userMgmt');
break;
case "listMgmtLink":
FlowRouter.go('/manageLists');
break;
case "storeMgmtLink":
FlowRouter.go('/manageStore');
break;
case "prodMgmtLink":
FlowRouter.go('/manageProduct');
break;
case "myMenuLink":
FlowRouter.go('/mymenus');
break;
case "taskMgmtLink":
FlowRouter.go('/taskHome');
break;
default:
break;
}
},
'click .card' (event) {
event.preventDefault();
let cardId = event.currentTarget.id;
switch(cardId) {
case "userInfoCard":
FlowRouter.go('/userMgmt');
break;
case "listInfoCard":
FlowRouter.go("/mylists");
break;
case "storeInfoCard":
FlowRouter.go('/manageStore');
break;
case "prodInfoCard":
FlowRouter.go("/manageProduct");
break;
case "menuInfoCard":
FlowRouter.go('/mymenus');
break;
case "taskInfoCard":
FlowRouter.go('/myTasks');
break;
default:
break;
}
}
});