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>
{{#if Template.subscriptionsReady}}
<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">
<input type="text" class="prodName" style="{{#if $eq prodNameErr true}}border: 2px solid red;{{/if}}" id="prodName" />
<label for="prodName">Name*</label>
@ -37,4 +45,4 @@
</div>
</div>
{{> snackbar}}
</template>
</template>

View file

@ -136,4 +136,13 @@ Template.prodMgmtForm.events({
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() {
Session.set("searchProds", false);
Session.set("searchStore", false);
Session.set("noStoreSet", false);
});
Template.prodMgmtTbl.helpers({
products: function() {
let searchProd = Session.get("searchProds");
let searchStore = Session.get("searchStore");
let noStoreSet = Session.get("noStoreSet");
if (searchProd == true) {
let searchVal = Session.get("searchVal");
@ -29,6 +31,8 @@ Template.prodMgmtTbl.helpers({
} else {
return Products.find({ prodStore: { $regex: searchVal + '.*', $options: 'i' } });
}
} else if (noStoreSet == true) {
return Products.find({ prodStore: '' });
} else {
return Products.find({});
}
@ -86,4 +90,4 @@ Template.prodMgmtTbl.events({
Session.set("searchStoreVal", searchVal);
}
}
});
});

View file

@ -17,15 +17,15 @@ Meteor.startup(() => {
allowReg: true,
});
} 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)
let itemInfoNoLink = MenuItems.find({ isLinked: { $exists: false } }).fetch();
console.log("No Ites with isLinked not set: " + itemInfoNoLink.length);
if (itemInfoNoLink.length > 0) {
console.log("found items with isLinked not set.");
console.dir(itemInfoNoLink);
// console.log("found items with isLinked not set.");
// console.dir(itemInfoNoLink);
let infoLength = itemInfoNoLink.length;
for (i=0; i < infoLength; i++) {
MenuItems.update({ _id: itemInfoNoLink[i]._id }, {
@ -36,7 +36,7 @@ Meteor.startup(() => {
}
} else {
// 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) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
console.log(" SUCCESSFULLY set user dark mode preference.");
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
} else if (countOfUsers == 1) {
@ -27,7 +27,7 @@ Meteor.methods({
if (err) {
console.log(" ERROR: can't set user dark mode preference: " + err);
} else {
console.log(" SUCCESSFULLY set user dark mode preference.");
// console.log(" SUCCESSFULLY set user dark mode preference.");
}
});
}
@ -59,4 +59,4 @@ Meteor.methods({
return Roles.setUserRoles(userId, role);
},
});
});