mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Updating framework to meteor 3 and later
This commit is contained in:
parent
717994508a
commit
cca29bc591
58 changed files with 2332 additions and 1611 deletions
|
|
@ -53,12 +53,14 @@ Template.addProdToListModal.events({
|
|||
event.preventDefault();
|
||||
let selectedItems = Session.get("itemsSelected");
|
||||
let listId = $("#chooseList").val();
|
||||
Meteor.call('add.itemsFromMenuItem', selectedItems, listId, function(err, result) {
|
||||
if (err) {
|
||||
const addItemsFromMenu = async() => {
|
||||
let result = await Meteor.callAsync('add.itemsFromMenuItem', selectedItems, listId);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding menu components to list: " + err);
|
||||
} else {
|
||||
showSnackbar("Items Added to List!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
addItemsFromMenu();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -38,13 +38,27 @@ Template.menuItemsForm.helpers({
|
|||
if (Session.get("menuId")) {
|
||||
menuId = Session.get("menuId");
|
||||
} else {
|
||||
menuId = UserLast.findOne({ view: "Menu" }).viewId;
|
||||
const menuInfor = async() => {
|
||||
let result = await UserLast.findOneAsync({ view: "Menu" }).viewId;
|
||||
if (!result) {
|
||||
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
let menuId = menuInfor();
|
||||
}
|
||||
|
||||
let menuInfo = Menus.findOne({ _id: menuId });
|
||||
if (menuInfo) {
|
||||
return menuInfo.menuName;
|
||||
const menuData = async() => {
|
||||
let menuInfo = await Menus.findOneAsync({ _id: menuId });
|
||||
if (!menuInfo) {
|
||||
return;
|
||||
} else {
|
||||
return menuInfo.menuName;
|
||||
}
|
||||
}
|
||||
let menuInformation = menuData();
|
||||
return menuInformation;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -55,10 +69,54 @@ Template.menuItemsForm.events({
|
|||
let dateSrv = $("#dateServed").val();
|
||||
let menuId = Session.get("menuId");
|
||||
|
||||
const mie = async() => {
|
||||
let menuItemExists = await MenuItems.findOneAsync({ itemName: menuItem });
|
||||
if (!menuItemExists) {
|
||||
// call to add it
|
||||
notExists();
|
||||
} else {
|
||||
// call to add it to the menu only
|
||||
itExists(menuItemExists);
|
||||
}
|
||||
}
|
||||
mie();
|
||||
|
||||
let menuItemExists = MenuItems.findOne({ itemName: menuItem });
|
||||
const notExists = async() => {
|
||||
// add the item as new and add to the menu
|
||||
if (menuItem == null || menuItem == "") {
|
||||
Session.set("menuItemErr", true);
|
||||
} else {
|
||||
const addMenuItem = async() => {
|
||||
let result = await Meteor.callAsync('add.menuItem', menuItem);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding menu item: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding menu item.");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
let addedItem = addMenuItem();
|
||||
|
||||
if (typeof menuItemExists != 'undefined' && menuItemExists != null && menuItemExists != "") {
|
||||
if (!addedItem) {
|
||||
console.log("Item was not added.");
|
||||
} else {
|
||||
// now add this item to the menu
|
||||
const addToMenu = async() => {
|
||||
let result2 = await Meteor.callAsync('addto.Menu', menuId, menuItem, result, dateSrv);
|
||||
if (!result2) {
|
||||
console.log(" ERROR adding menuitem to menu: " + error);
|
||||
} else {
|
||||
$("#menuItemInp").val("");
|
||||
$("#dateServed").val("");
|
||||
// console.log("Added item to menu - no problem.");
|
||||
}
|
||||
}
|
||||
addToMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const itExists = async(menuItemExists) => {
|
||||
// use the existing item on the menu
|
||||
let menuItemId = menuItemExists._id;
|
||||
let isLinked = menuItemExists.isLinked;
|
||||
|
|
@ -75,30 +133,6 @@ Template.menuItemsForm.events({
|
|||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// add the item as new and add to the menu
|
||||
if (menuItem == null || menuItem == "") {
|
||||
Session.set("menuItemErr", true);
|
||||
} else {
|
||||
Meteor.call('add.menuItem', menuItem, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding menu item: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding menu item.");
|
||||
$("#menuItemInp").val("");
|
||||
$("#dateServed").val("");
|
||||
|
||||
// now add this item to the menu
|
||||
Meteor.call('addto.Menu', menuId, menuItem, result, dateSrv, false, function(error, nresult) {
|
||||
if (error) {
|
||||
console.log(" ERROR adding menuitem to menu: " + error);
|
||||
} else {
|
||||
// console.log("Added item to menu - no problem.");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .shiftOneDay' (event) {
|
||||
|
|
@ -110,13 +144,14 @@ Template.menuItemsForm.events({
|
|||
let menuItemId = menuInfo[i]._id;
|
||||
let momentAddDay = moment(menuInfo[i].serveDate).add(1, 'day').format("MMM DD, YYYY");
|
||||
// console.log(momentAddDay);
|
||||
Meteor.call('shiftDate', menuItemId, momentAddDay, function(err,result) {
|
||||
if (err) {
|
||||
const shiftDay = async() => {
|
||||
let result = await Meteor.callAsync('shiftDate', menuItemId, momentAddDay);
|
||||
if (!result) {
|
||||
console.log(" ERROR shifting meal days: " + err);
|
||||
} else {
|
||||
showSnackbar("Items Shifted Out by 1 Calendar Day", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
'keyup #menuItemInp' (event) {
|
||||
|
|
|
|||
|
|
@ -30,11 +30,21 @@ Template.menuItemsTbl.helpers({
|
|||
if (Session.get("menuId")) {
|
||||
menuId = Session.get("menuId");
|
||||
} else {
|
||||
menuId = UserLast.findOne({ view: "Menu" }).viewId;
|
||||
const menu = async() => {
|
||||
let menId = await UserLast.findOneAsync({ view: "Menu" }).viewId;
|
||||
if (!menId) {
|
||||
|
||||
} else {
|
||||
return menId;
|
||||
}
|
||||
}
|
||||
menuId = menu();
|
||||
}
|
||||
let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }});
|
||||
if (menuInfo) {
|
||||
return menuInfo
|
||||
if (menuId) {
|
||||
let menuInfo = Menus.find({ _id: menuId }, { sort: { serveDateActual: 1 }});
|
||||
if (menuInfo) {
|
||||
return menuInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ Template.modalLinkProducts.events({
|
|||
let links = M.FormSelect.getInstance(linkSelect).getSelectedValues();
|
||||
if (typeof links != undefined && links != [] && links != null) {
|
||||
// let's split these links into their parts, and make an array of objects
|
||||
for (i=0; i<links.length; i++) {
|
||||
for (let i=0; i<links.length; i++) {
|
||||
let linkArray = links[i].split('|');
|
||||
let key = linkArray[0];
|
||||
let value = linkArray[1];
|
||||
|
|
@ -50,25 +50,33 @@ Template.modalLinkProducts.events({
|
|||
linkObjArray.push(linkObj);
|
||||
}
|
||||
|
||||
Meteor.call("add.menuProdLinks", menuItemId, menuItemName, linkObjArray, function(err, result) {
|
||||
if (err) {
|
||||
const addMenuProdLinks = async() => {
|
||||
let result = await Meteor.callAsync("add.menuProdLinks", menuItemId, menuItemName, linkObjArray);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding product links to this menu item: " + err);
|
||||
} else {
|
||||
Meteor.call('update.menuItemLinked', menuItemId, true, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding link to menu item: " + err);
|
||||
} else {
|
||||
Meteor.call('link.inMenu', menuItemId, true, function(error, nresult) {
|
||||
if (error) {
|
||||
console.log(" ERROR adding link to menu sub-item: " + error);
|
||||
} else {
|
||||
showSnackbar("Products added to Menu Item successfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
updMenuItemLinks();
|
||||
}
|
||||
});
|
||||
}
|
||||
addMenuProdLinks();
|
||||
|
||||
const updMenuItemLinks = async() => {
|
||||
let result = await Meteor.callAsync('update.menuItemLinked', menuItemId, true);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding link to menu item: " + err);
|
||||
} else {
|
||||
linkInMenu();
|
||||
}
|
||||
}
|
||||
|
||||
const linkInMenu = async() => {
|
||||
let result = await Meteor.callAsync('link.inMenu', menuItemId, true);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding link to menu sub-item: " + error);
|
||||
} else {
|
||||
showSnackbar("Products added to Menu Item successfully!", "green");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue