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
|
|
@ -25,38 +25,48 @@ Meteor.methods({
|
|||
let iname = itemName.charAt(0).toUpperCase() + itemName.slice(1);
|
||||
|
||||
// look up the item from the Products collection
|
||||
let prodInfo = Products.findOne({ prodName: iname });
|
||||
if (!prodInfo) {
|
||||
Meteor.call("add.product", itemName, [""], function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding item to products: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding item to Products.");
|
||||
const prodIsIn = async() => {
|
||||
let prodInfo = await Products.findOneAsync({ prodName: iname });
|
||||
try {
|
||||
if (!prodInfo) {
|
||||
// add product info first
|
||||
const addProd = async() => {
|
||||
let added = await Meteor.callAsync("add.product", itemName, [""]);
|
||||
if (!added) {
|
||||
console.log(" ERROR adding item to products: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding item to Products.");
|
||||
|
||||
return ListItems.insert({
|
||||
return ListItems.insertAsync({
|
||||
itemName: iname,
|
||||
listId: listId,
|
||||
prodId: result,
|
||||
addedBy: this.userId,
|
||||
itemStore: "",
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ListItems.insertAsync({
|
||||
itemName: iname,
|
||||
listId: listId,
|
||||
prodId: result,
|
||||
prodId: prodInfo._id,
|
||||
addedBy: this.userId,
|
||||
itemStore: "",
|
||||
itemStore: prodInfo.prodStore,
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return ListItems.insert({
|
||||
itemName: iname,
|
||||
listId: listId,
|
||||
prodId: prodInfo._id,
|
||||
addedBy: this.userId,
|
||||
itemStore: prodInfo.prodStore,
|
||||
itemOrdered: false,
|
||||
itemReceived: false,
|
||||
dateAddedToList: new Date(),
|
||||
});
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding new product and item: " + error);
|
||||
}
|
||||
}
|
||||
let prodIn = prodIsIn();
|
||||
return prodIn;
|
||||
},
|
||||
'add.itemsFromMenuItem' (itemIds, listId) {
|
||||
check(itemIds, [String]);
|
||||
|
|
@ -75,7 +85,7 @@ Meteor.methods({
|
|||
if (onList == 0) {
|
||||
// now pull the product
|
||||
let prodInfo = Products.findOne({ _id: itemIds[i] });
|
||||
ListItems.insert({
|
||||
ListItems.insertAsync({
|
||||
itemName: prodInfo.prodName,
|
||||
listId: listId,
|
||||
prodId: prodInfo._id,
|
||||
|
|
@ -98,7 +108,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to set items as ordered. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.update({ _id: itemId }, {
|
||||
return ListItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemOrdered: true,
|
||||
dateOrdered: new Date(),
|
||||
|
|
@ -116,7 +126,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to set items as not ordered. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.update({ _id: itemId }, {
|
||||
return ListItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemOrdered: false,
|
||||
dateUnOrdered: new Date(),
|
||||
|
|
@ -130,7 +140,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to set items as received. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.update({ _id: itemId }, {
|
||||
return ListItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemReceived: true,
|
||||
dateReceived: new Date(),
|
||||
|
|
@ -145,7 +155,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to set items as not received. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.update({ _id: itemId }, {
|
||||
return ListItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemReceived: false,
|
||||
dateNotReceived: new Date(),
|
||||
|
|
@ -164,7 +174,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.update({ _id: itemId }, {
|
||||
return ListItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemName: itemName,
|
||||
}
|
||||
|
|
@ -177,6 +187,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete list items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return ListItems.remove({ _id: itemId });
|
||||
return ListItems.removeAsync({ _id: itemId });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add lists. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.insert({
|
||||
return Lists.insertAsync({
|
||||
listName: listName,
|
||||
listShared: isShared,
|
||||
listOwner: this.userId,
|
||||
|
|
@ -36,7 +36,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit lists. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.update({ _id: listId }, {
|
||||
return Lists.updateAsync({ _id: listId }, {
|
||||
$set: {
|
||||
listName: listName,
|
||||
listShared: isShared,
|
||||
|
|
@ -50,7 +50,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete lists. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.remove({ _id: listId });
|
||||
return Lists.removeAsync({ _id: listId });
|
||||
},
|
||||
'mark.complete' (listId) {
|
||||
check(listId, String);
|
||||
|
|
@ -59,7 +59,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark lists complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.update({ _id: listId }, {
|
||||
return Lists.updateAsync({ _id: listId }, {
|
||||
$set: {
|
||||
listComplete: true,
|
||||
completedOn: new Date()
|
||||
|
|
@ -73,7 +73,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to restore completed lists. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.update({ _id: listId }, {
|
||||
return Lists.updateAsync({ _id: listId }, {
|
||||
$set: {
|
||||
listComplete: false,
|
||||
completedOn: new Date()
|
||||
|
|
@ -85,6 +85,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to clean up old lists. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Lists.remove({ listComplete: true });
|
||||
return Lists.removeAsync({ listComplete: true });
|
||||
},
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@ Meteor.methods({
|
|||
'set.ScriptRun' (scriptName) {
|
||||
check(scriptName, String);
|
||||
|
||||
MScripts.insert({
|
||||
MScripts.insertAsync({
|
||||
scriptName: scriptName,
|
||||
hasRun: true,
|
||||
runOn: new Date(),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add menus. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.insert({
|
||||
return Menus.insertAsync({
|
||||
menuName: menuName,
|
||||
menuOwner: this.userId,
|
||||
menuComplete: false,
|
||||
|
|
@ -36,7 +36,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit menus. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.update({ _id: menuId }, {
|
||||
return Menus.updateAsync({ _id: menuId }, {
|
||||
$set: {
|
||||
menuName: menuName,
|
||||
}
|
||||
|
|
@ -49,7 +49,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete menus. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.remove({ _id: menuId });
|
||||
return Menus.removeAsync({ _id: menuId });
|
||||
},
|
||||
'markMenu.complete' (menuId) {
|
||||
check(menuId, String);
|
||||
|
|
@ -58,7 +58,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark menus complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.update({ _id: menuId }, {
|
||||
return Menus.updateAsync({ _id: menuId }, {
|
||||
$set: {
|
||||
menuComplete: true,
|
||||
}
|
||||
|
|
@ -71,7 +71,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark menus not complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.update({ _id: menuId }, {
|
||||
return Menus.updateAsync({ _id: menuId }, {
|
||||
$set: {
|
||||
menuComplete: false,
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ Meteor.methods({
|
|||
for (i=0; i < menuList.length; i++) {
|
||||
let removeMenu = true;
|
||||
let items = MenuItems.find({ menuId: menuList[i]._id }).fetch();
|
||||
for (j=0; j < items.length; j++) {
|
||||
for (let j=0; j < items.length; j++) {
|
||||
let srvDate = moment(items[j].serveDateActual);
|
||||
let today = moment();
|
||||
let expired = moment(today).isAfter(srvDate);
|
||||
|
|
@ -107,14 +107,14 @@ Meteor.methods({
|
|||
|
||||
// next let's add the ids of any menus that are marked complete
|
||||
let markedComplete = Menus.find({ menuComplete: true }).fetch();
|
||||
for (k = 0; k < markedComplete.length; k++) {
|
||||
for (let k = 0; k < markedComplete.length; k++) {
|
||||
let menuId = markedComplete[k]._id;
|
||||
removeMenuIds.push(menuId);
|
||||
}
|
||||
|
||||
// finally we'll cycle through the ids and remove the items we collected up.
|
||||
for (l = 0; l < removeMenuIds.length; l++) {
|
||||
Menus.remove({ _id: removeMenuIds[l] });
|
||||
for (let l = 0; l < removeMenuIds.length; l++) {
|
||||
Menus.removeAsync({ _id: removeMenuIds[l] });
|
||||
}
|
||||
},
|
||||
'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) {
|
||||
|
|
@ -130,7 +130,7 @@ Meteor.methods({
|
|||
|
||||
serveDateActual = new Date(dateSrv);
|
||||
|
||||
return Menus.update({ _id: menuId }, {
|
||||
return Menus.updateAsync({ _id: menuId }, {
|
||||
$addToSet: {
|
||||
menuItems:
|
||||
{
|
||||
|
|
@ -151,7 +151,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to link menu items to products. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Menus.update({ 'menuItems.menuItemId': menuItemId }, {
|
||||
return Menus.updateAsync({ 'menuItems.menuItemId': menuItemId }, {
|
||||
$set: {
|
||||
"menuItems.$.isLinked": isLinked
|
||||
}
|
||||
|
|
@ -167,7 +167,7 @@ Meteor.methods({
|
|||
let ids = itemIds.split('_');
|
||||
console.log("item ids: " + ids[0] + " and " + ids[1]);
|
||||
|
||||
return Menus.update({ _id: ids[0] }, {
|
||||
return Menus.updateAsync({ _id: ids[0] }, {
|
||||
$pull: {
|
||||
menuItems: {
|
||||
menuItemId: ids[1],
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MenuItems.insert({
|
||||
return MenuItems.insertAsync({
|
||||
itemName: itemName,
|
||||
addedBy: this.userId,
|
||||
dateAddedtoMenu: new Date(),
|
||||
|
|
@ -34,7 +34,7 @@ Meteor.methods({
|
|||
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 }, {
|
||||
return MenuItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
isLinked: isLinked,
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit menu items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MenuItems.update({ _id: itemId }, {
|
||||
return MenuItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
itemName: itemName,
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete menu items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MenuItems.remove({ _id: itemId });
|
||||
return MenuItems.removeAsync({ _id: itemId });
|
||||
},
|
||||
'shiftDate' (itemId, momentAddDay) {
|
||||
check(itemId, String);
|
||||
|
|
@ -71,7 +71,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to shift menu item dates. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return MenuItems.update({ _id: itemId }, {
|
||||
return MenuItems.updateAsync({ _id: itemId }, {
|
||||
$set: {
|
||||
serveDate: momentAddDay,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ Meteor.methods({
|
|||
}
|
||||
});
|
||||
} else {
|
||||
return MenuProdLinks.insert({
|
||||
return MenuProdLinks.insertAsync({
|
||||
menuItemId: menuItemId,
|
||||
menuItemName: menuItemName,
|
||||
products: prodNameArray,
|
||||
|
|
@ -52,7 +52,7 @@ 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.');
|
||||
};
|
||||
|
||||
return MenuProdLinks.update({ menuItemId: menuItemId }, {
|
||||
return MenuProdLinks.updateAsync({ menuItemId: menuItemId }, {
|
||||
$set: {
|
||||
products: prodNameArray,
|
||||
dateUpdated: Date(),
|
||||
|
|
|
|||
|
|
@ -24,15 +24,22 @@ Meteor.methods({
|
|||
|
||||
// first does this product already exist?
|
||||
|
||||
let prodExists = Products.findOne({ prodName: pname });
|
||||
|
||||
if (!prodExists) {
|
||||
return Products.insert({
|
||||
prodName: pname,
|
||||
prodOwner: this.userId,
|
||||
prodStore: prodStore,
|
||||
});
|
||||
const productIsIn = async() => {
|
||||
let prodExists = await Products.findOneAsync({ prodName: pname });
|
||||
try {
|
||||
if (!prodExists) {
|
||||
return Products.insertAsync({
|
||||
prodName: pname,
|
||||
prodOwner: this.userId,
|
||||
prodStore: prodStore,
|
||||
});
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding Pdocut: " + error);
|
||||
}
|
||||
}
|
||||
let prodIn = productIsIn();
|
||||
return prodIn;
|
||||
},
|
||||
'edit.product' (prodId, prodName, prodStore) {
|
||||
check(prodId, String);
|
||||
|
|
@ -45,7 +52,7 @@ Meteor.methods({
|
|||
|
||||
let pname = prodName.charAt(0).toUpperCase() + prodName.slice(1);
|
||||
|
||||
return Products.update({ _id: prodId }, {
|
||||
return Products.updateAsync({ _id: prodId }, {
|
||||
$set: {
|
||||
prodName: pname,
|
||||
prodStore: prodStore,
|
||||
|
|
@ -59,6 +66,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Products.remove({ _id: prodId });
|
||||
return Products.removeAsync({ _id: prodId });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add recipe items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return RecipeItems.insert({
|
||||
return RecipeItems.insertAsync({
|
||||
recipeId: recipeId,
|
||||
recipeItemType: recipeItemType,
|
||||
recipeItem: recipeItem,
|
||||
|
|
@ -37,7 +37,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit recipe items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return RecipeItems.update({ _id: recipeItemId }, {
|
||||
return RecipeItems.updateAsync({ _id: recipeItemId }, {
|
||||
$set: {
|
||||
recipeId: recipeId,
|
||||
recipeItemType: recipeItemType,
|
||||
|
|
@ -52,6 +52,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete recipe items. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return RecipeItems.remove({ _id: recipeItemId });
|
||||
return RecipeItems.removeAsync({ _id: recipeItemId });
|
||||
}
|
||||
});
|
||||
|
|
@ -19,7 +19,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Recipes.insert({
|
||||
return Recipes.insertAsync({
|
||||
recipeName: recipeName,
|
||||
addedBy: this.userId,
|
||||
addedOn: new Date(),
|
||||
|
|
@ -33,7 +33,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Recipes.update({ _id: recipeId }, {
|
||||
return Recipes.updateAsync({ _id: recipeId }, {
|
||||
$set: {
|
||||
recipeName: recipeName,
|
||||
updatedOn: new Date(),
|
||||
|
|
@ -48,6 +48,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete recipes. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Recipes.remove({ _id: recipeId });
|
||||
return Recipes.removeAsync({ _id: recipeId });
|
||||
}
|
||||
});
|
||||
|
|
@ -19,7 +19,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to add stores. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Stores.insert({
|
||||
return Stores.insertAsync({
|
||||
storeName: storeName,
|
||||
owner: this.userId,
|
||||
});
|
||||
|
|
@ -32,7 +32,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit stores. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Stores.update({ _id: storeId }, {
|
||||
return Stores.updateAsync({ _id: storeId }, {
|
||||
$set: {
|
||||
storeName: storeName,
|
||||
}
|
||||
|
|
@ -45,6 +45,6 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete stores. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return Stores.remove({ _id: storeId });
|
||||
return Stores.removeAsync({ _id: storeId });
|
||||
},
|
||||
});
|
||||
|
|
@ -20,23 +20,37 @@ Meteor.methods({
|
|||
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
}
|
||||
|
||||
let curr = SysConfig.findOne({});
|
||||
if (typeof curr != 'undefined') {
|
||||
let configId = curr._id;
|
||||
Meteor.call('edit.noSysAdminReg', configId, admReg, genReg, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR updating sys admin reg: " + err);
|
||||
const currConfig = async() => {
|
||||
let curr = await SysConfig.findOneAsync({});
|
||||
if (!curr) {
|
||||
try {
|
||||
return SysConfig.insertAsync({
|
||||
SysAdminReg: admReg,
|
||||
dateAdded: new Date(),
|
||||
allowReg: genReg,
|
||||
});
|
||||
} catch(error) {
|
||||
console.log(" ERROR trying to insert system config:");
|
||||
console.log(error.message);
|
||||
console.log(error.stack);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
let configId = curr._id;
|
||||
const addNoSys = await Meteor.callAsync('edit.noSysAdminReg', configId, admReg, genReg);
|
||||
if (!addNoSys) {
|
||||
console.log(" Couldn't edit the system config.");
|
||||
} else {
|
||||
console.log("Success updating sys admin reg.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return SysConfig.insert({
|
||||
SysAdminReg: admReg,
|
||||
dateAdded: new Date(),
|
||||
allowReg: genReg,
|
||||
});
|
||||
} catch(error) {
|
||||
console.log(" ERROR trying to pull current system config:");
|
||||
console.log(error.message);
|
||||
console.log(error.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
currConfig();
|
||||
},
|
||||
'edit.noSysAdminReg' (configId, canReg, genReg) {
|
||||
check(canReg, Boolean);
|
||||
|
|
@ -47,7 +61,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
}
|
||||
|
||||
return SysConfig.update({ _id: configId }, {
|
||||
return SysConfig.updateAsync({ _id: configId }, {
|
||||
$set: {
|
||||
SysAdminReg: canReg,
|
||||
allowReg: genReg,
|
||||
|
|
@ -66,7 +80,7 @@ Meteor.methods({
|
|||
|
||||
let configId = curr._id;
|
||||
|
||||
return SysConfig.update({ _id: configId }, {
|
||||
return SysConfig.updateAsync({ _id: configId }, {
|
||||
$set: {
|
||||
allowUpdates: allowUpdate,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,16 +27,23 @@ Meteor.methods({
|
|||
let username;
|
||||
|
||||
if (assignedTo == "self") {
|
||||
let userInfo = Meteor.users.findOne({ _id: this.userId });
|
||||
username = userInfo.profile.fullname;
|
||||
assignedToId = this.userId;
|
||||
const uInfo = async() => {
|
||||
let userInfo = await Meteor.users.findOneAsync({ _id: this.userId });
|
||||
if (!userInfo) {
|
||||
console.log("No matching user info found.")
|
||||
} else {
|
||||
username = userInfo.profile.fullname;
|
||||
assignedToId = this.userId;
|
||||
}
|
||||
}
|
||||
uInfo();
|
||||
} else {
|
||||
username = assignedTo;
|
||||
}
|
||||
|
||||
for (i=0; i < taskDateArr.length; i++) {
|
||||
for (j=0; j < taskNameArr.length; j++) {
|
||||
TaskItems.insert({
|
||||
TaskItems.insertAsync({
|
||||
taskName: taskNameArr[j].id,
|
||||
taskDate: taskDateArr[i],
|
||||
actualDate: actDate[i],
|
||||
|
|
@ -62,14 +69,21 @@ Meteor.methods({
|
|||
let username;
|
||||
|
||||
if (assignedTo == "self") {
|
||||
let userInfo = Meteor.users.findOne({ _id: this.userId });
|
||||
username = userInfo.profile.fullname;
|
||||
assignedToId = this.userId;
|
||||
const uInfo = async() => {
|
||||
let userInfo = await Meteor.users.findOneAsync({ _id: this.userId });
|
||||
if (!userInfo) {
|
||||
console.log("No matching user info found.")
|
||||
} else {
|
||||
username = userInfo.profile.fullname;
|
||||
assignedToId = this.userId;
|
||||
}
|
||||
}
|
||||
uInfo();
|
||||
} else {
|
||||
username = assignedTo;
|
||||
}
|
||||
|
||||
return TaskItems.insert({
|
||||
return TaskItems.insertAsync({
|
||||
taskName: taskName,
|
||||
taskDate: taskDate,
|
||||
actualDate: actDate,
|
||||
|
|
@ -91,7 +105,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to edit tasks. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
return TaskItems.updateAsync({ _id: taskId }, {
|
||||
$set: {
|
||||
taskName: taskName,
|
||||
taskDate: taskDate,
|
||||
|
|
@ -108,7 +122,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to delete tasks. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.remove({ _id: taskId });
|
||||
return TaskItems.removeAsync({ _id: taskId });
|
||||
},
|
||||
'markTask.complete' (taskId) {
|
||||
check(taskId, String);
|
||||
|
|
@ -117,7 +131,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark tasks complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
return TaskItems.updateAsync({ _id: taskId }, {
|
||||
$set: {
|
||||
isComplete: true,
|
||||
completedOn: new Date(),
|
||||
|
|
@ -132,7 +146,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark tasks not complete. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return TaskItems.update({ _id: taskId }, {
|
||||
return TaskItems.updateAsync({ _id: taskId }, {
|
||||
$set: {
|
||||
isComplete: false,
|
||||
markedUncomplteOn: new Date(),
|
||||
|
|
@ -174,6 +188,6 @@ Meteor.methods({
|
|||
break;
|
||||
}
|
||||
|
||||
return TaskItems.remove({ actualDate: { $lt: new Date((new Date()) - upToDate )}});
|
||||
return TaskItems.removeAsync({ actualDate: { $lt: new Date((new Date()) - upToDate )}});
|
||||
}
|
||||
});
|
||||
|
|
@ -15,7 +15,7 @@ Meteor.methods({
|
|||
'add.updateInfo' (updateObject) {
|
||||
check(updateObject, Object);
|
||||
|
||||
UpdateInfo.insert({
|
||||
return UpdateInfo.insertAsync({
|
||||
title: updateObject.title,
|
||||
description: updateObject.description,
|
||||
dateRelease: updateObject.date,
|
||||
|
|
@ -29,7 +29,7 @@ Meteor.methods({
|
|||
throw new Meteor.Error('You are not allowed to mark updates as read. Make sure you are logged in with valid user credentials.');
|
||||
}
|
||||
|
||||
return UpdateInfo.update({ _id: updateId }, {
|
||||
return UpdateInfo.updateAsync({ _id: updateId }, {
|
||||
$set: {
|
||||
viewed: true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ UserConfig.allow({
|
|||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
update: function(userId, doc){
|
||||
// if use id exists, allow insert
|
||||
return !!userId;
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
|
|
@ -16,10 +20,10 @@ Meteor.methods({
|
|||
check(pref, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
throw new Meteor.Error('Not able to change theme setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
}
|
||||
|
||||
return UserConfig.insert({
|
||||
return UserConfig.insertAsync({
|
||||
user: this.userId,
|
||||
darkMode: pref,
|
||||
dateAdded: Date()
|
||||
|
|
@ -29,23 +33,14 @@ Meteor.methods({
|
|||
check(pref, String);
|
||||
|
||||
if (!this.userId) {
|
||||
throw new Meteor.Error('Not able to change registration setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
throw new Meteor.Error('Not able to change theme setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
}
|
||||
|
||||
let myConfig = UserConfig.findOne({ user: this.userId });
|
||||
if (typeof myConfig == 'undefined') {
|
||||
Meteor.call('add.darkModePref', pref, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR calling the add functioin for dark mode: " + err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return UserConfig.update({ user: this.userId }, {
|
||||
$set: {
|
||||
darkMode: pref,
|
||||
dateUpdate: Date()
|
||||
}
|
||||
});
|
||||
}
|
||||
return UserConfig.updateAsync({ user: this.userId }, {
|
||||
$set: {
|
||||
darkMode: pref,
|
||||
dateUpdate: Date()
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -16,6 +16,6 @@ Meteor.methods({
|
|||
check(usersId, String);
|
||||
check(password, String);
|
||||
|
||||
return Accounts.setPassword(usersId, password);
|
||||
return Accounts.setPasswordAsync(usersId, password);
|
||||
},
|
||||
});
|
||||
|
|
@ -22,22 +22,34 @@ Meteor.methods({
|
|||
|
||||
// first let's find out if there's an entry for this user and view, and if so
|
||||
// we'll just edit that entry with updated information
|
||||
let userListInfo = UserLast.findOne({ userId: this.userId, view: view });
|
||||
if (typeof userListInfo != 'undefined' && userListInfo != "" && userListInfo != null) {
|
||||
// entry exists, call the edit function instead
|
||||
Meteor.call('edit.userLast', view, viewId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR moving user to edit for last view: " + err);
|
||||
const getUserLast = async() => {
|
||||
let userListInfo = await UserLast.findOneAsync({ userId: this.userId, view: view });
|
||||
if (!userListInfo) {
|
||||
console.log("Adding new user last item.");
|
||||
return UserLast.insertAsync({
|
||||
userId: this.userId,
|
||||
view: view,
|
||||
viewId: viewId,
|
||||
dateAdded: Date(),
|
||||
});
|
||||
} else {
|
||||
console.log("Editing existing user last itme.");
|
||||
// entry exists, call the edit function instead
|
||||
let result = await Meteor.callAsync('edit.userLast', view, viewId);
|
||||
if (!result) {
|
||||
try {
|
||||
console.log("Issue editing existing entry in userLast. Check the logs.");
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding userLast item: " + error);
|
||||
console.log(error.message);
|
||||
console.log(error.stack);
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return UserLast.insert({
|
||||
userId: this.userId,
|
||||
view: view,
|
||||
viewId: viewId,
|
||||
dateAdded: Date(),
|
||||
});
|
||||
}
|
||||
}
|
||||
return getUserLast();
|
||||
},
|
||||
'edit.userLast' (view, viewId) {
|
||||
check(view, String);
|
||||
|
|
@ -47,7 +59,8 @@ Meteor.methods({
|
|||
throw new Meteor.Error('Not able to change user view last setting. Make sure you are logged in with valid system administrator credentials.');
|
||||
}
|
||||
|
||||
return UserLast.update({ view: view, userId: this.userId }, {
|
||||
console.log("Edit in progress.");
|
||||
return UserLast.updateAsync({ view: view, userId: this.userId }, {
|
||||
$set: {
|
||||
viewId: viewId,
|
||||
dateLastUpdate: Date(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue