Cleaning up type ahead

This commit is contained in:
Brian McGonagill 2024-07-07 18:59:40 -05:00
parent cba5026ee4
commit dbd945391d
4 changed files with 11 additions and 14 deletions

View file

@ -20,7 +20,7 @@
<i class="material-icons clickable" id="filterOff">clear</i>
{{/if}}
</div>
<div class="col s10 m11 l11">
<div class="col s4 m3 l3">
Filter LIst
</div>
</div>
@ -35,11 +35,11 @@
</div>
{{else}}
<div class="row">
<div class="col s9 m10 l10 input-field">
<input type="text" class="autocomplete" id="findListItems" />
<div class="col s8 m9 l10 input-field">
<input type="text" class="autocomplete" id="findListItems" autocomplete="off" />
<label for="findListItems">Item...</label>
</div>
<div class="col s3 m2 l2">
<div class="col s4 m3 l2">
<a class="waves-effect waves-light btn saveListItem green right">Add</a>
</div>
</div>

View file

@ -19,6 +19,7 @@ Template.listItemsForm.onRendered(function() {
Session.set("itemReqErr", false);
Session.set("showReceivedItems", false);
Session.set("filtering", false);
Session.set("findListItems", {});
this.autorun(() => {
$('input.autocomplete').autocomplete({
data: Session.get("findListItems"),
@ -96,17 +97,21 @@ Template.listItemsForm.events({
if (event.which !== 13) {
let listItemObj = {};
let findItemVal = $("#findListItems").val();
console.log("Should start showing options now...");
Session.set("listItemVal", findItemVal);
let listItemInfo = Products.find({ prodName: {$regex: findItemVal + '.*', $options: 'i'}}, { limit: 5 }).fetch();
if (typeof listItemInfo != 'undefined' && listItemInfo != "" && listItemInfo != null) {
// console.log(" listItemInfo: ");
// console.dir(listItemInfo);
for (i=0; i < listItemInfo.length; i++) {
let item = listItemInfo[i].prodName;
let store = listItemInfo[i].prodStore;
listItemObj[item] = store;
}
}
Session.set("findListItems", listItemObj);
}
}
},
'click #filterOn' (event) {
event.preventDefault();

View file

@ -25,7 +25,7 @@ Template.listsTbl.events({
if (listId == "addList") {
$('#modalList').modal('open');
} else {
console.log("listId is: " + listId);
// console.log("listId is: " + listId);
Session.set("listId", listId);
Meteor.setTimeout(function() {
FlowRouter.go('/listitems');

View file

@ -37,14 +37,6 @@ Meteor.publish("myProducts", function() {
}
});
Meteor.publish("listProducts", function(itemNameListing) {
try {
return Products.find({ itemName: {$regex: itemNameListing + '.*', $options: 'i'}}, { limit: 5 });
} catch (error) {
console.log(" ERROR pulling items by filtered item name: " + error);
}
});
Meteor.publish("myLists", function() {
try {
return Lists.find( { $or: [ { listOwner: this.userId, listComplete: false }, { listShared: true, listComplete: false } ] } );