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
|
|
@ -1,4 +1,5 @@
|
|||
import { SysConfig } from '../../../imports/api/systemConfig.js';
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
|
||||
Template.login.onCreated(function() {
|
||||
this.subscribe("SystemConfig");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { SysConfig } from "../../../imports/api/systemConfig.js";
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
|
||||
Template.reg.onCreated(function() {
|
||||
this.subscribe("SystemConfig");
|
||||
|
|
@ -29,12 +30,15 @@ Template.reg.helpers({
|
|||
return Session.get("missingReq");
|
||||
},
|
||||
allowReg: function() {
|
||||
let conf = SysConfig.findOne();
|
||||
if (typeof conf != 'undefined') {
|
||||
return conf.allowReg;
|
||||
} else {
|
||||
return true
|
||||
const sysConf = async() => {
|
||||
let conf = await SysConfig.findOneAsync();
|
||||
if (!conf) {
|
||||
return true;
|
||||
} else {
|
||||
return conf.allowReg;
|
||||
}
|
||||
}
|
||||
sysConf();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -84,14 +88,16 @@ Template.reg.events({
|
|||
|
||||
let userId = Meteor.userId();
|
||||
console.log("User ID: " + userId);
|
||||
Meteor.call("addToRole", "user", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: " + err);
|
||||
const addRole = async() => {
|
||||
let result = await Meteor.callAsync("addToRole", "user");
|
||||
if (!result) {
|
||||
console.log(" ERROR: ROLES - Error adding user to role: ");
|
||||
} else {
|
||||
// console.log("User should be added to role - teacher.");
|
||||
FlowRouter.go('/dashboard');
|
||||
}
|
||||
});
|
||||
}
|
||||
addRole();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<label for="newPassConf">Enter New Password</label>
|
||||
{{#if $eq passMatch false}}<p class="red-text">Passwords do not match!</p>{{/if}}
|
||||
</div>
|
||||
<div class="col s12 m6 l6 input-field outlined">
|
||||
<div class="col s12 m6 l6 input-field">
|
||||
<select name="userRole" id="userRole" class="userRole {{#if $eq roleEmpty true}}red lighten-2 white-text{{/if}}">
|
||||
<option value="{{userRole}}" selected>{{userRole}}</option>
|
||||
<option value="admin">Admin</option>
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ Template.userInfoModal.onRendered(function() {
|
|||
var elemse = document.querySelectorAll('select');
|
||||
var instancese = M.FormSelect.init(elemse, {});
|
||||
|
||||
Meteor.setTimeout(() => {
|
||||
instances = M.Modal.init(elems, {});
|
||||
instancese = M.FormSelect.init(elemse, {});
|
||||
}, 500);
|
||||
// Meteor.setTimeout(() => {
|
||||
// instances = M.Modal.init(elems, {});
|
||||
// instancese = M.FormSelect.init(elemse, {});
|
||||
// }, 500);
|
||||
});
|
||||
|
||||
Template.userInfoModal.helpers({
|
||||
|
|
@ -35,19 +35,34 @@ Template.userInfoModal.helpers({
|
|||
userInfo: function() {
|
||||
let usersId = Session.get("usersId");
|
||||
if (usersId != "" && usersId != null) {
|
||||
let usersInfo = Meteor.users.findOne({ _id: usersId });
|
||||
// console.dir(usersInfo);
|
||||
Session.set("usersInfo", usersInfo);
|
||||
return usersInfo;
|
||||
const uIn = async() => {
|
||||
let usersInfo = await Meteor.users.findOneAsync({ _id: usersId });
|
||||
if (!usersInfo) {
|
||||
console.log("No information found for this user.");
|
||||
return;
|
||||
} else {
|
||||
Session.set("usersInfo", usersInfo);
|
||||
return usersInfo;
|
||||
}
|
||||
// console.dir(usersInfo);
|
||||
}
|
||||
uIn();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
userRole: function() {
|
||||
let userRole = Roles.getRolesForUser( Session.get("usersId"));
|
||||
Session.set("usersRole", userRole);
|
||||
console.log(userRole);
|
||||
return userRole;
|
||||
const getRole = async() => {
|
||||
let userRole = Roles.getRolesForUserAsync( Session.get("usersId"));
|
||||
if (!userRole) {
|
||||
return;
|
||||
} else {
|
||||
Session.set("usersRole", userRole);
|
||||
console.log(userRole);
|
||||
return userRole;
|
||||
}
|
||||
}
|
||||
getRole();
|
||||
},
|
||||
rolesOptions: function() {
|
||||
return Roles.find();
|
||||
|
|
@ -121,36 +136,33 @@ Template.userInfoModal.events({
|
|||
}
|
||||
});
|
||||
|
||||
changePassword = function(userId, passwd) {
|
||||
changePassword = async function(userId, passwd) {
|
||||
console.log("would change password.");
|
||||
Meteor.call('edit.userPass', userId, passwd, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR changing user passwrod:" + err);
|
||||
} else {
|
||||
showSnackbar("Successfully Saved Changes!", "green");
|
||||
console.log(" Password changed successfully!");
|
||||
}
|
||||
});
|
||||
let result = await Meteor.callAsync('edit.userPass', userId, passwd);
|
||||
if (!result) {
|
||||
console.log(" ERROR changing user passwrod:");
|
||||
} else {
|
||||
showSnackbar("Successfully Saved Changes!", "green");
|
||||
console.log(" Password changed successfully!");
|
||||
}
|
||||
}
|
||||
|
||||
changeUserEmail = function(usersId, usersEmail) {
|
||||
changeUserEmail = async function(usersId, usersEmail) {
|
||||
console.log("Would change user email");
|
||||
Meteor.call('update.userEmail', usersId, usersEmail, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR updating user email: " + err);
|
||||
} else {
|
||||
showSnackbar("Email updated successfully!", "green");
|
||||
}
|
||||
});
|
||||
let result = await Meteor.callAsync('update.userEmail', usersId, usersEmail);
|
||||
if (!result) {
|
||||
console.log(" ERROR updating user email: " + err);
|
||||
} else {
|
||||
showSnackbar("Email updated successfully!", "green");
|
||||
}
|
||||
}
|
||||
|
||||
changeUserRole = function(userId, role) {
|
||||
changeUserRole = async function(userId, role) {
|
||||
console.log("Would change user Role.");
|
||||
Meteor.call('edit.userRole', userId, role, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR updating user role: " + err);
|
||||
} else {
|
||||
showSnackbar("Role Successfully Updated!", "green");
|
||||
}
|
||||
});
|
||||
let result = await Meteor.callAsync('edit.userRole', userId, role);
|
||||
if (!result) {
|
||||
console.log(" ERROR updating user role: " + err);
|
||||
} else {
|
||||
showSnackbar("Role Successfully Updated!", "green");
|
||||
}
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ Template.userMgmt.helpers({
|
|||
return this.emails[0].address;
|
||||
},
|
||||
userRole: function() {
|
||||
return Roles.getRolesForUser( this._id );
|
||||
return Roles.getRolesForUserAsync( this._id );
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -40,27 +40,25 @@ Template.cleanUpModalConfirm.events({
|
|||
}
|
||||
});
|
||||
|
||||
cleanUp = function(methodName, whatItems) {
|
||||
Meteor.call(methodName, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR cleaning " + whatItems + ": " + err);
|
||||
} else {
|
||||
showSnackbar(whatItems + " have been cleaned up!", "green");
|
||||
let confirmModal = document.getElementById('cleanUpConfirm');
|
||||
M.Modal.getInstance(confirmModal).close();
|
||||
}
|
||||
});
|
||||
cleanUp = async function(methodName, whatItems) {
|
||||
let result = Meteor.callAsync(methodName);
|
||||
if (!result) {
|
||||
console.log(" ERROR cleaning " + whatItems + ": " + err);
|
||||
} else {
|
||||
showSnackbar(whatItems + " have been cleaned up!", "green");
|
||||
let confirmModal = document.getElementById('cleanUpConfirm');
|
||||
M.Modal.getInstance(confirmModal).close();
|
||||
}
|
||||
}
|
||||
|
||||
cleanTasks = function(methodName, whatItems) {
|
||||
cleanTasks = async function(methodName, whatItems) {
|
||||
let timeFrame = Session.get("overdueVal");
|
||||
Meteor.call(methodName, timeFrame, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR cleaning " + whatItems + ": " + err);
|
||||
} else {
|
||||
showSnackbar(whatItems + " have been cleaned up!", "green");
|
||||
let confirmModal = document.getElementById('cleanUpConfirm');
|
||||
M.Modal.getInstance(confirmModal).close();
|
||||
}
|
||||
});
|
||||
let result = await Meteor.call(methodName, timeFrame);
|
||||
if (!result) {
|
||||
console.log(" ERROR cleaning " + whatItems + ": " + err);
|
||||
} else {
|
||||
showSnackbar(whatItems + " have been cleaned up!", "green");
|
||||
let confirmModal = document.getElementById('cleanUpConfirm');
|
||||
M.Modal.getInstance(confirmModal).close();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,15 +29,7 @@ Template.listMgmtForm.events({
|
|||
Session.set("listNameMiss", true);
|
||||
return;
|
||||
} else {
|
||||
Meteor.call('add.list', listName, shared, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR adding list name: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
}
|
||||
});
|
||||
addList(listName, shared);
|
||||
}
|
||||
},
|
||||
'click .renameListMgmt' (event) {
|
||||
|
|
@ -50,16 +42,7 @@ Template.listMgmtForm.events({
|
|||
Session.set("listNameMiss", true);
|
||||
return;
|
||||
} else {
|
||||
Meteor.call('edit.list', listId, listName, shared, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR editing list name: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS editing list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
Session.set("listNameEditMode", false);
|
||||
}
|
||||
});
|
||||
editList(listId, listName, shared);
|
||||
}
|
||||
},
|
||||
'submit .listAdd' (event) {
|
||||
|
|
@ -74,30 +57,36 @@ Template.listMgmtForm.events({
|
|||
return;
|
||||
} else {
|
||||
if (editMode == false) {
|
||||
Meteor.call('add.list', listName, shared, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR adding list name: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS adding list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
}
|
||||
});
|
||||
addList(listName, shared);
|
||||
} else {
|
||||
Meteor.call('edit.list', listId, listName, shared, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR editing list name: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS editing list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
Session.set("listNameEditMode", false);
|
||||
}
|
||||
});
|
||||
editList(listId, listName, shared);
|
||||
}
|
||||
}
|
||||
},
|
||||
'change #isCompleted' (event) {
|
||||
Session.set("showCompletedLists", true);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const addList = async(listName, shared) => {
|
||||
let result = await Meteor.callAsync('add.list', listName, shared);
|
||||
if (!result) {
|
||||
// console.log(" ERROR adding list name: ");
|
||||
} else {
|
||||
// console.log(" SUCCESS adding list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
}
|
||||
}
|
||||
|
||||
const editList = async(listId, listName, shared) => {
|
||||
let result = await Meteor.callAsync('edit.list', listId, listName, shared);
|
||||
if (!result) {
|
||||
// console.log(" ERROR editing list name: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESS editing list name.");
|
||||
$("#listNameInp").val("");
|
||||
$("#isShared").prop("checked", false);
|
||||
Session.set("listNameEditMode", false);
|
||||
}
|
||||
}
|
||||
|
|
@ -34,9 +34,14 @@ Template.listMgmtTbl.events({
|
|||
},
|
||||
'click .editListName' (event) {
|
||||
event.preventDefault();
|
||||
let listInfo = Lists.findOne({ _id: this._id });
|
||||
let listName = listInfo.listName;
|
||||
let listShared = listInfo.listShared;
|
||||
const lInfo = async() => {
|
||||
let listInfo = await Lists.findOneAsync({ _id: this._id });
|
||||
return listInfo;
|
||||
}
|
||||
let listData = lInfo();
|
||||
|
||||
let listName = listData.listName;
|
||||
let listShared = listData.listShared;
|
||||
$("#listNameInp").val(listName);
|
||||
if (listShared == true) {
|
||||
$("#isShared").prop("checked", true);
|
||||
|
|
@ -49,23 +54,27 @@ Template.listMgmtTbl.events({
|
|||
'click .markListComplete' (event) {
|
||||
event.preventDefault();
|
||||
let listId = this._id;
|
||||
Meteor.call('mark.complete', listId, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR marking complete: " + err);
|
||||
const markComp = async() => {
|
||||
let result = await Meteor.callAsync('mark.complete', listId);
|
||||
if (!result) {
|
||||
console.log(" ERROR marking complete.");
|
||||
} else {
|
||||
// console.log(" SUCCESS marking complete.");
|
||||
}
|
||||
});
|
||||
}
|
||||
markComp();
|
||||
},
|
||||
'click .markListNotComplete' (event) {
|
||||
event.preventDefault();
|
||||
let listId = this._id;
|
||||
Meteor.call('mark.incomplete', listId, function(err, result) {
|
||||
if (err) {
|
||||
|
||||
const markInc = async() => {
|
||||
let result = await Meteor.callAsync('mark.incomplete', listId);
|
||||
if (!result) {
|
||||
console.log("Issue marking list incomplete.");
|
||||
} else {
|
||||
|
||||
// console.log("List marked incomplete.");
|
||||
}
|
||||
});
|
||||
}
|
||||
markInc();
|
||||
}
|
||||
});
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
|
||||
Template.mgmtPage.onCreated(function() {
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -35,36 +35,19 @@ Template.prodMgmtForm.events({
|
|||
'click .saveProdMgmt, click .editProdMgmt' (event) {
|
||||
let name = $("#prodName").val();
|
||||
let store = $("#prodStore").val();
|
||||
|
||||
let prodId = Session.get("prodEditId");
|
||||
let prodEditMode = Session.get("prodEditMode");
|
||||
|
||||
if (store == null) {
|
||||
store = "";
|
||||
}
|
||||
|
||||
if (name == "" || name == null) {
|
||||
Session.set("prodNameRed", true);
|
||||
return;
|
||||
} else {
|
||||
if (prodEditMode == true) {
|
||||
Meteor.call('edit.product', prodId, name, store, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
$("#prodName").val("");
|
||||
showSnackbar("Successfully Edited Product!", "green");
|
||||
}
|
||||
});
|
||||
editProd(prodId, name, store);
|
||||
} else {
|
||||
Meteor.call('add.product', name, store, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
$("#prodName").val("");
|
||||
showSnackbar("Product Added Succssfully!", "green");
|
||||
}
|
||||
});
|
||||
newProd(name, store);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -76,5 +59,33 @@ Template.prodMgmtForm.events({
|
|||
} else {
|
||||
Session.set("noStoreSet", false);
|
||||
}
|
||||
}
|
||||
},
|
||||
'submit .prodInputForm' (event) {
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
const newProd = async(name, store) => {
|
||||
let result = await Meteor.callAsync('add.product', name, store);
|
||||
try {
|
||||
if (!result) {
|
||||
console.log("No result when trying to add a new product.");
|
||||
showSnackbar("Unable to add new product.");
|
||||
} else {
|
||||
$("#prodName").val("");
|
||||
showSnackbar("New Product Added!", "green");
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR - couldn't add product: " + error);
|
||||
}
|
||||
}
|
||||
|
||||
const editProd = async(prodId, name, store) => {
|
||||
let result = await Meteor.callAsync('edit.product', prodId, name, store);
|
||||
if (!result) {
|
||||
console.log(" ERROR: can't add product: " + err);
|
||||
} else {
|
||||
$("#prodName").val("");
|
||||
showSnackbar("Successfully Edited Product!", "green");
|
||||
}
|
||||
}
|
||||
|
|
@ -57,10 +57,17 @@ Template.prodMgmtTbl.events({
|
|||
event.preventDefault();
|
||||
Session.set("prodEditMode", true);
|
||||
Session.set("prodEditId", this._id);
|
||||
let prodInfo = Products.findOne({ _id: this._id });
|
||||
$("#prodName").val(prodInfo.prodName);
|
||||
$("#prodStore").val(prodInfo.prodStore);
|
||||
// $('select').formSelect();
|
||||
const getProds = async() => {
|
||||
let prodInfo = await Products.findOneAsync({ _id: this._id });
|
||||
if (!prodInfo) {
|
||||
console.log("No Product Returned.");
|
||||
} else {
|
||||
$("#prodName").val(prodInfo.prodName);
|
||||
$("#prodStore").val(prodInfo.prodStore);
|
||||
}
|
||||
}
|
||||
getProds();
|
||||
|
||||
},
|
||||
'click #filterProds' (event) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -23,14 +23,7 @@ Template.storeMgmtForm.events({
|
|||
Session.set("borderRed", true);
|
||||
return;
|
||||
} else {
|
||||
Meteor.call("add.store", storeName, function(err, result) {
|
||||
if (err) {
|
||||
console.log("ERROR: Store add failed: " + err);
|
||||
} else {
|
||||
$("#storeName").val("");
|
||||
showSnackbar("Store Added Successfully!", "green");
|
||||
}
|
||||
});
|
||||
addStore(storeName);
|
||||
}
|
||||
},
|
||||
'click .cancelStoreMgmt' (event) {
|
||||
|
|
@ -38,51 +31,51 @@ Template.storeMgmtForm.events({
|
|||
$("#storeName").val("");
|
||||
Session.set("editModeStore", false);
|
||||
},
|
||||
// 'submit #storeForm' (event) {
|
||||
// event.preventDefault();
|
||||
// let editMode = Session.get("editModeStore");
|
||||
// let storeName = $("#storeName").val();
|
||||
// if (storeName == "" || storeName == null) {
|
||||
// Session.set("borderRed", true);
|
||||
// return;
|
||||
// } else {
|
||||
// if (editMode == false) {
|
||||
// Meteor.call("add.store", storeName, function(err, result) {
|
||||
// if (err) {
|
||||
// console.log("ERROR: Store add failed: " + err);
|
||||
// } else {
|
||||
// $("#storeName").val("");
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// let storeId = Session.get("storeIdEdit");
|
||||
// Meteor.call("edit.store", storeId, storeName, function(err, result) {
|
||||
// if (err) {
|
||||
// console.log("ERROR: Store add failed: " + err);
|
||||
// } else {
|
||||
// $("#storeName").val("");
|
||||
// Session.set("editModeStore", false);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
'submit #storeForm' (event) {
|
||||
event.preventDefault();
|
||||
let editMode = Session.get("editModeStore");
|
||||
let storeName = $("#storeName").val();
|
||||
if (storeName == "" || storeName == null) {
|
||||
Session.set("borderRed", true);
|
||||
return;
|
||||
} else {
|
||||
if (editMode == false) {
|
||||
addStore(storeName);
|
||||
} else {
|
||||
let storeId = Session.get("storeIdEdit");
|
||||
editStore(storeId, storeName);
|
||||
}
|
||||
}
|
||||
},
|
||||
'click .editStoreMgmt' (event) {
|
||||
let storeName = $("#storeName").val();
|
||||
let storeId = Session.get("storeIdEdit");
|
||||
if (storeName == "" || storeName == null) {
|
||||
Session.set("borderRed", true);
|
||||
return;
|
||||
} else {
|
||||
Meteor.call("edit.store", storeId, storeName, function(err, result) {
|
||||
if (err) {
|
||||
console.log("ERROR: Store add failed: " + err);
|
||||
} else {
|
||||
$("#storeName").val("");
|
||||
Session.set("editModeStore", false);
|
||||
showSnackbar("Store Updated Successfully!", "green");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
editStore(storeId, storeName);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const addStore = async(storeName) => {
|
||||
let result = await Meteor.callAsync("add.store", storeName);
|
||||
if (!result) {
|
||||
console.log("ERROR: Store add failed.");
|
||||
} else {
|
||||
$("#storeName").val("");
|
||||
showSnackbar("Store Added Successfully!", "green");
|
||||
}
|
||||
}
|
||||
|
||||
const editStore = async(storeId, storeName) => {
|
||||
let result = await Meteor.callAsync("edit.store", storeId, storeName);
|
||||
if (!result) {
|
||||
console.log("ERROR: Store add failed: " + err);
|
||||
} else {
|
||||
$("#storeName").val("");
|
||||
Session.set("editModeStore", false);
|
||||
showSnackbar("Store Updated Successfully!", "green");
|
||||
}
|
||||
}
|
||||
|
|
@ -27,34 +27,34 @@ Template.systemAdmin.onRendered(function() {
|
|||
});
|
||||
|
||||
Template.systemAdmin.helpers({
|
||||
currConfigs: function() {
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
Template.systemAdmin.events({
|
||||
'change #allowGenReg, change #allowAdmReg' (evnnt) {
|
||||
let genReg = $("#allowGenReg").prop('checked');
|
||||
let admReg = $("#allowAdmReg").prop('checked');
|
||||
// console.log("General Reg set to: " + genReg);
|
||||
Meteor.call("add.noSysAdminReg", admReg, genReg, function(err, result) {
|
||||
if (err) {
|
||||
// console.log(" ERROR updating permission to allow general registration: " + err);
|
||||
// showSnackbar("Registration Permission Change Failed.", "red");
|
||||
const addNoSysReg = async() => {
|
||||
let result = await Meteor.callAsync("add.noSysAdminReg", admReg, genReg);
|
||||
if (!result) {
|
||||
showSnackbar("Registration Permission Change Failed.", "red");
|
||||
} else {
|
||||
// console.log(" Successfully updated permission to allow general registration.");
|
||||
showSnackbar("Registration Permission Successfully Changed.", "green")
|
||||
}
|
||||
});
|
||||
}
|
||||
addNoSysReg();
|
||||
},
|
||||
'change #recvUpdateMsgs' (event) {
|
||||
let updSet = $("#recvUpdateMsgs").prop('checked');
|
||||
Meteor.call('allow.updateInfo', updSet, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR changing update setting: " + err);
|
||||
const allowUpdateInfo = async() => {
|
||||
let result = await Meteor.callAsync('allow.updateInfo', updSet);
|
||||
if (!result) {
|
||||
console.log(" ERROR changing update setting.");
|
||||
showSnackbar("Update Setting Change Failed.", "red");
|
||||
} else {
|
||||
showSnackbar("Update Setting Changed Successfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
allowUpdateInfo();
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -92,9 +92,10 @@ Template.taskForm.events({
|
|||
}
|
||||
|
||||
if (taskUserErr == false && taskDateErr == false && taskNameErr == false) {
|
||||
Meteor.call("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding the new task: " + err);
|
||||
const addTask = async() => {
|
||||
let result = await Meteor.callAsync("add.task", taskNameArr, userInfo[0], userInfo[1], taskDateArr, actDate);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding the new task.");
|
||||
} else {
|
||||
console.log(" SUCCESS adding the new task.");
|
||||
Session.set("taskDateArr", []);
|
||||
|
|
@ -102,7 +103,8 @@ Template.taskForm.events({
|
|||
$("#taskUser").val("");
|
||||
$('select').formSelect();
|
||||
}
|
||||
});
|
||||
}
|
||||
addTask();
|
||||
} else {
|
||||
showSnackbar("ERROR: Missing Required Fields!", "red");
|
||||
}
|
||||
|
|
@ -113,7 +115,6 @@ Template.taskForm.events({
|
|||
Session.set("hideCompletedTasks", true);
|
||||
} else {
|
||||
Session.set("hideCompletedTasks", false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -43,13 +43,15 @@ Template.taskTbl.events({
|
|||
'click .markTaskComplete' (event) {
|
||||
event.preventDefault();
|
||||
let taskId = this._id;
|
||||
Meteor.call("markTask.complete", taskId, function(err, result) {
|
||||
if (err) {
|
||||
const markComp = async() => {
|
||||
let result = await Meteor.callAsync("markTask.complete", taskId);
|
||||
if (!result) {
|
||||
console.log(" ERROR marking task completeL " + err);
|
||||
showSnackbar("ERROR Marking Task Complete!", "red");
|
||||
} else {
|
||||
showSnackbar("Successfully Marked Task Complete!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
markComp();
|
||||
},
|
||||
});
|
||||
|
|
@ -2,12 +2,13 @@
|
|||
<h4>My Dashboard</h4>
|
||||
<div class="row">
|
||||
{{#if $eq currConfig.allowUpdates true}}
|
||||
{{#if updatesExist}}
|
||||
{{#if $eq updatesExist true}}
|
||||
<div class="col s12">
|
||||
<div class="card green darken-3" id="updateInfoCard">
|
||||
<div class="card-content white-text">
|
||||
<div class="card-title">Update Available</div>
|
||||
<div class="row">
|
||||
<ul class="collapsible green darken-3 white-text">
|
||||
<li>
|
||||
<div class="collapsible-header"><strong>Update Available</strong></div>
|
||||
<div class="collapsible-body">
|
||||
<div class="row">
|
||||
{{#each updates}}
|
||||
<div class="col s12">
|
||||
<div class="row">
|
||||
|
|
@ -33,8 +34,9 @@
|
|||
<hr />
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ import moment from 'moment';
|
|||
import { TaskItems } from "../../imports/api/tasks";
|
||||
import { UpdateInfo } from '../../imports/api/updateInfo.js';
|
||||
import { SysConfig } from '../../imports/api/systemConfig.js';
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
import { M } from '../lib/assets/materialize.js';
|
||||
|
||||
Template.dashboard.onCreated(function() {
|
||||
this.subscribe("userList");
|
||||
|
|
@ -23,7 +25,10 @@ Template.dashboard.onCreated(function() {
|
|||
});
|
||||
|
||||
Template.dashboard.onRendered(function() {
|
||||
|
||||
setTimeout(function() {
|
||||
var elems = document.querySelectorAll('.collapsible');
|
||||
var instances = M.Collapsible.init(elems, {});
|
||||
}, 200);
|
||||
});
|
||||
|
||||
Template.dashboard.helpers({
|
||||
|
|
@ -61,18 +66,47 @@ Template.dashboard.helpers({
|
|||
},
|
||||
updates: function() {
|
||||
let updateAvail = UpdateInfo.find({});
|
||||
return updateAvail;
|
||||
},
|
||||
updatesExist: function() {
|
||||
let updateExists = UpdateInfo.find({ viewed: false }).fetch();
|
||||
if (updateExists.length > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
try {
|
||||
if (!updateAvail) {
|
||||
console.log("No update info found.");
|
||||
return false;
|
||||
} else {
|
||||
console.dir(updateAvail);
|
||||
return updateAvail;
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR trying to grab update info: " + error);
|
||||
}
|
||||
},
|
||||
updatesExist: function() {
|
||||
const ifUpdate = async() => {
|
||||
let updateExists = await UpdateInfo.findOneAsync({ viewed: false });
|
||||
if (!updateExists) {
|
||||
console.log("Update doesn't exist as false.");
|
||||
return false;
|
||||
} else {
|
||||
console.log("Update found with false.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
let updateAvail = ifUpdate();
|
||||
return updateAvail;
|
||||
},
|
||||
currConfig: function() {
|
||||
return SysConfig.findOne({});
|
||||
const getSys = async() => {
|
||||
let currSys = SysConfig.findOneAsync({});
|
||||
try {
|
||||
if (!currSys) {
|
||||
// console.log("No System Config found.")
|
||||
} else {
|
||||
return currSys;
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR trying to fetch current system config: " + error);
|
||||
}
|
||||
}
|
||||
let currConf = getSys();
|
||||
return currConf;
|
||||
},
|
||||
descriptionSinHTML: function() {
|
||||
let desc = this.description;
|
||||
|
|
@ -141,12 +175,19 @@ Template.dashboard.events({
|
|||
'click .readLink' (event) {
|
||||
let eventId = event.currentTarget.id;
|
||||
|
||||
Meteor.call('markUpdate.read', eventId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR marking update as 'read': " + err);
|
||||
} else {
|
||||
console.log("marked read successfully!");
|
||||
const markUpdate = async() => {
|
||||
let result = await Meteor.callAsync('markUpdate.read', eventId);
|
||||
try {
|
||||
if (!result) {
|
||||
console.log(" Error marking this read.");
|
||||
showSnackbar("Error Marking Read!", "red");
|
||||
} else {
|
||||
showSnackbar("Successfully Marked as Read.", "green");
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR trying to mark this update as read: " + error);
|
||||
}
|
||||
});
|
||||
}
|
||||
markUpdate();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -22,14 +22,16 @@ Template.deleteConfirmationModal.events({
|
|||
let deleteId = Session.get("deleteId");
|
||||
let method = Session.get("method");
|
||||
|
||||
Meteor.call(method, deleteId, function(err, result) {
|
||||
if (err) {
|
||||
const delItem = async() => {
|
||||
let result = await Meteor.callAsync(method, deleteId);
|
||||
if (!result) {
|
||||
console.log(" ERROR deleting item from modal: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESSFULLY deleted.");
|
||||
// put the new modal open / close here
|
||||
// $('#modalDelete').modal('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
delItem();
|
||||
},
|
||||
});
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
<li><a href="#" id="mymenus" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Menus</a></li>
|
||||
<li><a href="#" id="myTasks" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">My Tasks</a></li>
|
||||
<li><a href="#" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}" id="mySettings">My Settings</a></li>
|
||||
{{#if isInRole 'systemadmin'}}
|
||||
{{#if isInRole "systemadmin"}}
|
||||
<li><a href="#" id="manage" class="navBtn {{#if $eq myTheme 'dark'}}white-text{{/if}}">Manage</a></li>
|
||||
{{/if}}
|
||||
<li class="signOut {{#if $eq myTheme 'dark'}}white-text{{/if}}"><a href="#" class="signOut">Log Out</a></li>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,38 @@
|
|||
import { Meteor } from 'meteor/meteor';
|
||||
import { M } from '../lib/assets/materialize';
|
||||
import { UpdateInfo } from '../../imports/api/updateInfo.js';
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
import { Roles } from 'meteor/roles';
|
||||
|
||||
Template.headerBar.onCreated(function() {
|
||||
this.subscribe("UpdateVersion");
|
||||
this.subscribe("assignment");
|
||||
});
|
||||
|
||||
Template.headerBar.onRendered(function() {
|
||||
var elems = document.querySelectorAll('.sidenav');
|
||||
var instances = M.Sidenav.init(elems, {});
|
||||
var elemd = document.querySelectorAll('.dropdown-trigger');
|
||||
var instances = M.Dropdown.init(elemd, {});
|
||||
var instances = M.Dropdown.init(elemd, {});
|
||||
|
||||
setTimeout(function() {
|
||||
const getRoles = async() => {
|
||||
let userId = Meteor.userId();
|
||||
// let isRole = await Roles.userIsInRoleAsync(userId, "systemadmin");
|
||||
let isRole = await Roles.getRolesForUserAsync(userId);
|
||||
try {
|
||||
if (!isRole) {
|
||||
console.log("SystemAdmin role for user not found: " + isRole);;
|
||||
} else {
|
||||
console.log("Found role for the user: ");
|
||||
console.dir(isRole);
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting role for user: " + error);
|
||||
}
|
||||
}
|
||||
getRoles();
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
Template.headerBar.helpers({
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ Template.listItemsForm.helpers({
|
|||
}
|
||||
},
|
||||
itemProdName: function() {
|
||||
|
||||
return Products.find({});
|
||||
},
|
||||
editMode: function() {
|
||||
|
|
@ -66,14 +67,7 @@ Template.listItemsForm.events({
|
|||
if (item == null || item == "") {
|
||||
Session.set("itemReqErr", true);
|
||||
} else {
|
||||
Meteor.call("add.listItem", item, listId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding item to list: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS adding item to list.");
|
||||
$("#findListItems").val("");
|
||||
}
|
||||
});
|
||||
addItem(item, listId);
|
||||
}
|
||||
},
|
||||
'keydown #findListItems' (event) {
|
||||
|
|
@ -83,14 +77,7 @@ Template.listItemsForm.events({
|
|||
if (item == null || item == "") {
|
||||
Session.set("itemReqErr", true);
|
||||
} else {
|
||||
Meteor.call("add.listItem", item, listId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding item to list: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS adding item to list.");
|
||||
$("#findListItems").val("");
|
||||
}
|
||||
});
|
||||
addItem(item, listId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -110,8 +97,11 @@ Template.listItemsForm.events({
|
|||
'keyup #findListItems' (event) {
|
||||
if (event.which !== 13) {
|
||||
let findItemVal = $("#findListItems").val();
|
||||
// console.log(findItemVal);
|
||||
let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}).fetch();
|
||||
if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) {
|
||||
if (!listItemInfo) {
|
||||
console.log("No data for key input.");
|
||||
} else {
|
||||
getDataList(listItemInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +118,21 @@ Template.listItemsForm.events({
|
|||
});
|
||||
|
||||
getDataList = function(listItemInfo) {
|
||||
// console.log(listItemInfo);
|
||||
let listItemObjArray = [];
|
||||
listItemObjArray = listItemInfo.map(info => ({ id: info._id, text: info.prodName, store: info.prodStore }))
|
||||
Session.set("findListItems", listItemObjArray);
|
||||
}
|
||||
|
||||
const addItem = async(item, listId) => {
|
||||
let result = await Meteor.callAsync("add.listItem", item, listId);
|
||||
try {
|
||||
if (!result) {
|
||||
console.log(" ISSUE adding list item. See logs.");
|
||||
} else {
|
||||
$("#findListItems").val("");
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR adding list item: " + error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ Template.listItemsTbl.helpers({
|
|||
let showRecvd = Session.get("showReceivedItems");
|
||||
let searchVal = Session.get("searchVal");
|
||||
if (showRecvd == false) {
|
||||
if (typeof searchVal == 'undefined' || searchVal.length === 0) {
|
||||
if (!searchVal) {
|
||||
return ListItems.find({ itemReceived: false });
|
||||
} else {
|
||||
return ListItems.find({ itemReceived: false, itemName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
}
|
||||
} else {
|
||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
||||
if (!searchVal) {
|
||||
return ListItems.find({});
|
||||
} else {
|
||||
return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Lists } from '../../imports/api/lists.js';
|
||||
import { M } from '../lib/assets/materialize.js';
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
|
||||
Template.listsTbl.onCreated(function() {
|
||||
this.subscribe("myLists");
|
||||
|
|
@ -25,17 +26,19 @@ Template.listsTbl.events({
|
|||
if (listId == "addList") {
|
||||
// opens the modal and allows you to add a new List
|
||||
} else {
|
||||
// console.log("listId is: " + listId);
|
||||
console.log("listId is: " + listId);
|
||||
Session.set("listId", listId);
|
||||
Meteor.call('add.userLast', "List", listId, function(err, result) {
|
||||
if (err) {
|
||||
const addUserLast = async() => {
|
||||
let result = await Meteor.callAsync('add.userLast', "List", listId);
|
||||
if (!result) {
|
||||
console.log(" ERROR setting user last list id in db: " + err);
|
||||
} else {
|
||||
Meteor.setTimeout(function() {
|
||||
setTimeout(function() {
|
||||
FlowRouter.go('/listitems');
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
addUserLast();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -47,15 +50,17 @@ Template.listsTbl.events({
|
|||
let splitList = listFullId.split("_");
|
||||
let listId = splitList[1];
|
||||
// console.log("listId is " + listId);
|
||||
Meteor.call("mark.complete", listId, function(err, result){
|
||||
if (err) {
|
||||
console.log(" ERROR marking list complete! " + err);
|
||||
const markComp = async() => {
|
||||
let result = await Meteor.callAsync("mark.complete", listId);
|
||||
if (!result) {
|
||||
console.log(" ERROR marking list complete!");
|
||||
showSnackbar("ERROR! List Not Makred Complete!", "red");
|
||||
} else {
|
||||
// console.log(" SUCCESS marking list complete.");
|
||||
showSnackbar("List Marked Complete!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
markComp();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -7,20 +7,27 @@ Template.MainLayout.onCreated(function() {
|
|||
Template.MainLayout.onRendered(function() {
|
||||
this.autorun(() => {
|
||||
let myId = Meteor.userId();
|
||||
let myprefs = UserConfig.findOne({ user: myId });
|
||||
if (typeof myprefs != 'undefined') {
|
||||
if (myprefs.darkMode == "light") {
|
||||
console.log("Found theme as light");
|
||||
Session.set("myTheme", "light");
|
||||
document.documentElement.setAttribute('theme', "light");
|
||||
} else {
|
||||
console.log("Found theme as dark");
|
||||
Session.set("myTheme", "dark");
|
||||
document.documentElement.setAttribute('theme', "dark");
|
||||
}
|
||||
} else {
|
||||
console.log("User Prefs appear undefined.");
|
||||
const getConfig = async() => {
|
||||
let myprefs = await UserConfig.findOneAsync({ user: myId });
|
||||
try {
|
||||
if (!myprefs) {
|
||||
console.log("User Prefs appear undefined.");
|
||||
} else {
|
||||
if (myprefs.darkMode == "light") {
|
||||
console.log("Found theme as light");
|
||||
Session.set("myTheme", "light");
|
||||
document.documentElement.setAttribute('theme', "light");
|
||||
} else {
|
||||
console.log("Found theme as dark");
|
||||
Session.set("myTheme", "dark");
|
||||
document.documentElement.setAttribute('theme', "dark");
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting user preferences: " + error);
|
||||
}
|
||||
}
|
||||
getConfig();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,14 +27,16 @@ Template.addMenuModal.events({
|
|||
if (menuName == "" || menuName == null) {
|
||||
Session.set("menuNameErr", true);
|
||||
} else {
|
||||
Meteor.call("add.menu", menuName, function(err, result) {
|
||||
if (err) {
|
||||
const addMenu = async() => {
|
||||
let result = await Meteor.callAsync("add.menu", menuName);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding menu: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS adding menu.");
|
||||
$("#menuNameInp").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
addMenu();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
import { Menus } from '../../imports/api/menu.js';
|
||||
import { M } from '../lib/assets/materialize.js';
|
||||
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
|
||||
|
||||
Template.mainMenuTbl.onCreated(function() {
|
||||
this.subscribe("myMenus");
|
||||
|
|
@ -21,41 +22,48 @@ Template.mainMenuTbl.events({
|
|||
'click li.collection-item' (event) {
|
||||
event.preventDefault();
|
||||
let sender = event.target;
|
||||
// console.log("Sender origination from: ");
|
||||
// console.log("Sender originated from: ");
|
||||
// console.log(sender.localName);
|
||||
if (sender.localName == "li") {
|
||||
let menuId = event.currentTarget.id;
|
||||
if (menuId == "addMenu") {
|
||||
// console.log("add menu clicked");
|
||||
console.log("add menu clicked");
|
||||
} else {
|
||||
// console.log("menuId is: " + menuId);
|
||||
Meteor.call('add.userLast', "Menu", menuId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR writing last menu viewed by user to db: " + err);
|
||||
console.log("menuId is: " + menuId);
|
||||
const addUserLast = async() => {
|
||||
let result = await Meteor.callAsync('add.userLast', "Menu", menuId);
|
||||
if (!result) {
|
||||
console.log(" ERROR writing last menu viewed by user to db.");
|
||||
} else {
|
||||
Session.set("menuId", menuId);
|
||||
Meteor.setTimeout(function() {
|
||||
FlowRouter.go('/menuitems');
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
addUserLast();
|
||||
}
|
||||
} else if (sender.localName == "i") {
|
||||
let menuId = this._id;
|
||||
Meteor.call("markMenu.complete", menuId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: can't mark menu complete: " + err);
|
||||
const makrMenuComp = async() => {
|
||||
let result = await Meteor.callAsync("markMenu.complete", menuId);
|
||||
if (!result) {
|
||||
console.log(" ERROR: can't mark menu complete.");
|
||||
} else {
|
||||
console.log(" SUCCESS marking menu complete.");
|
||||
Meteor.call('setAllMade.menuItem', menuId, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: cannot set all items as made: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESS setting all items made.");
|
||||
}
|
||||
});
|
||||
setAllMade();
|
||||
}
|
||||
});
|
||||
}
|
||||
makrMenuComp();
|
||||
|
||||
const setAllMade = async() => {
|
||||
let result = await Meteor.callAsync('setAllMade.menuItem', menuId);
|
||||
if (!result) {
|
||||
console.log(" ERROR: cannot set all items as made.");
|
||||
} else {
|
||||
console.log(" SUCCESS setting all items made.");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -40,7 +40,7 @@ Template.myTasksForm.events({
|
|||
if (taskDateArray == null || taskDateArray == []|| taskDateArray == "") {
|
||||
taskDateErr = true;
|
||||
} else {
|
||||
for (i = 0; i < taskDateArray.length; i++) {
|
||||
for (let i = 0; i < taskDateArray.length; i++) {
|
||||
// console.log(taskDateArray[i]);
|
||||
let actDateTask = new Date(taskDateArray[i]);
|
||||
actDate.push(actDateTask);
|
||||
|
|
@ -49,10 +49,11 @@ Template.myTasksForm.events({
|
|||
|
||||
console.log("Date Error: " + taskDateErr + " - Name Error: " + taskNameErr);
|
||||
if (taskDateErr == false && taskNameErr == false) {
|
||||
Meteor.call("add.task", taskNameArray, "self", "selfId", taskDateArray, actDate, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR adding task for self: " + err);
|
||||
showSnackbar("ERROR adding task for self!", "red");
|
||||
const addTask = async() => {
|
||||
let result = await Meteor.callAsync("add.task", taskNameArray, "self", "selfId", taskDateArray, actDate);
|
||||
if (!result) {
|
||||
console.log(" ERROR adding task for self: ");
|
||||
showSnackbar("Error adding task for self!", "red");
|
||||
} else {
|
||||
console.log(" SUCCESS adding task for self.");
|
||||
Session.set("taskDateArr", []);
|
||||
|
|
@ -60,7 +61,8 @@ Template.myTasksForm.events({
|
|||
$("#myTaskDate").val("");
|
||||
showSnackbar("Added Tasks Successfully!", "green");
|
||||
}
|
||||
});
|
||||
}
|
||||
addTask();
|
||||
} else {
|
||||
showSnackbar("Error! Both Task & Date are Required!", "red");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,15 +55,15 @@ Template.myTasksTbl.events({
|
|||
'click .markMyTaskComplete' (event) {
|
||||
event.preventDefault();
|
||||
let taskId = this._id;
|
||||
Meteor.call("markTask.complete", taskId, function(err, result) {
|
||||
if (err) {
|
||||
const makrTaskComp = async() => {
|
||||
let result = await Meteor.callAsync("markTask.complete", taskId);
|
||||
if (!result) {
|
||||
console.log(" ERROR marking task completeL " + err);
|
||||
showSnackbar("ERROR Marking Task Complete!", "red");
|
||||
} else {
|
||||
showSnackbar("Successfully Marked Task Complete!", "green");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'click .deleteMyTask' (event) {
|
||||
event.preventDefault();
|
||||
|
|
|
|||
|
|
@ -5,15 +5,29 @@ Template.userConfig.onCreated(function() {
|
|||
});
|
||||
|
||||
Template.userConfig.onRendered(function() {
|
||||
let myConfig = UserConfig.findOne({ user: Meteor.userId() });
|
||||
if (typeof myConfig != 'undefined') {
|
||||
console.log("My Pref: " + myConfig.darkPref);
|
||||
if (myConfig.darkMode == 'light') {
|
||||
$("#darkMode").prop('checked', false);
|
||||
} else {
|
||||
$("#darkMode").prop('checked', true);
|
||||
const getConfig = async() => {
|
||||
// console.log("tried to get switch config.")
|
||||
let myConfig = await UserConfig.findOneAsync({ user: Meteor.userId() });
|
||||
try {
|
||||
// console.dir(myConfig);
|
||||
if (!myConfig) {
|
||||
// console.log("config not found, setting to light mode.");
|
||||
$("#darkMode").prop('checked', false);
|
||||
} else {
|
||||
// console.log("My Pref: " + myConfig.darkMode);
|
||||
if (myConfig.darkMode == 'light') {
|
||||
$("#darkMode").prop('checked', false);
|
||||
} else {
|
||||
// console.log("should be checked.")
|
||||
$("#darkMode").prop('checked', true);
|
||||
}
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting dark theme for setting swtich: " + error);
|
||||
}
|
||||
|
||||
}
|
||||
getConfig();
|
||||
});
|
||||
|
||||
Template.userConfig.helpers({
|
||||
|
|
@ -22,23 +36,22 @@ Template.userConfig.helpers({
|
|||
|
||||
Template.userConfig.events({
|
||||
'click #darkMode' (event) {
|
||||
let darkModePref = $("#darkMode").prop('checked');
|
||||
let darkModePref = $("#darkMode").prop('checked')
|
||||
if (darkModePref == true) {
|
||||
Meteor.call('update.darkModePref', 'dark', function(err, reuslt) {
|
||||
if (err) {
|
||||
console.log(" ERROR: could not set dark mode preference to dark: " + err);
|
||||
} else {
|
||||
showSnackbar("Dark Mode Preference Set to Dark", "green");
|
||||
}
|
||||
});
|
||||
let mode = 'dark';
|
||||
setDarkMode(mode);
|
||||
} else {
|
||||
Meteor.call('update.darkModePref', 'light', function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: could not set dark mode preference to light: " + err);
|
||||
} else {
|
||||
showSnackbar("Dark Mode Preference Set to Light", "green");
|
||||
}
|
||||
});
|
||||
let mode = 'light';
|
||||
setDarkMode(mode);
|
||||
}
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const setDarkMode = async(mode) => {
|
||||
let result = await Meteor.callAsync('update.darkModePref', mode);
|
||||
if (!result) {
|
||||
console.log(" - Did not receive back a 'result' from the update.");
|
||||
} else {
|
||||
showSnackbar("Dark Mode Preference Set to " + mode, "green");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue