From 6c986ee0a35bc61892c2c3505938e36c0cfb87fc Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 5 Apr 2020 17:45:01 +0000 Subject: [PATCH] fixed mysterious invalid search error that should not display in picklist during testing --- ayanova/src/components/pick-list.vue | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/ayanova/src/components/pick-list.vue b/ayanova/src/components/pick-list.vue index 4ae818cb..4de0feb8 100644 --- a/ayanova/src/components/pick-list.vue +++ b/ayanova/src/components/pick-list.vue @@ -83,17 +83,11 @@ export default { //clear any local errors vm.clearErrors(); //if the search entry is in the results list then it's a drop down selection not a typed search so bail - console.log( - "watch searchentry checking if search or selection for entry:", - val - ); for (let i = 0; i < vm.searchResults.length; i++) { if (vm.searchResults[i].name == val) { - console.log("Yes, match, bail no search"); return; } } - console.log("past entry check, maybe search?"); if (!val || vm.fetching || !vm.initialized) { if (!vm.initialized) { vm.$nextTick(() => { @@ -102,9 +96,8 @@ export default { } return; } - console.log("watch::searchentry - calling do search on :", val); - this.doSearch(); + this.doSearch(val); }, errors(val) { if (this.hasError()) { @@ -270,34 +263,33 @@ export default { vm.fetching = false; }); }, - doSearch: _.debounce(function() { + doSearch: _.debounce(function(searchFor) { //NOTE debounce with a watcher is a bit different, currently it has to be done exactly this way, nothing else will work properly //https://vuejs.org/v2/guide/migration.html#debounce-Param-Attribute-for-v-model-removed //----------------- - console.log("doSearch top, search for:", vm.searchEntry); - let vm = this; + + let vm = this; let isATwoTermQuery = false; let queryTerms = []; //NOTE: empty query is valid; it means get the top 100 ordered by template order let emptyQuery = false; - if (this.searchEntry == null || this.searchEntry == "") { + if (searchFor == null || searchFor == "") { emptyQuery = true; } else { //Pre-process the query to validate and send conditionally - let val = this.searchEntry; + //get the discrete search terms and verify there are max two - if (val.includes(" ")) { - queryTerms = val.split(" "); + if (searchFor.includes(" ")) { + queryTerms = searchFor.split(" "); if (queryTerms.length > 2) { - console.log("Query invalid 1"); vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid")); return; } isATwoTermQuery = true; } else { //one term only so push it into array - queryTerms.push(val); + queryTerms.push(searchEntered); //Marker term, will be weeded back out later queryTerms.push("[?]"); } @@ -326,7 +318,6 @@ export default { window.$gz._.startsWith(queryTerms[0], "..") && window.$gz._.startsWith(queryTerms[1], "..") ) { - console.log("Query invalid 2"); vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid")); return; } @@ -336,7 +327,6 @@ export default { !window.$gz._.startsWith(queryTerms[0], "..") && !window.$gz._.startsWith(queryTerms[1], "..") ) { - console.log("Query invalid 3"); vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid")); return; }