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
|
|
@ -13,7 +13,15 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</th>
|
</th>
|
||||||
<th>Store</th>
|
<th>
|
||||||
|
{{#if $eq searchStore false}}
|
||||||
|
Store <i class="material-icons clickable right" id="filterStore">search</i>
|
||||||
|
{{else}}
|
||||||
|
<div style="width: 100%;">
|
||||||
|
<input type="text" class="searchStore" id="searchStore" style="width: 85%;" /> <i class="material-icons clickable" id="closeStoreFilter">close</i>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,38 @@ Template.prodMgmtTbl.onCreated(function() {
|
||||||
|
|
||||||
Template.prodMgmtTbl.onRendered(function() {
|
Template.prodMgmtTbl.onRendered(function() {
|
||||||
Session.set("searchProds", false);
|
Session.set("searchProds", false);
|
||||||
|
Session.set("searchStore", false);
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.prodMgmtTbl.helpers({
|
Template.prodMgmtTbl.helpers({
|
||||||
products: function() {
|
products: function() {
|
||||||
let searchVal = Session.get("searchVal");
|
let searchProd = Session.get("searchProds");
|
||||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
let searchStore = Session.get("searchStore");
|
||||||
return Products.find({});
|
|
||||||
|
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 {
|
} else {
|
||||||
return Products.find({ prodName: { $regex: searchVal + '.*', $options: 'i' } });
|
return Products.find({});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchProd: function() {
|
searchProd: function() {
|
||||||
return Session.get("searchProds");
|
return Session.get("searchProds");
|
||||||
}
|
},
|
||||||
|
searchStore: function() {
|
||||||
|
return Session.get("searchStore");
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.prodMgmtTbl.events({
|
Template.prodMgmtTbl.events({
|
||||||
|
|
@ -53,5 +71,19 @@ Template.prodMgmtTbl.events({
|
||||||
let searchVal = $("#searchProds").val();
|
let searchVal = $("#searchProds").val();
|
||||||
Session.set("searchVal", searchVal);
|
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