mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-26 15:58:50 +00:00
Updates to make Menu and lists work together again.
This commit is contained in:
parent
b5d490c052
commit
9223f21e06
7 changed files with 32 additions and 27 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -39,10 +39,9 @@
|
|||
<a class="left btn waves-effect waves-light orange white-text modal-close">Cancel</a>
|
||||
</div>
|
||||
<div class="col s6 m6 l6">
|
||||
<a class="right btn waves-effect waves-light green white-text saveProdsToList" id="saveProdsToList">Save to List</a>
|
||||
<a class="right btn waves-effect waves-light green white-text saveProdsToList modal-close" id="saveProdsToList">Save to List</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{> snackbar}}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue