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
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue