mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Add list items from linked menu items
This commit is contained in:
parent
91150f03b2
commit
00a99e0393
11 changed files with 203 additions and 5 deletions
|
|
@ -54,9 +54,39 @@ Meteor.methods({
|
|||
dateAddedToList: new Date(),
|
||||
});
|
||||
}
|
||||
},
|
||||
'add.itemsFromMenuItem' (itemIds, listId) {
|
||||
check(itemIds, [String]);
|
||||
check(listId, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to add items from a menu. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
|
||||
console.dir(itemIds);
|
||||
|
||||
for (i=0; i < itemIds.length; i++) {
|
||||
// let's check and make sure the product isn't already on the list
|
||||
let onList = ListItems.find({ listId: listId, prodId: itemIds[i] }).count();
|
||||
console.log("Number On List: " + onList);
|
||||
if (onList == 0) {
|
||||
// now pull the product
|
||||
let prodInfo = Products.findOne({ _id: itemIds[i] });
|
||||
ListItems.insert({
|
||||
itemName: prodInfo.prodName,
|
||||
listId: listId,
|
||||
prodId: prodInfo._id,
|
||||
addedBy: this.userId,
|
||||
itemStore: prodInfo.prodStore,
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
});
|
||||
} else {
|
||||
// product exists on list, move on to next
|
||||
console.log("Product Exists on Selected List.");
|
||||
}
|
||||
}
|
||||
},
|
||||
'setOrdered.listItem' (itemId) {
|
||||
check(itemId, String);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,21 @@ Meteor.methods({
|
|||
addedBy: this.userId,
|
||||
itemMade: false,
|
||||
dateAddedtoMenu: new Date(),
|
||||
isLinked: false,
|
||||
});
|
||||
},
|
||||
'update.menuItemLinked' (itemId, isLinked) {
|
||||
check(itemId, String);
|
||||
check(isLinked, Boolean);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('You are not allowed to set this menu item as linked to products. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MenuItems.update({ _id: itemId }, {
|
||||
$set: {
|
||||
isLinked: isLinked,
|
||||
}
|
||||
});
|
||||
},
|
||||
'setMade.menuItem' (itemId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue