diff --git a/client/AdminMgmt/MgmtPage/mgmtPage.html b/client/AdminMgmt/MgmtPage/mgmtPage.html
index df2ad22..ebb2637 100644
--- a/client/AdminMgmt/MgmtPage/mgmtPage.html
+++ b/client/AdminMgmt/MgmtPage/mgmtPage.html
@@ -11,6 +11,7 @@
Category
Location
Store
+ Tasks
diff --git a/client/AdminMgmt/MgmtPage/mgmtPage.js b/client/AdminMgmt/MgmtPage/mgmtPage.js
index 162c17b..39c831a 100644
--- a/client/AdminMgmt/MgmtPage/mgmtPage.js
+++ b/client/AdminMgmt/MgmtPage/mgmtPage.js
@@ -1,4 +1,3 @@
-
Template.mgmtPage.onCreated(function() {
});
diff --git a/client/AdminMgmt/Tasks/taskForm.html b/client/AdminMgmt/Tasks/taskForm.html
new file mode 100644
index 0000000..c01f73f
--- /dev/null
+++ b/client/AdminMgmt/Tasks/taskForm.html
@@ -0,0 +1,35 @@
+
+ Tasks
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{> snackbar}}
+
\ No newline at end of file
diff --git a/client/AdminMgmt/Tasks/taskForm.js b/client/AdminMgmt/Tasks/taskForm.js
new file mode 100644
index 0000000..e4f4381
--- /dev/null
+++ b/client/AdminMgmt/Tasks/taskForm.js
@@ -0,0 +1,79 @@
+import { Tasks } from '../../../imports/api/tasks.js';
+
+Template.taskForm.onCreated(function() {
+ this.subscribe("userList");
+ this.subscribe("allTasks");
+});
+
+Template.taskForm.onRendered(function() {
+ Meteor.setTimeout(function() {
+ $('select').formSelect();
+ }, 100);
+ $('select').formSelect();
+ $('.datepicker').datepicker();
+ Session.set("taskNameErr", false);
+ Session.set("taskUserErr", false);
+ Session.set("taskDateErr", false);
+ Session.set("hideCompletedTasks", true);
+});
+
+Template.taskForm.helpers({
+ taskUsers: function() {
+ return Meteor.users.find({});
+ },
+ username: function() {
+ return this.profile.fullname;
+ },
+});
+
+Template.taskForm.events({
+ 'click .saveTaskMgmt' (event) {
+ event.preventDefault();
+ let taskName = $("#taskName").val();
+ let taskUser = $("#taskUser").val();
+ let taskDate = $("#taskDate").val();
+ let taskUserErr = false;
+ let taskNameErr = false;
+ let taskDateErr = false;
+
+ console.log("taskUser value: " + taskUser);
+
+ if (taskName == null || taskName == "") {
+ taskNameErr = true;
+ }
+
+ if (taskDate == null || taskDate == "") {
+ taskDateErr = true;
+ }
+
+ if (taskUser == null || taskUser == "") {
+ console.log("triggered taskUser error.");
+ taskUserErr = true;
+ }
+
+ if (taskUserErr == false && taskDateErr == false && taskNameErr == false) {
+ Meteor.call("add.task", taskName, taskUser, taskDate, function(err, result) {
+ if (err) {
+ console.log(" ERROR adding the new task: " + err);
+ } else {
+ console.log(" SUCCESS adding the new task.");
+ $("#taskName").val("");
+ $("#taskDate").val("");
+ $("#taskUser").val("");
+ $('select').formSelect();
+ }
+ });
+ } else {
+ showSnackbar("ERROR: Missing Required Fields!", "red");
+ }
+ },
+ 'click #hideCompletedTasks' (event) {
+ let hideComp = $("#hideCompletedTasks").prop('checked');
+ if (hideComp == true) {
+ Session.set("hideCompletedTasks", true);
+ } else {
+ Session.set("hideCompletedTasks", false);
+ }
+
+ }
+});
\ No newline at end of file
diff --git a/client/AdminMgmt/Tasks/taskHome.html b/client/AdminMgmt/Tasks/taskHome.html
new file mode 100644
index 0000000..2973355
--- /dev/null
+++ b/client/AdminMgmt/Tasks/taskHome.html
@@ -0,0 +1,5 @@
+
+ {{> taskForm}}
+
+ {{> taskTbl}}
+
\ No newline at end of file
diff --git a/client/AdminMgmt/Tasks/taskTbl.html b/client/AdminMgmt/Tasks/taskTbl.html
new file mode 100644
index 0000000..fa0961c
--- /dev/null
+++ b/client/AdminMgmt/Tasks/taskTbl.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+ | Task Name |
+ Assigned To |
+ Due |
+ Done On |
+ Complete |
+
+
+
+ {{#each tasks}}
+
+ | {{taskName}} |
+ {{assignedTo}} |
+ {{taskDate}} |
+ {{completeDate}} |
+
+ {{#if $eq isComplete true}}
+ check
+ {{/if}}
+ |
+
+ delete
+ check
+ |
+
+ {{/each}}
+
+
+
+
+ {{> deleteConfirmationModal}}
+ {{> snackbar}}
+
\ No newline at end of file
diff --git a/client/AdminMgmt/Tasks/taskTbl.js b/client/AdminMgmt/Tasks/taskTbl.js
new file mode 100644
index 0000000..75fb526
--- /dev/null
+++ b/client/AdminMgmt/Tasks/taskTbl.js
@@ -0,0 +1,51 @@
+import { TaskItems } from '../../../imports/api/tasks.js';
+import moment from 'moment';
+
+Template.taskTbl.onCreated(function() {
+ this.subscribe("allTasks");
+});
+
+Template.taskTbl.onRendered(function() {
+ Session.set("hideCompletedTasks", false);
+});
+
+Template.taskTbl.helpers({
+ tasks: function() {
+ let hideComp = Session.get("hideCompletedTasks");
+ if (hideComp == false) {
+ return TaskItems.find({});
+ } else {
+ return TaskItems.find({ isComplete: false });
+ }
+ },
+ completeDate: function() {
+ let completedOn = this.completedOn;
+ if (completedOn != null) {
+ let compOn = moment(completedOn).format("MMM DD, YYYY");
+ return compOn;
+ }
+ }
+});
+
+Template.taskTbl.events({
+ 'click .deleteTask' (event) {
+ event.preventDefault();
+ Session.set("deleteId", this._id);
+ Session.set("method", "delete.task");
+ Session.set("item", this.taskName);
+ Session.set("view", "Tasks");
+ $('#modalDelete').modal('open');
+ },
+ 'click .markTaskComplete' (event) {
+ event.preventDefault();
+ let taskId = this._id;
+ Meteor.call("markTask.complete", taskId, function(err, result) {
+ if (err) {
+ console.log(" ERROR marking task completeL " + err);
+ showSnackbar("ERROR Marking Task Complete!", "red");
+ } else {
+ showSnackbar("Successfully Marked Task Complete!", "green");
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/client/General/headerBar.html b/client/General/headerBar.html
index 6b30ae1..ba6ce7a 100644
--- a/client/General/headerBar.html
+++ b/client/General/headerBar.html
@@ -10,6 +10,7 @@
{{#if currentUser}}
My Lists
+ My Tasks
{{#if isInRole 'systemadmin'}}
Manage
{{/if}}
@@ -24,6 +25,7 @@
{{#if currentUser}}
My Lists
+ My Tasks
{{#if isInRole 'systemadmin'}}
Manage
{{/if}}
diff --git a/imports/api/recipeItems.js b/imports/api/recipeItems.js
new file mode 100644
index 0000000..a0688be
--- /dev/null
+++ b/imports/api/recipeItems.js
@@ -0,0 +1,57 @@
+import { Meteor } from 'meteor/meteor';
+import { Mongo } from 'meteor/mongo';
+import { check } from 'meteor/check';
+
+export const RecipeItems = new Mongo.Collection('recipeitems');
+
+RecipeItems.allow({
+ insert: function(userId, doc){
+ // if use id exists, allow insert
+ return !!userId;
+ },
+});
+
+Meteor.methods({
+ 'add.recipeItem' (recipeId, recipeItemType, recipeItem) {
+ check(recipeId, String);
+ check(recipeItemType, String);
+ check(recipeItem, String);
+
+ if (!this.userId) {
+ 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({
+ recipeId: recipeId,
+ recipeItemType: recipeItemType,
+ recipeItem: recipeItem,
+ });
+ },
+ 'edit.recipeItem' (recipeItemId, recipeId, recipeItemType, recipeItem) {
+ check(recipeItemId, String);
+ check(recipeId, String);
+ check(recipeItemType, String);
+ check(recipeItem, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ recipeId: recipeId,
+ recipeItemType: recipeItemType,
+ recipeItem: recipeItem,
+ }
+ });
+ },
+ 'delete.recipeItem' (recipeItemId) {
+ check(recipeItemId, String);
+
+ if (!this.userId) {
+ 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 });
+ }
+});
\ No newline at end of file
diff --git a/imports/api/recipes.js b/imports/api/recipes.js
new file mode 100644
index 0000000..9ad2169
--- /dev/null
+++ b/imports/api/recipes.js
@@ -0,0 +1,53 @@
+import { Meteor } from 'meteor/meteor';
+import { Mongo } from 'meteor/mongo';
+import { check } from 'meteor/check';
+
+export const Recipes = new Mongo.Collection('recipes');
+
+Recipes.allow({
+ insert: function(userId, doc){
+ // if use id exists, allow insert
+ return !!userId;
+ },
+});
+
+Meteor.methods({
+ 'add.recipe' (recipeName) {
+ check(recipeName, String);
+
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to add recipes. Make sure you are logged in with valid user credentials.');
+ }
+
+ return Recipes.insert({
+ recipeName: recipeName,
+ addedBy: this.userId,
+ addedOn: new Date(),
+ });
+ },
+ 'edit.recipe' (recipeId, recipeName) {
+ check(recipeId, String);
+ check(recipeName, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ recipeName: recipeName,
+ updatedOn: new Date(),
+ updatedBy: this.userId,
+ }
+ });
+ },
+ 'delete.recipe' (recipeId) {
+ check(recipeId, String);
+
+ if (!this.userId) {
+ 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 });
+ }
+});
\ No newline at end of file
diff --git a/imports/api/tasks.js b/imports/api/tasks.js
new file mode 100644
index 0000000..0faabb0
--- /dev/null
+++ b/imports/api/tasks.js
@@ -0,0 +1,93 @@
+import { Meteor } from 'meteor/meteor';
+import { Mongo } from 'meteor/mongo';
+import { check } from 'meteor/check';
+
+export const TaskItems = new Mongo.Collection('taskitems');
+
+TaskItems.allow({
+ insert: function(userId, doc){
+ // if use id exists, allow insert
+ return !!userId;
+ },
+});
+
+Meteor.methods({
+ 'add.task' (taskName, assignedTo, taskDate) {
+ check(taskName, String);
+ check(assignedTo, String);
+ check(taskDate, String);
+
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to add tasks. Make sure you are logged in with valid user credentials.');
+ }
+
+ return TaskItems.insert({
+ taskName: taskName,
+ taskDate: taskDate,
+ assignedTo: assignedTo,
+ isComplete: false,
+ completedOn: null,
+ assignedOn: new Date(),
+ assignedBy: this.userId,
+ });
+ },
+ 'edit.task' (taskId, taskName, assignedTo, taskDate) {
+ check(taskId, String);
+ check(taskName, String);
+ check(assignedTo, String);
+ check(taskDate, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ taskName: taskName,
+ taskDate: taskDate,
+ assignedTo: assignedTo,
+ changedOn: new Date(),
+ changedBy: this.userId,
+ }
+ });
+ },
+ 'delete.task' (taskId) {
+ check(taskId, String);
+
+ if (!this.userId) {
+ 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 });
+ },
+ 'markTask.complete' (taskId) {
+ check(taskId, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ isComplete: true,
+ completedOn: new Date(),
+ completedBy: this.userId,
+ }
+ });
+ },
+ 'markTask.notComplete' (taskId) {
+ check(taskId, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ isComplete: false,
+ markedUncomplteOn: new Date(),
+ markedUncompleteBy: this.userId,
+ }
+ });
+ },
+});
\ No newline at end of file
diff --git a/lib/routes.js b/lib/routes.js
index 213b26a..6df339f 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -108,4 +108,11 @@ FlowRouter.route('/menuItems', {
action() {
BlazeLayout.render('MainLayout', { main: 'menuItems' });
}
+});
+
+FlowRouter.route('/taskHome', {
+ name: 'taskHome',
+ action() {
+ BlazeLayout.render('MainLayout', { main: 'taskHome' });
+ }
});
\ No newline at end of file
diff --git a/server/publish.js b/server/publish.js
index 9efef1f..6857432 100644
--- a/server/publish.js
+++ b/server/publish.js
@@ -9,6 +9,7 @@ import { ListItems } from '../imports/api/listItems.js';
import { Menus } from '../imports/api/menu.js';
import { MenuItems } from '../imports/api/menuItems.js';
import moment from 'moment';
+import { TaskItems } from '../imports/api/tasks.js';
Meteor.publish("SystemConfig", function() {
try {
@@ -95,4 +96,12 @@ Meteor.publish("todayMenuItems", function() {
} catch (error) {
console.log(" ERROR pulling today's menu items: " + error);
}
+});
+
+Meteor.publish("allTasks", function() {
+ try {
+ return TaskItems.find({});
+ } catch (error) {
+ console.log(" ERROR pulling the task items: " + error);
+ }
});
\ No newline at end of file