Updated to filter Products when no store is assigned.

This commit is contained in:
Brian McGonagill 2024-08-09 12:03:49 -05:00
parent d0398ddc32
commit a7a9c48e01
5 changed files with 31 additions and 10 deletions

View file

@ -2,6 +2,14 @@
<h4>Product Management</h4> <h4>Product Management</h4>
{{#if Template.subscriptionsReady}} {{#if Template.subscriptionsReady}}
<form action="submit" class="row prodInputForm" style="gap: 1em;"> <form action="submit" class="row prodInputForm" style="gap: 1em;">
<div class="col s12">
<p>
<label>
<input type="checkbox" id="showNoStoreSet" />
<span>Show Products without Store Assigned</span>
</label>
</p>
</div>
<div class="col s12 m6 l6 input-field outlined"> <div class="col s12 m6 l6 input-field outlined">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" /> <input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
<label for="prodName">Name*</label> <label for="prodName">Name*</label>

View file

@ -136,4 +136,13 @@ Template.prodMgmtForm.events({
storeModal.open(); storeModal.open();
} }
}, },
'click #showNoStoreSet' (event) {
let noStoreSet = $("#showNoStoreSet").prop('checked');
console.log("Clicked: " + noStoreSet);
if (noStoreSet == true) {
Session.set("noStoreSet", true);
} else {
Session.set("noStoreSet", false);
}
}
}); });

View file

@ -8,12 +8,14 @@ Template.prodMgmtTbl.onCreated(function() {
Template.prodMgmtTbl.onRendered(function() { Template.prodMgmtTbl.onRendered(function() {
Session.set("searchProds", false); Session.set("searchProds", false);
Session.set("searchStore", false); Session.set("searchStore", false);
Session.set("noStoreSet", false);
}); });
Template.prodMgmtTbl.helpers({ Template.prodMgmtTbl.helpers({
products: function() { products: function() {
let searchProd = Session.get("searchProds"); let searchProd = Session.get("searchProds");
let searchStore = Session.get("searchStore"); let searchStore = Session.get("searchStore");
let noStoreSet = Session.get("noStoreSet");
if (searchProd == true) { if (searchProd == true) {
let searchVal = Session.get("searchVal"); let searchVal = Session.get("searchVal");
@ -29,6 +31,8 @@ Template.prodMgmtTbl.helpers({
} else { } else {
return Products.find({ prodStore: { $regex: searchVal + '.*', $options: 'i' } }); return Products.find({ prodStore: { $regex: searchVal + '.*', $options: 'i' } });
} }
} else if (noStoreSet == true) {
return Products.find({ prodStore: '' });
} else { } else {
return Products.find({}); return Products.find({});
} }

View file

@ -17,15 +17,15 @@ Meteor.startup(() => {
allowReg: true, allowReg: true,
}); });
} else { } else {
console.log("Registration policy already set."); // console.log("Registration policy already set.");
} }
// check if the isLInked item exists on menuitems, and if not, add it (data cleanup task) // check if the isLInked item exists on menuitems, and if not, add it (data cleanup task)
let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch(); let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch();
console.log("No Ites with isLinked not set: " + itemInfoNoLink.length); console.log("No Ites with isLinked not set: " + itemInfoNoLink.length);
if (itemInfoNoLink.length > 0) { if (itemInfoNoLink.length > 0) {
console.log("found items with isLinked not set."); // console.log("found items with isLinked not set.");
console.dir(itemInfoNoLink); // console.dir(itemInfoNoLink);
let infoLength = itemInfoNoLink.length; let infoLength = itemInfoNoLink.length;
for (i=0; i < infoLength; i++) { for (i=0; i < infoLength; i++) {
MenuItems.update({ _id: itemInfoNoLink[i]._id }, { MenuItems.update({ _id: itemInfoNoLink[i]._id }, {
@ -36,7 +36,7 @@ Meteor.startup(() => {
} }
} else { } else {
// this will show if all items are found to have isLInked set. // this will show if all items are found to have isLInked set.
console.log("No itesm with isLinked not set."); // console.log("No itesm with isLinked not set.");
} }
}); });

View file

@ -16,7 +16,7 @@ Meteor.methods({
if (err) { if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {
console.log(" SUCCESSFULLY set user dark mode preference."); // console.log(" SUCCESSFULLY set user dark mode preference.");
} }
}); });
} else if (countOfUsers == 1) { } else if (countOfUsers == 1) {
@ -27,7 +27,7 @@ Meteor.methods({
if (err) { if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err); console.log(" ERROR: can't set user dark mode preference: " + err);
} else { } else {
console.log(" SUCCESSFULLY set user dark mode preference."); // console.log(" SUCCESSFULLY set user dark mode preference.");
} }
}); });
} }