mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Added filtering to the Store column in Product management
This commit is contained in:
parent
c4123ce6da
commit
de1ca5bace
2 changed files with 46 additions and 6 deletions
|
|
@ -7,20 +7,38 @@ Template.prodMgmtTbl.onCreated(function() {
|
|||
|
||||
Template.prodMgmtTbl.onRendered(function() {
|
||||
Session.set("searchProds", false);
|
||||
Session.set("searchStore", false);
|
||||
});
|
||||
|
||||
Template.prodMgmtTbl.helpers({
|
||||
products: function() {
|
||||
let searchVal = Session.get("searchVal");
|
||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
||||
return Products.find({});
|
||||
let searchProd = Session.get("searchProds");
|
||||
let searchStore = Session.get("searchStore");
|
||||
|
||||
if (searchProd == true) {
|
||||
let searchVal = Session.get("searchVal");
|
||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
||||
return Products.find({});
|
||||
} else {
|
||||
return Products.find({ prodName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
}
|
||||
} else if (searchStore == true) {
|
||||
let searchVal = Session.get("searchStoreVal");
|
||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
||||
return Products.find({});
|
||||
} else {
|
||||
return Products.find({ prodStore: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
}
|
||||
} else {
|
||||
return Products.find({ prodName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
return Products.find({});
|
||||
}
|
||||
},
|
||||
searchProd: function() {
|
||||
return Session.get("searchProds");
|
||||
}
|
||||
},
|
||||
searchStore: function() {
|
||||
return Session.get("searchStore");
|
||||
},
|
||||
});
|
||||
|
||||
Template.prodMgmtTbl.events({
|
||||
|
|
@ -53,5 +71,19 @@ Template.prodMgmtTbl.events({
|
|||
let searchVal = $("#searchProds").val();
|
||||
Session.set("searchVal", searchVal);
|
||||
}
|
||||
},
|
||||
'click #filterStore' (event) {
|
||||
event.preventDefault();
|
||||
Session.set("searchStore", true);
|
||||
},
|
||||
'click #closeStoreFilter' (event) {
|
||||
event.preventDefault();
|
||||
Session.set("searchStore", false);
|
||||
},
|
||||
'keyup #searchStore' (event) {
|
||||
if (event.which !== 13) {
|
||||
let searchVal = $("#searchStore").val();
|
||||
Session.set("searchStoreVal", searchVal);
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue