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);
}
}
});
});