From dbd945391d094518d5d5205c4d6b19eb18c377fb Mon Sep 17 00:00:00 2001 From: Brian McGonagill Date: Sun, 7 Jul 2024 18:59:40 -0500 Subject: [PATCH] Cleaning up type ahead --- client/ListItems/listItemsForm.html | 8 ++++---- client/ListItems/listItemsForm.js | 7 ++++++- client/Lists/listsTbl.js | 2 +- server/publish.js | 8 -------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/client/ListItems/listItemsForm.html b/client/ListItems/listItemsForm.html index 50089f9..24d7eb8 100644 --- a/client/ListItems/listItemsForm.html +++ b/client/ListItems/listItemsForm.html @@ -20,7 +20,7 @@ clear {{/if}} -
+
Filter LIst
@@ -35,11 +35,11 @@ {{else}}
-
- +
+
-
+
Add
diff --git a/client/ListItems/listItemsForm.js b/client/ListItems/listItemsForm.js index 9bd3a5b..c233a6f 100644 --- a/client/ListItems/listItemsForm.js +++ b/client/ListItems/listItemsForm.js @@ -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,16 +97,20 @@ 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); } - Session.set("findListItems", listItemObj); + } }, 'click #filterOn' (event) { diff --git a/client/Lists/listsTbl.js b/client/Lists/listsTbl.js index d0fa225..24c5ad9 100644 --- a/client/Lists/listsTbl.js +++ b/client/Lists/listsTbl.js @@ -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'); diff --git a/server/publish.js b/server/publish.js index c796d22..ad7e3c7 100644 --- a/server/publish.js +++ b/server/publish.js @@ -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 } ] } );