diff --git a/client/Dashboard/dashboard.html b/client/Dashboard/dashboard.html index 732ee5d..017ac4f 100644 --- a/client/Dashboard/dashboard.html +++ b/client/Dashboard/dashboard.html @@ -41,9 +41,13 @@

{{todayDate}}

{{#each todayMenuItem}} -
-

local_dining {{itemName}}

-
+ {{#each menuItems}} + {{#if $eq todayDate serveDate}} +
+

local_dining {{menuItemName}}

+
+ {{/if}} + {{/each}} {{else}}

local_diningNo Menu Today

@@ -71,4 +75,4 @@
{{/if}}
- \ No newline at end of file + diff --git a/client/Dashboard/dashboard.js b/client/Dashboard/dashboard.js index 80add4b..2ea3cb1 100644 --- a/client/Dashboard/dashboard.js +++ b/client/Dashboard/dashboard.js @@ -14,7 +14,7 @@ Template.dashboard.onCreated(function() { this.subscribe("storeInfo"); this.subscribe("myProducts"); this.subscribe("myLocations"); - this.subscribe("myMenus"); + // this.subscribe("myMenus"); this.subscribe("todayMenuItems"); this.subscribe("myTasks"); }); @@ -47,7 +47,9 @@ Template.dashboard.helpers({ return TaskItems.find({ isComplete: false, taskDate: today }); }, todayMenuItem: function() { - return MenuItems.find({}); + let myMenus = Menus.find({}).fetch(); + console.dir(myMenus); + return myMenus; }, todayDate: function() { let now = new Date(); @@ -110,4 +112,4 @@ Template.dashboard.events({ break; } } -}); \ No newline at end of file +}); diff --git a/client/MenuItems/addProdToListModal.html b/client/MenuItems/addProdToListModal.html index b397b96..191eaeb 100644 --- a/client/MenuItems/addProdToListModal.html +++ b/client/MenuItems/addProdToListModal.html @@ -16,16 +16,18 @@

Products to Add

{{#each productToChoose}} -
  • -
    -

    - -

    -
    -
  • + {{#each products}} +
  • +
    +

    + +

    +
    +
  • + {{/each}} {{/each}} @@ -44,4 +46,4 @@ {{> snackbar}} - \ No newline at end of file + diff --git a/client/MenuItems/menuItemsForm.js b/client/MenuItems/menuItemsForm.js index 5e5b6d6..9fdb96e 100644 --- a/client/MenuItems/menuItemsForm.js +++ b/client/MenuItems/menuItemsForm.js @@ -17,6 +17,9 @@ Template.menuItemsForm.onRendered(function() { Session.set("menuItemErr", false); Session.set("menuListItems", {}); + var elemt = document.querySelectorAll('.tooltipped'); + var instancet = M.Tooltip.init(elemt, {}); + this.autorun(() => { var elema = document.querySelectorAll('.autocomplete'); var instancea = M.Autocomplete.init(elema, { @@ -52,18 +55,50 @@ Template.menuItemsForm.events({ let dateSrv = $("#dateServed").val(); let menuId = Session.get("menuId"); - if (menuItem == null || menuItem == "") { - Session.set("menuItemErr", true); + + let menuItemExists = MenuItems.findOne({ itemName: menuItem }); + + if (typeof menuItemExists != 'undefined' && menuItemExists != null && menuItemExists != "") { + // use the existing item on the menu + let menuItemId = menuItemExists._id; + let isLinked = menuItemExists.isLinked; + if (menuItem == null || menuItem == "") { + Session.set("menuItemErr", true); + } else { + Meteor.call('addto.Menu', menuId, menuItem, menuItemId, dateSrv, isLinked, function(error, nresult) { + if (error) { + console.log(" ERROR adding menuitem to menu: " + error); + } else { + // console.log("Added item to menu - no problem."); + $("#menuItemInp").val(""); + $("#dateServed").val(""); + } + }); + } } else { - Meteor.call('add.menuItem', menuItem, dateSrv, menuId, function(err, result) { - if (err) { - console.log(" ERROR adding menu item: " + err); - } else { - console.log(" SUCCESS adding menu item."); - $("#menuItemInp").val(""); - $("#dateServed").val(""); - } - }); + // add the item as new and add to the menu + if (menuItem == null || menuItem == "") { + Session.set("menuItemErr", true); + } else { + Meteor.call('add.menuItem', menuItem, function(err, result) { + if (err) { + console.log(" ERROR adding menu item: " + err); + } else { + // console.log(" SUCCESS adding menu item."); + $("#menuItemInp").val(""); + $("#dateServed").val(""); + + // now add this item to the menu + Meteor.call('addto.Menu', menuId, menuItem, result, dateSrv, function(error, nresult) { + if (error) { + console.log(" ERROR adding menuitem to menu: " + error); + } else { + // console.log("Added item to menu - no problem."); + } + }); + } + }); + } } }, 'click .shiftOneDay' (event) { @@ -77,7 +112,7 @@ Template.menuItemsForm.events({ // console.log(momentAddDay); Meteor.call('shiftDate', menuItemId, momentAddDay, function(err,result) { if (err) { - // console.log(" ERROR shifting meal days: " + err); + console.log(" ERROR shifting meal days: " + err); } else { // console.log(" SUCCESS shifting meal date."); } @@ -99,4 +134,4 @@ getMenuItemList = function(menuItemInfo) { let menuItemObjArray = []; menuItemObjArray = menuItemInfo.map(info => ({ id: info._id, text: info.itemName })); Session.set("menuListItems", menuItemObjArray); -} \ No newline at end of file +} diff --git a/client/MenuItems/menuItemsTbl.html b/client/MenuItems/menuItemsTbl.html index ee1da76..10c56f6 100644 --- a/client/MenuItems/menuItemsTbl.html +++ b/client/MenuItems/menuItemsTbl.html @@ -11,27 +11,25 @@ {{#each thisMenuItems}} - - - - {{#if $eq itemMade true}} - {{itemName}} - {{else}} - {{itemName}} - {{/if}} - - - - {{serveDate}} - - - {{#if $eq isLinked true}}+ Shopping List{{/if}} - - - delete - link - - + {{#each menuItems}} + + + + {{menuItemName}} + + + + {{serveDate}} + + + {{#if $eq isLinked true}}+ Shopping List{{/if}} + + + delete + link + + + {{/each}} {{/each}} @@ -41,4 +39,4 @@ {{> deleteConfirmationModal}} {{> modalLinkProducts}} {{> addProdToListModal}} - \ No newline at end of file + diff --git a/client/MenuItems/menuItemsTbl.js b/client/MenuItems/menuItemsTbl.js index fb01e79..40e279c 100644 --- a/client/MenuItems/menuItemsTbl.js +++ b/client/MenuItems/menuItemsTbl.js @@ -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); } -}); \ No newline at end of file +}); diff --git a/client/MenuItems/menuitemsForm.html b/client/MenuItems/menuitemsForm.html index a9f22a6..0650769 100644 --- a/client/MenuItems/menuitemsForm.html +++ b/client/MenuItems/menuitemsForm.html @@ -2,11 +2,8 @@
    {{menuName}}
    - \ No newline at end of file + diff --git a/client/MenuItems/modalLinkProducts.html b/client/MenuItems/modalLinkProducts.html index 89dfcf1..5637bd7 100644 --- a/client/MenuItems/modalLinkProducts.html +++ b/client/MenuItems/modalLinkProducts.html @@ -6,7 +6,7 @@ @@ -26,4 +26,4 @@ {{> snackbar}} - \ No newline at end of file + diff --git a/client/MenuItems/modalLinkProducts.js b/client/MenuItems/modalLinkProducts.js index a367e55..86c3378 100644 --- a/client/MenuItems/modalLinkProducts.js +++ b/client/MenuItems/modalLinkProducts.js @@ -36,22 +36,39 @@ 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) { - Meteor.call("add.menuProdLinks", menuItemId, links, function(err, result) { + // let's split these links into their parts, and make an array of objects + for (i=0; i