From 075dd579965370905cf939b399fdf53658aee89a Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 27 Aug 2022 16:59:01 -0500 Subject: [PATCH] Finished adding the simplest form of Menus. --- client/Dashboard/dashboard.html | 16 +++++++++++++ client/Dashboard/dashboard.js | 18 +++++++++++++++ client/MenuItems/menuItemsForm.js | 19 ++++++++++++++++ client/MenuItems/menuitemsForm.html | 5 ++++- imports/api/menuItems.js | 14 ++++++++++++ node_modules/meteor-node-stubs/CHANGELOG.md | 8 +++++++ package-lock.json | 25 ++++++++++++--------- package.json | 3 ++- server/publish.js | 11 +++++++++ 9 files changed, 107 insertions(+), 12 deletions(-) diff --git a/client/Dashboard/dashboard.html b/client/Dashboard/dashboard.html index 78abd7b..7022876 100644 --- a/client/Dashboard/dashboard.html +++ b/client/Dashboard/dashboard.html @@ -31,6 +31,22 @@ +
+ +
{{#if isInRole 'systemadmin'}}
diff --git a/client/Dashboard/dashboard.js b/client/Dashboard/dashboard.js index 4aa7ad9..bf899f0 100644 --- a/client/Dashboard/dashboard.js +++ b/client/Dashboard/dashboard.js @@ -3,6 +3,9 @@ import { Lists } from "../../imports/api/lists"; import { Locations } from "../../imports/api/location"; import { Products } from "../../imports/api/products"; import { Stores } from "../../imports/api/stores"; +import { Menus } from '../../imports/api/menu.js'; +import { MenuItems } from '../../imports/api/menuItems.js'; +import moment from 'moment'; Template.dashboard.onCreated(function() { @@ -12,6 +15,8 @@ Template.dashboard.onCreated(function() { this.subscribe("storeInfo"); this.subscribe("myProducts"); this.subscribe("myLocations"); + this.subscribe("myMenus"); + this.subscribe("todayMenuItems"); }); Template.dashboard.onRendered(function() { @@ -36,6 +41,14 @@ Template.dashboard.helpers({ }, locCount: function() { return Locations.find().count(); + }, + todayMenuItem: function() { + return MenuItems.find({}); + }, + todayDate: function() { + let now = new Date(); + let todayDate = moment(now).format("MMM D, YYYY"); + return todayDate; } }); @@ -62,6 +75,9 @@ Template.dashboard.events({ case "locationMgmtLink": FlowRouter.go('/manageLocation'); break; + case "myMenuLink": + FlowRouter.go('/mymenus'); + break; default: break; } @@ -89,6 +105,8 @@ Template.dashboard.events({ case "prodInfoCard": FlowRouter.go("/manageProduct"); break; + case "menuInfoCard": + FlowRouter.go('/mymenus'); default: break; } diff --git a/client/MenuItems/menuItemsForm.js b/client/MenuItems/menuItemsForm.js index 031add6..e55222e 100644 --- a/client/MenuItems/menuItemsForm.js +++ b/client/MenuItems/menuItemsForm.js @@ -1,5 +1,6 @@ import { MenuItems } from '../../imports/api/menuItems.js'; import { Menus } from '../../imports/api/menu.js'; +import moment from 'moment'; Template.menuItemsForm.onCreated(function() { this.subscribe("myMenus"); @@ -43,5 +44,23 @@ Template.menuItemsForm.events({ } }); } + }, + 'click .shiftOneDay' (event) { + event.preventDefault(); + let menuInfo = MenuItems.find({}).fetch(); + // now menuInfo is an array + let menuInfoLen = menuInfo.length; + for (i = 0; i < menuInfoLen; i++) { + let menuItemId = menuInfo[i]._id; + let momentAddDay = moment(menuInfo[i].serveDate).add(1, 'day').format("MMM D, YYYY"); + // console.log(momentAddDay); + Meteor.call('shiftDate', menuItemId, momentAddDay, function(err,result) { + if (err) { + // console.log(" ERROR shifting meal days: " + err); + } else { + // console.log(" SUCCESS shifting meal date."); + } + }); + } } }); \ No newline at end of file diff --git a/client/MenuItems/menuitemsForm.html b/client/MenuItems/menuitemsForm.html index f0ed7f0..cc5de80 100644 --- a/client/MenuItems/menuitemsForm.html +++ b/client/MenuItems/menuitemsForm.html @@ -12,7 +12,10 @@
- diff --git a/imports/api/menuItems.js b/imports/api/menuItems.js index 7a206a5..2f33efb 100644 --- a/imports/api/menuItems.js +++ b/imports/api/menuItems.js @@ -83,5 +83,19 @@ Meteor.methods({ } return MenuItems.remove({ _id: itemId }); + }, + 'shiftDate' (itemId, momentAddDay) { + check(itemId, String); + check(momentAddDay, String); + + if (!this.userId) { + 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 }, { + $set: { + serveDate: momentAddDay, + } + }); } }); \ No newline at end of file diff --git a/node_modules/meteor-node-stubs/CHANGELOG.md b/node_modules/meteor-node-stubs/CHANGELOG.md index 2395fde..8e02fcc 100644 --- a/node_modules/meteor-node-stubs/CHANGELOG.md +++ b/node_modules/meteor-node-stubs/CHANGELOG.md @@ -1,3 +1,11 @@ +v1.2.1 - 2022-03-17 + +* Fix the missing dependencies. + +v1.2.0 - 2022-03-11 + +* Adds support for [node: imports](https://nodejs.org/api/esm.html#node-imports). + v1.1.0 - 2021-07-19 * Updated dependencies to their latest versions diff --git a/package-lock.json b/package-lock.json index 266eb74..35e83cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,24 +17,24 @@ "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==" }, "meteor-node-stubs": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.1.0.tgz", - "integrity": "sha512-YvMQb4zcfWA82wFdRVTyxq28GO+Us7GSdtP+bTtC/mV35yipKnWo4W4665O57AmLVFnz4zR+WIZW11b4sfCtJw==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.2.5.tgz", + "integrity": "sha512-FLlOFZx3KnZ5s3yPCK+x58DyX9ewN+oQ12LcpwBXMLtzJ/YyprMQVivd6KIrahZbKJrNenPNUGuDS37WUFg+Mw==", "requires": { "assert": "^2.0.0", "browserify-zlib": "^0.2.0", - "buffer": "^6.0.3", + "buffer": "^5.7.1", "console-browserify": "^1.2.0", "constants-browserify": "^1.0.0", "crypto-browserify": "^3.12.0", - "domain-browser": "^4.19.0", + "domain-browser": "^4.22.0", "elliptic": "^6.5.4", "events": "^3.3.0", "https-browserify": "^1.0.0", "os-browserify": "^0.3.0", "path-browserify": "^1.0.0", "process": "^0.11.10", - "punycode": "^2.1.1", + "punycode": "^1.4.1", "querystring-es3": "^0.2.1", "readable-stream": "^3.6.0", "stream-browserify": "^3.0.0", @@ -151,11 +151,11 @@ } }, "buffer": { - "version": "6.0.3", + "version": "5.7.1", "bundled": true, "requires": { "base64-js": "^1.3.1", - "ieee754": "^1.2.1" + "ieee754": "^1.1.13" } }, "buffer-xor": { @@ -275,7 +275,7 @@ } }, "domain-browser": { - "version": "4.19.0", + "version": "4.22.0", "bundled": true }, "elliptic": { @@ -604,7 +604,7 @@ } }, "punycode": { - "version": "2.1.1", + "version": "1.4.1", "bundled": true }, "querystring": { @@ -793,6 +793,11 @@ } } }, + "moment": { + "version": "2.29.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz", + "integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==" + }, "regenerator-runtime": { "version": "0.13.9", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz", diff --git a/package.json b/package.json index fdfee12..9896551 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "dependencies": { "@babel/runtime": "^7.15.3", "jquery": "^3.6.0", - "meteor-node-stubs": "^1.1.0" + "meteor-node-stubs": "^1.2.5", + "moment": "^2.29.4" } } diff --git a/server/publish.js b/server/publish.js index ea3ed06..6dd5caa 100644 --- a/server/publish.js +++ b/server/publish.js @@ -8,6 +8,7 @@ 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'; +import moment from 'moment'; Meteor.publish("SystemConfig", function() { try { @@ -84,4 +85,14 @@ Meteor.publish("myMenuItems", function(menuId) { } catch (error) { console.log(" ERROR pulling list items for this list: " + error); } +}); + +Meteor.publish("todayMenuItems", function() { + try { + let todayDate = new Date(); + let todaysDate = moment(todayDate).format("MMM D, YYYY"); + return MenuItems.find({ serveDate: todaysDate }); + } catch (error) { + console.log(" ERROR pulling today's menu items: " + error); + } }); \ No newline at end of file