diff --git a/client/General/headerBar.html b/client/General/headerBar.html
index e15265e..6b30ae1 100644
--- a/client/General/headerBar.html
+++ b/client/General/headerBar.html
@@ -9,6 +9,7 @@
{{#if currentUser}}
- My Lists
+
{{#if isInRole 'systemadmin'}}
- Manage
{{/if}}
@@ -22,6 +23,7 @@
{{#if currentUser}}
- My Lists
+
{{#if isInRole 'systemadmin'}}
- Manage
{{/if}}
diff --git a/client/MenuItems/menuItems.html b/client/MenuItems/menuItems.html
new file mode 100644
index 0000000..eeca689
--- /dev/null
+++ b/client/MenuItems/menuItems.html
@@ -0,0 +1,5 @@
+
+ {{> menuItemsForm}}
+
+ {{> menuItemsTbl}}
+
\ No newline at end of file
diff --git a/client/MenuItems/menuItems.js b/client/MenuItems/menuItems.js
new file mode 100644
index 0000000..6d5256d
--- /dev/null
+++ b/client/MenuItems/menuItems.js
@@ -0,0 +1,15 @@
+Template.menuItems.onCreated(function() {
+
+});
+
+Template.menuItems.onRendered(function() {
+
+});
+
+Template.menuItems.helpers({
+
+});
+
+Template.menuItems.events({
+
+});
\ No newline at end of file
diff --git a/client/MenuItems/menuItemsForm.js b/client/MenuItems/menuItemsForm.js
new file mode 100644
index 0000000..031add6
--- /dev/null
+++ b/client/MenuItems/menuItemsForm.js
@@ -0,0 +1,47 @@
+import { MenuItems } from '../../imports/api/menuItems.js';
+import { Menus } from '../../imports/api/menu.js';
+
+Template.menuItemsForm.onCreated(function() {
+ this.subscribe("myMenus");
+ this.subscribe("myMenuItems", Session.get("menuId"));
+});
+
+Template.menuItemsForm.onRendered(function() {
+ $('.datepicker').datepicker();
+ Session.set("menuItemErr", false);
+});
+
+Template.menuItemsForm.helpers({
+ menuItemErr: function() {
+ return Session.get("menuItemErr");
+ },
+ menuName: function() {
+ let menuId = Session.get("menuId");
+ let menuInfo = Menus.findOne({ _id: menuId });
+ let menuName = menuInfo.menuName;
+ return menuName;
+ }
+});
+
+Template.menuItemsForm.events({
+ 'click .saveMenuItem' (event) {
+ event.preventDefault();
+ let menuItem = $("#menuItemInp").val();
+ let dateSrv = $("#dateServed").val();
+ let menuId = Session.get("menuId");
+
+ if (menuItem == null || menuItem == "") {
+ Session.set("menuItemErr", true);
+ } else {
+ Meteor.call('add.menuItem', menuItem, dateSrv, menuId, function(err, result) {
+ if (err) {
+ console.log(" ERROR adding menu item: " + err);
+ } else {
+ console.log(" SUCCESS adding menu item.");
+ $("#menuItemInp").val("");
+ $("#dateServed").val("");
+ }
+ });
+ }
+ }
+});
\ No newline at end of file
diff --git a/client/MenuItems/menuItemsTbl.html b/client/MenuItems/menuItemsTbl.html
new file mode 100644
index 0000000..1cf4075
--- /dev/null
+++ b/client/MenuItems/menuItemsTbl.html
@@ -0,0 +1,28 @@
+
+
+
+
+ {{#each thisMenuItems}}
+
+
+
+ {{#if $eq itemMade true}}
+ {{itemName}}
+ {{else}}
+ {{itemName}}
+ {{/if}}
+
+ |
+
+ {{serveDate}}
+ |
+
+
+ |
+
+ {{/each}}
+
+
+
+ {{> deleteConfirmationModal}}
+
\ No newline at end of file
diff --git a/client/MenuItems/menuItemsTbl.js b/client/MenuItems/menuItemsTbl.js
new file mode 100644
index 0000000..cfeeb9b
--- /dev/null
+++ b/client/MenuItems/menuItemsTbl.js
@@ -0,0 +1,21 @@
+import { MenuItems } from '../../imports/api/menuItems.js';
+
+Template.menuItemsTbl.onCreated(function() {
+ this.autorun( () => {
+ this.subscribe("myMenuItems", Session.get("menuId"));
+ });
+});
+
+Template.menuItemsTbl.onRendered(function() {
+
+});
+
+Template.menuItemsTbl.helpers({
+ thisMenuItems: function() {
+ return MenuItems.find({});
+ }
+});
+
+Template.menuItemsTbl.events({
+
+});
\ No newline at end of file
diff --git a/client/MenuItems/menuitemsForm.html b/client/MenuItems/menuitemsForm.html
new file mode 100644
index 0000000..f0ed7f0
--- /dev/null
+++ b/client/MenuItems/menuitemsForm.html
@@ -0,0 +1,20 @@
+
+ {{menuName}}
+
+
\ No newline at end of file
diff --git a/client/Menus/addMenuModal.html b/client/Menus/addMenuModal.html
new file mode 100644
index 0000000..c81c083
--- /dev/null
+++ b/client/Menus/addMenuModal.html
@@ -0,0 +1,26 @@
+
+
+
\ No newline at end of file
diff --git a/client/Menus/addMenuModal.js b/client/Menus/addMenuModal.js
new file mode 100644
index 0000000..3d6de5a
--- /dev/null
+++ b/client/Menus/addMenuModal.js
@@ -0,0 +1,42 @@
+import { Menus } from '../../imports/api/menu.js';
+
+Template.addMenuModal.onCreated(function() {
+ this.subscribe("myMenus");
+});
+
+Template.addMenuModal.onRendered(function() {
+ Session.set("menuNameErr", false);
+ $('.modal').modal();
+});
+
+Template.addMenuModal.helpers({
+ menuNameErr: function() {
+ return Session.get("menuNameErr");
+ },
+ editMode: function() {
+ return Session.get("menuEditMode");
+ }
+});
+
+Template.addMenuModal.events({
+ 'click .saveMenu' (event) {
+ event.preventDefault();
+ let menuName = $("#menuNameInp").val();
+ if (menuName == "" || menuName == null) {
+ Session.set("menuNameErr", true);
+ } else {
+ Meteor.call("add.menu", menuName, function(err, result) {
+ if (err) {
+ console.log(" ERROR adding menu: " + err);
+ } else {
+ console.log(" SUCCESS adding menu.");
+ $("#menuNameInp").val("");
+ }
+ });
+ }
+ },
+ 'click .renameMenu' (event) {
+ event.preventDefault();
+
+ },
+});
\ No newline at end of file
diff --git a/client/Menus/mainMenu.html b/client/Menus/mainMenu.html
new file mode 100644
index 0000000..a87f5de
--- /dev/null
+++ b/client/Menus/mainMenu.html
@@ -0,0 +1,3 @@
+
+ {{> mainMenuTbl}}
+
\ No newline at end of file
diff --git a/client/Menus/mainMenu.js b/client/Menus/mainMenu.js
new file mode 100644
index 0000000..0071219
--- /dev/null
+++ b/client/Menus/mainMenu.js
@@ -0,0 +1,15 @@
+Template.mainMenu.onCreated(function() {
+
+});
+
+Template.mainMenu.onRendered(function() {
+
+});
+
+Template.mainMenu.helpers({
+
+});
+
+Template.mainMenu.events({
+
+});
\ No newline at end of file
diff --git a/client/Menus/mainMenuTbl.html b/client/Menus/mainMenuTbl.html
new file mode 100644
index 0000000..deaee60
--- /dev/null
+++ b/client/Menus/mainMenuTbl.html
@@ -0,0 +1,18 @@
+
+
+
+
+ {{#each myMenus}}
+ -
+ {{menuName}}
+ check
+
+ {{/each}}
+
+
+
+
+ {{> addMenuModal}}
+
+ {{> snackbar}}
+
\ No newline at end of file
diff --git a/client/Menus/mainMenuTbl.js b/client/Menus/mainMenuTbl.js
new file mode 100644
index 0000000..7c1b3e7
--- /dev/null
+++ b/client/Menus/mainMenuTbl.js
@@ -0,0 +1,40 @@
+import { Menus } from '../../imports/api/menu.js';
+
+Template.mainMenuTbl.onCreated(function() {
+ this.subscribe("myMenus");
+});
+
+Template.mainMenuTbl.onRendered(function() {
+ Session.set("menuEditMode", false);
+});
+
+Template.mainMenuTbl.helpers({
+ myMenus: function() {
+ return Menus.find({});
+ }
+});
+
+Template.mainMenuTbl.events({
+ // 'click #addMenu' (event) {
+ // event.preventDefault();
+ // $('#modalMenu').modal('open');
+ // },
+ 'click li.collection-item' (event) {
+ event.preventDefault();
+ let sender = event.target;
+ // console.log("Sender origination from: ");
+ // console.log(sender.localName);
+ if (sender.localName == "li") {
+ let menuId = event.currentTarget.id;
+ if (menuId == "addMenu") {
+ $('#modalMenu').modal('open');
+ } else {
+ console.log("menuId is: " + menuId);
+ Session.set("menuId", menuId);
+ Meteor.setTimeout(function() {
+ FlowRouter.go('/menuitems');
+ }, 100);
+ }
+ }
+ },
+});
\ No newline at end of file
diff --git a/imports/api/menuItems.js b/imports/api/menuItems.js
new file mode 100644
index 0000000..7a206a5
--- /dev/null
+++ b/imports/api/menuItems.js
@@ -0,0 +1,87 @@
+import { Meteor } from 'meteor/meteor';
+import { Mongo } from 'meteor/mongo';
+import { check } from 'meteor/check';
+
+export const MenuItems = new Mongo.Collection('menuitems');
+
+MenuItems.allow({
+ insert: function(userId, doc){
+ // if use id exists, allow insert
+ return !!userId;
+ },
+});
+
+Meteor.methods({
+ 'add.menuItem' (itemName, serveDate, menuId) {
+ check(itemName, String);
+ check(serveDate, String);
+ check(menuId, String);
+
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to add items. Make sure you are logged in with valid user credentials.');
+ }
+
+
+ return MenuItems.insert({
+ itemName: itemName,
+ serveDate: serveDate,
+ menuId: menuId,
+ addedBy: this.userId,
+ itemMade: false,
+ dateAddedtoMenu: new Date(),
+ });
+ },
+ 'setMade.menuItem' (itemId) {
+ check(itemId, String);
+
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to set items as made. Make sure you are logged in with valid user credentials.');
+ }
+
+ return MenuItems.update({ _id: itemId }, {
+ $set: {
+ itemMade: true,
+ dateMade: new Date(),
+ }
+ });
+ },
+ 'setNotMade.menuItem' (itemId) {
+ check(itemId, String);
+
+ if (!this.userId) {
+ throw new Meteor.Error('You are not allowed to set items as not made. Make sure you are logged in with valid user credentials.');
+ }
+
+ return MenuItems.update({ _id: itemId }, {
+ $set: {
+ itemMade: false,
+ dateUnMade: new Date(),
+ }
+ });
+ },
+ 'edit.madeItem' (itemId, itemName, serveDate) {
+ check(itemId, String);
+ check(itemName, String);
+ check(serveDate, String);
+
+ if (!this.userId) {
+ 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 }, {
+ $set: {
+ itemName: itemName,
+ serveDate: serveDate,
+ }
+ });
+ },
+ 'delete.menuItem' (itemId) {
+ check(itemId, String);
+
+ if (!this.userId) {
+ 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 });
+ }
+});
\ No newline at end of file
diff --git a/lib/routes.js b/lib/routes.js
index 51fc7ce..213b26a 100644
--- a/lib/routes.js
+++ b/lib/routes.js
@@ -94,4 +94,18 @@ FlowRouter.route('/listItems', {
action() {
BlazeLayout.render('MainLayout', { main: 'listItemsMain' });
}
+});
+
+FlowRouter.route('/mymenus', {
+ name: 'mymenus',
+ action() {
+ BlazeLayout.render('MainLayout', { main: 'mainMenu' });
+ }
+});
+
+FlowRouter.route('/menuItems', {
+ name: 'menuItems',
+ action() {
+ BlazeLayout.render('MainLayout', { main: 'menuItems' });
+ }
});
\ No newline at end of file
diff --git a/server/publish.js b/server/publish.js
index 45cd22e..ea3ed06 100644
--- a/server/publish.js
+++ b/server/publish.js
@@ -6,6 +6,8 @@ import { Categories } from '../imports/api/category.js';
import { Locations } from '../imports/api/location.js';
import { Lists } from '../imports/api/lists.js';
import { ListItems } from '../imports/api/listItems.js';
+import { Menus } from '../imports/api/menu.js';
+import { MenuItems } from '../imports/api/menuItems.js';
Meteor.publish("SystemConfig", function() {
try {
@@ -66,4 +68,20 @@ Meteor.publish("myListItems", function(listId) {
} catch (error) {
console.log(" ERROR pulling list items for this list: " + error);
}
+});
+
+Meteor.publish("myMenus", function() {
+ try {
+ return Menus.find({ menuComplete: false });
+ } catch (error) {
+ console.log(" ERROR pulling menu info: " + error);
+ }
+});
+
+Meteor.publish("myMenuItems", function(menuId) {
+ try {
+ return MenuItems.find({ menuId: menuId });
+ } catch (error) {
+ console.log(" ERROR pulling list items for this list: " + error);
+ }
});
\ No newline at end of file