mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +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({
|
Template.listItemsTbl.events({
|
||||||
'click li' (event) {
|
'click li' (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
let itemInfo = ListItems.findOne({ _id: this._id });
|
const setOrd = async() => {
|
||||||
|
let itemInfo = await ListItems.findOneAsync({ _id: this._id });
|
||||||
if (itemInfo.itemOrdered == true) {
|
if (itemInfo.itemOrdered == true) {
|
||||||
Meteor.call('setNotOrdered.listItem', this._id, function(err, result) {
|
let result = await Meteor.callAsync('setNotOrdered.listItem', this._id);
|
||||||
if (err) {
|
if (!result) {
|
||||||
// console.log(" ERROR setting this item as NOT ordered: " + err);
|
// console.log(" ERROR seeting item as not ordered.");
|
||||||
} else {
|
} else {
|
||||||
// console.log(" SUCCESS setting this item as NOT ordered.");
|
// console.log(" SUCCESS setting item as ordered.");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
Meteor.call('setOrdered.listItem', this._id, function(err, result) {
|
let result = Meteor.callAsync('setOrdered.listItem', this._id);
|
||||||
if (err) {
|
if (!result) {
|
||||||
// console.log(" ERROR marking item ordered: " + err);
|
// console.log(" ERROR marking item ordered: " + err);
|
||||||
} else {
|
} else {
|
||||||
// console.log(" SUCCESS marking this item ordered.");
|
// console.log(" SUCCESS marking this item ordered.");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
setOrd();
|
||||||
},
|
},
|
||||||
'click .markListItemReceived' (event) {
|
'click .markListItemReceived' (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,9 @@
|
||||||
<a class="left btn waves-effect waves-light orange white-text modal-close">Cancel</a>
|
<a class="left btn waves-effect waves-light orange white-text modal-close">Cancel</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s6 m6 l6">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{> snackbar}}
|
{{> snackbar}}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ Template.addProdToListModal.events({
|
||||||
const addItemsFromMenu = async() => {
|
const addItemsFromMenu = async() => {
|
||||||
let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId);
|
let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// console.log(" ERROR adding menu components to list: " + err);
|
console.log(" ERROR adding menu components to list: ");
|
||||||
} else {
|
} else {
|
||||||
showSnackbar("Items Added to List!", "green");
|
showSnackbar("Items Added to List!", "green");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ Template.modalLinkProducts.events({
|
||||||
const linkInMenu = async() => {
|
const linkInMenu = async() => {
|
||||||
let result = await Meteor.callAsync('link.inMenu', menuItemId, true);
|
let result = await Meteor.callAsync('link.inMenu', menuItemId, true);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// console.log(" ERROR adding link to menu sub-item: " + error);
|
console.log(" ERROR adding link to menu sub-item: " + error);
|
||||||
} else {
|
} else {
|
||||||
showSnackbar("Products added to Menu Item successfully!", "green");
|
showSnackbar("Products added to Menu Item successfully!", "green");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,12 @@ Template.mainMenuTbl.events({
|
||||||
} else {
|
} else {
|
||||||
// console.log("menuId is: " + menuId);
|
// console.log("menuId is: " + menuId);
|
||||||
const addUserLast = async() => {
|
const addUserLast = async() => {
|
||||||
|
Session.set("menuId", menuId);
|
||||||
let result = await Meteor.callAsync('add.userLast', "Menu", menuId);
|
let result = await Meteor.callAsync('add.userLast', "Menu", menuId);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
// console.log(" ERROR writing last menu viewed by user to db.");
|
// console.log(" ERROR writing last menu viewed by user to db.");
|
||||||
} else {
|
} else {
|
||||||
Session.set("menuId", menuId);
|
|
||||||
Meteor.setTimeout(function() {
|
|
||||||
FlowRouter.go('/menuitems');
|
FlowRouter.go('/menuitems');
|
||||||
}, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addUserLast();
|
addUserLast();
|
||||||
|
|
|
||||||
|
|
@ -72,17 +72,20 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
|
|
||||||
console.dir(itemIds);
|
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'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);
|
// console.log("Number On List: " + onList);
|
||||||
if (onList == 0) {
|
if (onList == 0) {
|
||||||
// now pull the product
|
// now pull the product
|
||||||
let prodInfo = await Products.findOneAsync({ _id: itemIds[i] });
|
let prodInfo = await Products.findOneAsync({ _id: itemIds[i] });
|
||||||
if (!prodInfo) {
|
if (!prodInfo) {
|
||||||
// console.log("Unable to load product info.");
|
console.log("Unable to load product info.");
|
||||||
} else {
|
} else {
|
||||||
|
console.log("Run " + i);
|
||||||
ListItems.insertAsync({
|
ListItems.insertAsync({
|
||||||
itemName: prodInfo.prodName,
|
itemName: prodInfo.prodName,
|
||||||
listId: listId,
|
listId: listId,
|
||||||
|
|
@ -96,7 +99,11 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// product exists on list, move on to next
|
// 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.');
|
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) {
|
if (linkExists) {
|
||||||
// console.log("sending to update method instead.");
|
// 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) {
|
if (err) {
|
||||||
// console.log(" ERROR moving to the update method: " + err);
|
// console.log(" ERROR moving to the update method: " + err);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue