fixed mysterious invalid search error that should not display in picklist during testing

This commit is contained in:
2020-04-05 17:45:01 +00:00
parent 0a315b4d57
commit 6c986ee0a3

View File

@@ -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;
}