diff --git a/client/ListItems/listItemsTbl.js b/client/ListItems/listItemsTbl.js index 7960b52..1ff8aae 100644 --- a/client/ListItems/listItemsTbl.js +++ b/client/ListItems/listItemsTbl.js @@ -40,24 +40,25 @@ Template.listItemsTbl.helpers({ Template.listItemsTbl.events({ 'click li' (event) { event.preventDefault(); - let itemInfo = ListItems.findOne({ _id: this._id }); - if (itemInfo.itemOrdered == true) { - Meteor.call('setNotOrdered.listItem', this._id, function(err, result) { - if (err) { - // console.log(" ERROR setting this item as NOT ordered: " + err); + const setOrd = async() => { + let itemInfo = await ListItems.findOneAsync({ _id: this._id }); + if (itemInfo.itemOrdered == true) { + let result = await Meteor.callAsync('setNotOrdered.listItem', this._id); + if (!result) { + // console.log(" ERROR seeting item as not ordered."); } else { - // console.log(" SUCCESS setting this item as NOT ordered."); - } - }); - } else { - Meteor.call('setOrdered.listItem', this._id, function(err, result) { - if (err) { + // console.log(" SUCCESS setting item as ordered."); + } + } else { + let result = Meteor.callAsync('setOrdered.listItem', this._id); + if (!result) { // console.log(" ERROR marking item ordered: " + err); } else { // console.log(" SUCCESS marking this item ordered."); } - }); + } } + setOrd(); }, 'click .markListItemReceived' (event) { event.preventDefault(); diff --git a/client/MenuItems/addProdToListModal.html b/client/MenuItems/addProdToListModal.html index 191eaeb..4ac3f34 100644 --- a/client/MenuItems/addProdToListModal.html +++ b/client/MenuItems/addProdToListModal.html @@ -39,10 +39,9 @@ Cancel
- Save to List + Save to List
- - + {{> snackbar}} diff --git a/client/MenuItems/addProdToListModal.js b/client/MenuItems/addProdToListModal.js index 4dd32ea..914273a 100644 --- a/client/MenuItems/addProdToListModal.js +++ b/client/MenuItems/addProdToListModal.js @@ -56,7 +56,7 @@ Template.addProdToListModal.events({ const addItemsFromMenu = async() => { let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId); if (!result) { - // console.log(" ERROR adding menu components to list: " + err); + console.log(" ERROR adding menu components to list: "); } else { showSnackbar("Items Added to List!", "green"); } diff --git a/client/MenuItems/modalLinkProducts.js b/client/MenuItems/modalLinkProducts.js index 5d6bf33..00326ff 100644 --- a/client/MenuItems/modalLinkProducts.js +++ b/client/MenuItems/modalLinkProducts.js @@ -72,7 +72,7 @@ Template.modalLinkProducts.events({ const linkInMenu = async() => { let result = await Meteor.callAsync('link.inMenu', menuItemId, true); if (!result) { - // console.log(" ERROR adding link to menu sub-item: " + error); + console.log(" ERROR adding link to menu sub-item: " + error); } else { showSnackbar("Products added to Menu Item successfully!", "green"); } diff --git a/client/Menus/mainMenuTbl.js b/client/Menus/mainMenuTbl.js index 55b884c..a64e4c3 100644 --- a/client/Menus/mainMenuTbl.js +++ b/client/Menus/mainMenuTbl.js @@ -31,14 +31,12 @@ Template.mainMenuTbl.events({ } else { // console.log("menuId is: " + menuId); const addUserLast = async() => { + Session.set("menuId", menuId); let result = await Meteor.callAsync('add.userLast', "Menu", menuId); if (!result) { // console.log(" ERROR writing last menu viewed by user to db."); } else { - Session.set("menuId", menuId); - Meteor.setTimeout(function() { - FlowRouter.go('/menuitems'); - }, 100); + FlowRouter.go('/menuitems'); } } addUserLast(); diff --git a/imports/api/listItems.js b/imports/api/listItems.js index b54ef38..ad85f68 100644 --- a/imports/api/listItems.js +++ b/imports/api/listItems.js @@ -72,17 +72,20 @@ Meteor.methods({ } console.dir(itemIds); + let noitems = itemIds.length; + let i; - for (i=0; i < itemIds.length; i++) { + for (i=0; i < noitems; i++) { // let's check and make sure the product isn't already on the list - let onList = await ListItems.find({ listId: listId, prodId: itemIds[i] }).count(); + let onList = await ListItems.find({ listId: listId, prodId: itemIds[i] }).countAsync(); // console.log("Number On List: " + onList); if (onList == 0) { // now pull the product let prodInfo = await Products.findOneAsync({ _id: itemIds[i] }); if (!prodInfo) { - // console.log("Unable to load product info."); + console.log("Unable to load product info."); } else { + console.log("Run " + i); ListItems.insertAsync({ itemName: prodInfo.prodName, listId: listId, @@ -96,7 +99,11 @@ Meteor.methods({ } } else { // product exists on list, move on to next - // console.log("Product Exists on Selected List."); + console.log("Product Exists on Selected List."); + } + if (i == (noitems - 1)) { + console.log("Returning now."); + return true; } } }, diff --git a/imports/api/menuProdLinks.js b/imports/api/menuProdLinks.js index 29304ca..70bded5 100644 --- a/imports/api/menuProdLinks.js +++ b/imports/api/menuProdLinks.js @@ -22,11 +22,11 @@ Meteor.methods({ throw new Meteor.Error('You are not allowed to add menu and product links. Make sure you are logged in with valid user credentials.'); }; - let linkExists = MenuProdLinks.findOne({ menuItemId: menuItemId }); + let linkExists = await MenuProdLinks.findOneAsync({ menuItemId: menuItemId }); if (linkExists) { // console.log("sending to update method instead."); - Meteor.call('update.menuPordLInks', menuItemId, menuItemName, prodNameArray, function(err, result) { + await Meteor.callAsync('update.menuPordLInks', menuItemId, menuItemName, prodNameArray, function(err, result) { if (err) { // console.log(" ERROR moving to the update method: " + err); } else {