From 839390f820157f09108b9f34348456acc9d82256 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 2 Aug 2025 15:45:34 -0500 Subject: [PATCH 1/6] attempting to make product load better in drop down --- client/MenuItems/modalLinkProducts.js | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/client/MenuItems/modalLinkProducts.js b/client/MenuItems/modalLinkProducts.js index 00326ff..8d777d3 100644 --- a/client/MenuItems/modalLinkProducts.js +++ b/client/MenuItems/modalLinkProducts.js @@ -18,17 +18,29 @@ Template.modalLinkProducts.onRendered(function() { dropdownOptions: 4, }); - setTimeout(function() { - var instances = M.Modal.init(elems, {}); - var instancese = M.FormSelect.init(elemse, { - dropdownOptions: 4, - }); - }, 250); + this.autorun(() => { + if (this.subscriptionsReady()) { + // setTimeout(function() { + // var instances = M.Modal.init(elems, {}); + var elemse = document.querySelectorAll('select'); + var instancese = M.FormSelect.init(elemse, { + dropdownOptions: 4, + }); + // }, 250); + } + }); }); Template.modalLinkProducts.helpers({ products: function() { - return Products.find({}, {sort: { prodName:1 }}); + let prodInfo = Products.find({}, { sort: { prodName:1 }}); + // return Products.find({}, {sort: { prodName:1 }}); + if (!prodInfo) { + console.log("no product info yet."); + } else { + console.log("prod info found."); + return prodInfo; + } } }); @@ -79,4 +91,4 @@ Template.modalLinkProducts.events({ } } } -}); +}); \ No newline at end of file From aaddbf0b44ab203c6bd401214d1463cae2a3c6b3 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 2 Aug 2025 17:05:09 -0500 Subject: [PATCH 2/6] Fixed Menu Clean up. --- imports/api/menu.js | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/imports/api/menu.js b/imports/api/menu.js index 3cd7939..e9bd450 100644 --- a/imports/api/menu.js +++ b/imports/api/menu.js @@ -82,40 +82,7 @@ Meteor.methods({ throw new Meteor.Error('You are not allowed to clean up old Menus. Make sure you are logged in with valid user credentials.'); } - let removeMenuIds = []; - - - // let's find all the menus with menu items that are past their date. - let menuList = Menus.find({ menuComplete: false }).fetch(); - for (i=0; i < menuList.length; i++) { - let removeMenu = true; - let items = MenuItems.find({ menuId: menuList[i]._id }).fetch(); - for (let j=0; j < items.length; j++) { - let srvDate = moment(items[j].serveDateActual); - let today = moment(); - let expired = moment(today).isAfter(srvDate); - if (expired != true) { - removeMenu = false; - } - if (j == items.length - 1) { - if (removeMenu == true) { - removeMenuIds.push(menuList[i]._id); - } - } - } - } - - // next let's add the ids of any menus that are marked complete - let markedComplete = Menus.find({ menuComplete: true }).fetch(); - 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 (let l = 0; l < removeMenuIds.length; l++) { - await Menus.removeAsync({ _id: removeMenuIds[l] }); - } + return await Menus.removeAsync({ menuComplete: true }); }, async 'addto.Menu' (menuId, menuItem, menuItemId, dateSrv, isLinked) { check(menuId, String); From c6c5951d1674625895f4e2d1b632d1ff99fc95f9 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 2 Aug 2025 19:22:37 -0500 Subject: [PATCH 3/6] tiny update to add console logging. --- client/AdminMgmt/ListMgmt/listMgmtTbl.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/AdminMgmt/ListMgmt/listMgmtTbl.js b/client/AdminMgmt/ListMgmt/listMgmtTbl.js index 922028b..256f7d5 100644 --- a/client/AdminMgmt/ListMgmt/listMgmtTbl.js +++ b/client/AdminMgmt/ListMgmt/listMgmtTbl.js @@ -15,6 +15,7 @@ Template.listMgmtTbl.onRendered(function() { Template.listMgmtTbl.helpers({ lists: function() { let showComplete = Session.get("showCompletedLists"); + // console.log("Show Complete Lists: " + showComplete); if (showComplete) { return Lists.find({}); } else { From 680f7c614d2032db03c081815e95adbb346c0435 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 9 Aug 2025 07:21:46 -0500 Subject: [PATCH 4/6] Fixing clean Up and added option to show which products arent used in a list --- .../modalConfirm/cleanUpModalConfirm.js | 13 ++++++++-- .../AdminMgmt/ProductMgmt/prodMgmtForm.html | 24 ++++++++++++------- client/AdminMgmt/ProductMgmt/prodMgmtForm.js | 8 +++++++ client/AdminMgmt/ProductMgmt/prodMgmtTbl.js | 18 ++++++++++++++ imports/api/products.js | 10 ++++++++ server/publish.js | 8 +++++++ 6 files changed, 71 insertions(+), 10 deletions(-) diff --git a/client/AdminMgmt/CleanUp/modalConfirm/cleanUpModalConfirm.js b/client/AdminMgmt/CleanUp/modalConfirm/cleanUpModalConfirm.js index 247da06..19245ea 100644 --- a/client/AdminMgmt/CleanUp/modalConfirm/cleanUpModalConfirm.js +++ b/client/AdminMgmt/CleanUp/modalConfirm/cleanUpModalConfirm.js @@ -29,7 +29,7 @@ Template.cleanUpModalConfirm.events({ case "Menus": cleanUp("clean.Menus", whatItems); case "Products": - // cleanUp("clean.Products", whatItems); + cleanUp("clean.Products", whatItems); case "Stores": // cleanUp("clean.Stores", whatItems); case "Tasks": @@ -43,7 +43,7 @@ Template.cleanUpModalConfirm.events({ cleanUp = async function(methodName, whatItems) { let result = Meteor.callAsync(methodName); if (!result) { - console.log(" ERROR cleaning " + whatItems + ": " + err); + console.log(" ERROR cleaning " + whatItems); } else { showSnackbar(whatItems + " have been cleaned up!", "green"); let confirmModal = document.getElementById('cleanUpConfirm'); @@ -51,6 +51,15 @@ cleanUp = async function(methodName, whatItems) { } } +cleanProducts = async function(methodName, whatItems) { + let result = await Meteor.call(methodName, whatItems); + if (!result) { + console.log(" ERROR cleaning " + whatItems); + } else { + showSnackbar(whatItems + " have been cleaned up.", "green"); + } +} + cleanTasks = async function(methodName, whatItems) { let timeFrame = Session.get("overdueVal"); let result = await Meteor.call(methodName, timeFrame); diff --git a/client/AdminMgmt/ProductMgmt/prodMgmtForm.html b/client/AdminMgmt/ProductMgmt/prodMgmtForm.html index 357b19c..3a6ff9c 100644 --- a/client/AdminMgmt/ProductMgmt/prodMgmtForm.html +++ b/client/AdminMgmt/ProductMgmt/prodMgmtForm.html @@ -2,14 +2,22 @@

Product Management

{{#if Template.subscriptionsReady}}
-
-

- -

-
+
+

+ +

+
+
+

+ +

+
diff --git a/client/AdminMgmt/ProductMgmt/prodMgmtForm.js b/client/AdminMgmt/ProductMgmt/prodMgmtForm.js index cb5fc18..f0c2a2d 100644 --- a/client/AdminMgmt/ProductMgmt/prodMgmtForm.js +++ b/client/AdminMgmt/ProductMgmt/prodMgmtForm.js @@ -60,6 +60,14 @@ Template.prodMgmtForm.events({ Session.set("noStoreSet", false); } }, + 'click #showNoList' (event) { + let notUsedInList = $("#showNoList").prop('checked'); + if (notUsedInList == true) { + Session.set("noListUsed", true); + } else { + Session.set("noListUsed", false); + } + }, 'submit .prodInputForm' (event) { }, diff --git a/client/AdminMgmt/ProductMgmt/prodMgmtTbl.js b/client/AdminMgmt/ProductMgmt/prodMgmtTbl.js index cf49c52..48dfee1 100644 --- a/client/AdminMgmt/ProductMgmt/prodMgmtTbl.js +++ b/client/AdminMgmt/ProductMgmt/prodMgmtTbl.js @@ -1,14 +1,17 @@ import { Products } from '../../../imports/api/products.js'; +import { ListItems } from '../../../imports/api/listItems.js'; import { M } from '../../lib/assets/materialize.js'; Template.prodMgmtTbl.onCreated(function() { this.subscribe("myProducts"); + this.subscribe("allListItems"); }); Template.prodMgmtTbl.onRendered(function() { Session.set("searchProds", false); Session.set("searchStore", false); Session.set("noStoreSet", false); + Session.set("noListUsed", false); }); Template.prodMgmtTbl.helpers({ @@ -16,6 +19,7 @@ Template.prodMgmtTbl.helpers({ let searchProd = Session.get("searchProds"); let searchStore = Session.get("searchStore"); let noStoreSet = Session.get("noStoreSet"); + let noListUsed = Session.get("noListUsed"); if (searchProd == true) { let searchVal = Session.get("searchVal"); @@ -33,6 +37,20 @@ Template.prodMgmtTbl.helpers({ } } else if (noStoreSet == true) { return Products.find({ prodStore: '' }, { sort: { prodName: 1 }}); + } else if (noListUsed == true) { + let i; + let idList = []; + let idsInLists = ListItems.find({}).fetch(); + for (i=0; i < idsInLists.length; i++) { + // console.log(idsInList[i]); + idList.push(idsInLists[i].prodId); + } + if (i > idsInLists.length - 1) { + console.dir(idList); + let noProdsNot = Products.find({ _id: { $nin: idList }}).count(); + console.log(noProdsNot); + return Products.find({ _id: { $nin: idList }}, { sort: { prodName: 1 }}); + } } else { return Products.find({}, { sort: { prodName: 1 }}); } diff --git a/imports/api/products.js b/imports/api/products.js index b8d5056..35e8206 100644 --- a/imports/api/products.js +++ b/imports/api/products.js @@ -63,5 +63,15 @@ Meteor.methods({ } return await Products.removeAsync({ _id: prodId }); + }, + async 'clean.Products' () { + if (!this.userId) { + throw new Meteor.Error('You are not allowed to delete products. Make sure you are logged in with valid user credentials.'); + } + + // first we need to find potential duplicate products + // next we need to see which of those are on incomplete lists + // Then we'll update those to use the main products ID instead + // finally we'll delete the duplicates } }); diff --git a/server/publish.js b/server/publish.js index c0f8072..61750dd 100644 --- a/server/publish.js +++ b/server/publish.js @@ -96,6 +96,14 @@ Meteor.publish("myListItems", function(listId) { } }); +Meteor.publish("allListItems", function() { + try { + return ListItems.find({}); + } catch (error) { + console.log(" ERROR pulling all list items."); + } +}); + Meteor.publish("myStoreListItems", function(listId) { try { let stores = Store.find({}); From 047befcae920bedb36f6ebd0ac8be9cbd8fa4b19 Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sat, 9 Aug 2025 07:24:54 -0500 Subject: [PATCH 5/6] Adjusted layout and removed logging --- client/AdminMgmt/ProductMgmt/prodMgmtForm.html | 4 ++-- client/AdminMgmt/ProductMgmt/prodMgmtTbl.js | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/client/AdminMgmt/ProductMgmt/prodMgmtForm.html b/client/AdminMgmt/ProductMgmt/prodMgmtForm.html index 3a6ff9c..7ebd800 100644 --- a/client/AdminMgmt/ProductMgmt/prodMgmtForm.html +++ b/client/AdminMgmt/ProductMgmt/prodMgmtForm.html @@ -2,7 +2,7 @@

Product Management

{{#if Template.subscriptionsReady}} -
+

-
+

  • My Lists
  • My Menus
  • My Tasks
  • -
  • My Settings
  • +
  • My Settings
  • {{#if isInRole "systemadmin"}}
  • Manage
  • {{/if}} @@ -30,7 +30,7 @@
  • My Lists
  • My Menus
  • My Tasks
  • -
  • My Settings
  • +
  • My Settings
  • {{#if isInRole 'systemadmin'}}
  • Manage
  • {{#if $eq updateExists true}} diff --git a/client/ListItems/listItemsTbl.js b/client/ListItems/listItemsTbl.js index 1ff8aae..4d04e18 100644 --- a/client/ListItems/listItemsTbl.js +++ b/client/ListItems/listItemsTbl.js @@ -62,13 +62,15 @@ Template.listItemsTbl.events({ }, 'click .markListItemReceived' (event) { event.preventDefault(); - Meteor.call('setReceived.listItem', this._id, function(err, result) { - if (err) { - // console.log(" ERROR setting item as received: " + err); + const setRcvd = async() => { + let result = await Meteor.callAsync('setReceived.listItem', this._id); + if (!result) { + // console.log("Item not marked properly - why?"); } else { - // console.log(" SUCCESS setting item received."); + // console.log("Item Marked Received."); } - }); + } + setRcvd(); }, 'click .deleteListItem' (event) { event.preventDefault(); diff --git a/imports/api/menuProdLinks.js b/imports/api/menuProdLinks.js index 70bded5..3dba4fc 100644 --- a/imports/api/menuProdLinks.js +++ b/imports/api/menuProdLinks.js @@ -52,6 +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.'); }; + console.log(" ---- Doing an Update instead! ---- "); return await MenuProdLinks.updateAsync({ menuItemId: menuItemId }, { $set: { products: prodNameArray, diff --git a/package-lock.json b/package-lock.json index 0d65189..a78ea76 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,9 +16,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.27.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.27.6.tgz", - "integrity": "sha512-vbavdySgbTTrmFE+EsiqUTzlOr5bzlnJtUv9PynGCAKvfQqjIXbvFdumPM/GxMDfyuGMJaJAU6TO4zc1Jf1i8Q==", + "version": "7.28.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.4.tgz", + "integrity": "sha512-Q/N6JNWvIvPnLDvjlE1OUBLPQHH6l3CltCEsHIujp45zQUSSh8K+gHnaEX45yAT1nyngnINhvWtzN+Nb9D8RAQ==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -109,9 +109,9 @@ "license": "MIT" }, "node_modules/meteor-node-stubs": { - "version": "1.2.19", - "resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.2.19.tgz", - "integrity": "sha512-lryhEAPp7aysrC0j3XU1yTs92ktPQQhzQzLVz3OGQEZjL//iLhvJyeYNSvV01XJn6fXUXe48agossxniJkzYOQ==", + "version": "1.2.24", + "resolved": "https://registry.npmjs.org/meteor-node-stubs/-/meteor-node-stubs-1.2.24.tgz", + "integrity": "sha512-tw9QzDFVOI5A5CcEw4tTD6CjF+Lk14uzhy2gWH5ImoH4mx4pyPVcha9MmyVur+rEVgpzk+aMG6rs3RxAF9SwiA==", "bundleDependencies": [ "@meteorjs/crypto-browserify", "assert", @@ -154,6 +154,7 @@ "punycode": "^1.4.1", "querystring-es3": "^0.2.1", "readable-stream": "^3.6.2", + "sha.js": "^2.4.12", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", "string_decoder": "^1.3.0", @@ -188,6 +189,11 @@ "node": ">= 0.12" } }, + "node_modules/meteor-node-stubs/node_modules/@meteorjs/browserify-sign/node_modules/isarray": { + "version": "1.0.0", + "inBundle": true, + "license": "MIT" + }, "node_modules/meteor-node-stubs/node_modules/@meteorjs/browserify-sign/node_modules/readable-stream": { "version": "2.3.8", "inBundle": true, @@ -906,7 +912,7 @@ } }, "node_modules/meteor-node-stubs/node_modules/isarray": { - "version": "1.0.0", + "version": "2.0.5", "inBundle": true, "license": "MIT" }, @@ -1040,20 +1046,49 @@ "license": "MIT" }, "node_modules/meteor-node-stubs/node_modules/pbkdf2": { - "version": "3.1.2", + "version": "3.1.3", "inBundle": true, "license": "MIT", "dependencies": { - "create-hash": "^1.1.2", - "create-hmac": "^1.1.4", - "ripemd160": "^2.0.1", - "safe-buffer": "^5.0.1", - "sha.js": "^2.4.8" + "create-hash": "~1.1.3", + "create-hmac": "^1.1.7", + "ripemd160": "=2.0.1", + "safe-buffer": "^5.2.1", + "sha.js": "^2.4.11", + "to-buffer": "^1.2.0" }, "engines": { "node": ">=0.12" } }, + "node_modules/meteor-node-stubs/node_modules/pbkdf2/node_modules/create-hash": { + "version": "1.1.3", + "inBundle": true, + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "sha.js": "^2.4.0" + } + }, + "node_modules/meteor-node-stubs/node_modules/pbkdf2/node_modules/hash-base": { + "version": "2.0.2", + "inBundle": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.1" + } + }, + "node_modules/meteor-node-stubs/node_modules/pbkdf2/node_modules/ripemd160": { + "version": "2.0.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "hash-base": "^2.0.0", + "inherits": "^2.0.1" + } + }, "node_modules/meteor-node-stubs/node_modules/possible-typed-array-names": { "version": "1.1.0", "inBundle": true, @@ -1215,15 +1250,22 @@ "license": "MIT" }, "node_modules/meteor-node-stubs/node_modules/sha.js": { - "version": "2.4.11", + "version": "2.4.12", "inBundle": true, "license": "(MIT AND BSD-3-Clause)", "dependencies": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1", + "to-buffer": "^1.2.0" }, "bin": { "sha.js": "bin.js" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/meteor-node-stubs/node_modules/side-channel": { @@ -1333,11 +1375,37 @@ "node": ">=0.6.0" } }, + "node_modules/meteor-node-stubs/node_modules/to-buffer": { + "version": "1.2.1", + "inBundle": true, + "license": "MIT", + "dependencies": { + "isarray": "^2.0.5", + "safe-buffer": "^5.2.1", + "typed-array-buffer": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/meteor-node-stubs/node_modules/tty-browserify": { "version": "0.0.1", "inBundle": true, "license": "MIT" }, + "node_modules/meteor-node-stubs/node_modules/typed-array-buffer": { + "version": "1.0.3", + "inBundle": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/meteor-node-stubs/node_modules/url": { "version": "0.11.4", "inBundle": true, diff --git a/server/publish.js b/server/publish.js index 61750dd..57e5e13 100644 --- a/server/publish.js +++ b/server/publish.js @@ -30,7 +30,7 @@ Meteor.publish("SystemConfig", function() { Meteor.publish("UserConfigPrefs", function() { try { - return UserConfig.find({}); + return UserConfig.find({ user: this.userId }); } catch (error) { console.log(" ERROR: Error accessing user config: " + error); }