Updates to make Menu and lists work together again.

This commit is contained in:
Brian McGonagill 2025-07-30 07:11:50 -05:00
parent b5d490c052
commit 9223f21e06
7 changed files with 32 additions and 27 deletions

View file

@ -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;
}
}
},

View file

@ -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 {