mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Added filtering option to Lists and Products views.
This commit is contained in:
parent
0768e707b8
commit
7641b17e6f
6 changed files with 208 additions and 20 deletions
|
|
@ -1,17 +1,39 @@
|
|||
<template name="listItemsForm">
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<h4>{{selListName}}</h4>
|
||||
<div class="col s6 center">
|
||||
<h5>{{selListName}}</h5>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<p>
|
||||
<label>
|
||||
<input type="checkbox" id="showReceivedItems" />
|
||||
<span>Show Recv'd</span>
|
||||
</label>
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<p>
|
||||
<label>
|
||||
<input type="checkbox" id="showReceivedItems" />
|
||||
<span>Show Recv'd</span>
|
||||
</label>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col s2 m1 l1">
|
||||
{{#if $eq filtering false}}
|
||||
<i class="material-icons clickable" id="filterOn">filter_list</i>
|
||||
{{else}}
|
||||
<i class="material-icons clickable" id="filterOff">clear</i>
|
||||
{{/if}}
|
||||
</div>
|
||||
<div class="col s10 m11 l11">
|
||||
Filter LIst
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#if $eq filtering true}}
|
||||
<div class="row">
|
||||
<div class="col s8 input-field">
|
||||
<input type="text" class="searchListItems" id="searchListItems" />
|
||||
<label for="searchlistItems">Filter</label>
|
||||
</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="row">
|
||||
<div class="col s9 m10 l10">
|
||||
<input list="listItemsData" name="listItems" id="listItems">
|
||||
|
|
@ -23,11 +45,8 @@
|
|||
</datalist>
|
||||
</div>
|
||||
<div class="col s3 m2 l2">
|
||||
{{#if $eq editMode false}}
|
||||
<a class="waves-effect waves-light btn saveListItem green right">Add</a>
|
||||
{{else}}
|
||||
<a class="waves-effect waves-light btn renameListItem blue right">Rename</a>
|
||||
{{/if}}
|
||||
<a class="waves-effect waves-light btn saveListItem green right">Add</a>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
</template>
|
||||
|
|
@ -16,6 +16,7 @@ Template.listItemsForm.onRendered(function() {
|
|||
Session.set("listItemEditMode", false);
|
||||
Session.set("itemReqErr", false);
|
||||
Session.set("showReceivedItems", false);
|
||||
Session.set("filtering", false);
|
||||
});
|
||||
|
||||
Template.listItemsForm.helpers({
|
||||
|
|
@ -30,6 +31,9 @@ Template.listItemsForm.helpers({
|
|||
},
|
||||
editMode: function() {
|
||||
return Session.get("listItemEditMode");
|
||||
},
|
||||
filtering: function() {
|
||||
return Session.get("filtering");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -75,5 +79,19 @@ Template.listItemsForm.events({
|
|||
} else {
|
||||
Session.set("showReceivedItems", false);
|
||||
}
|
||||
},
|
||||
'keyup #searchListItems' (event) {
|
||||
if (event.which !== 13) {
|
||||
let searchVal = $("#searchListItems").val();
|
||||
Session.set("searchVal", searchVal);
|
||||
}
|
||||
},
|
||||
'click #filterOn' (event) {
|
||||
event.preventDefault();
|
||||
Session.set("filtering", true);
|
||||
},
|
||||
'click #filterOff' (event) {
|
||||
event.preventDefault();
|
||||
Session.set("filtering", false);
|
||||
}
|
||||
});
|
||||
|
|
@ -8,16 +8,25 @@ Template.listItemsTbl.onCreated(function() {
|
|||
|
||||
Template.listItemsTbl.onRendered(function() {
|
||||
Session.set("showReceivedItems", false);
|
||||
Session.set("searchVal", "");
|
||||
});
|
||||
|
||||
Template.listItemsTbl.helpers({
|
||||
'thisListItems': function() {
|
||||
let showRecvd = Session.get("showReceivedItems");
|
||||
console.log("Show Received is: " + showRecvd);
|
||||
let searchVal = Session.get("searchVal");;
|
||||
if (showRecvd == false) {
|
||||
return ListItems.find({ itemReceived: false });
|
||||
if (typeof searchVal == 'undefined' || searchVal.length === 0) {
|
||||
return ListItems.find({ itemReceived: false });
|
||||
} else {
|
||||
return ListItems.find({ itemReceived: false, itemName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
}
|
||||
} else {
|
||||
return ListItems.find({});
|
||||
if (typeof searchVal == 'undefined' || searchVal.length == 0) {
|
||||
return ListItems.find({});
|
||||
} else {
|
||||
return ListItems.find({ itemName: { $regex: searchVal + '.*', $options: 'i' } });
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
@ -63,5 +72,5 @@ Template.listItemsTbl.events({
|
|||
console.log(" SUCCESS deleting the list item.");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue