fixed mysterious invalid search error that should not display in picklist during testing
This commit is contained in:
@@ -83,17 +83,11 @@ export default {
|
|||||||
//clear any local errors
|
//clear any local errors
|
||||||
vm.clearErrors();
|
vm.clearErrors();
|
||||||
//if the search entry is in the results list then it's a drop down selection not a typed search so bail
|
//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++) {
|
for (let i = 0; i < vm.searchResults.length; i++) {
|
||||||
if (vm.searchResults[i].name == val) {
|
if (vm.searchResults[i].name == val) {
|
||||||
console.log("Yes, match, bail no search");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log("past entry check, maybe search?");
|
|
||||||
if (!val || vm.fetching || !vm.initialized) {
|
if (!val || vm.fetching || !vm.initialized) {
|
||||||
if (!vm.initialized) {
|
if (!vm.initialized) {
|
||||||
vm.$nextTick(() => {
|
vm.$nextTick(() => {
|
||||||
@@ -102,9 +96,8 @@ export default {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("watch::searchentry - calling do search on :", val);
|
|
||||||
|
|
||||||
this.doSearch();
|
this.doSearch(val);
|
||||||
},
|
},
|
||||||
errors(val) {
|
errors(val) {
|
||||||
if (this.hasError()) {
|
if (this.hasError()) {
|
||||||
@@ -270,34 +263,33 @@ export default {
|
|||||||
vm.fetching = false;
|
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
|
//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
|
//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 isATwoTermQuery = false;
|
||||||
let queryTerms = [];
|
let queryTerms = [];
|
||||||
//NOTE: empty query is valid; it means get the top 100 ordered by template order
|
//NOTE: empty query is valid; it means get the top 100 ordered by template order
|
||||||
let emptyQuery = false;
|
let emptyQuery = false;
|
||||||
if (this.searchEntry == null || this.searchEntry == "") {
|
if (searchFor == null || searchFor == "") {
|
||||||
emptyQuery = true;
|
emptyQuery = true;
|
||||||
} else {
|
} else {
|
||||||
//Pre-process the query to validate and send conditionally
|
//Pre-process the query to validate and send conditionally
|
||||||
let val = this.searchEntry;
|
|
||||||
//get the discrete search terms and verify there are max two
|
//get the discrete search terms and verify there are max two
|
||||||
|
|
||||||
if (val.includes(" ")) {
|
if (searchFor.includes(" ")) {
|
||||||
queryTerms = val.split(" ");
|
queryTerms = searchFor.split(" ");
|
||||||
if (queryTerms.length > 2) {
|
if (queryTerms.length > 2) {
|
||||||
console.log("Query invalid 1");
|
|
||||||
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isATwoTermQuery = true;
|
isATwoTermQuery = true;
|
||||||
} else {
|
} else {
|
||||||
//one term only so push it into array
|
//one term only so push it into array
|
||||||
queryTerms.push(val);
|
queryTerms.push(searchEntered);
|
||||||
//Marker term, will be weeded back out later
|
//Marker term, will be weeded back out later
|
||||||
queryTerms.push("[?]");
|
queryTerms.push("[?]");
|
||||||
}
|
}
|
||||||
@@ -326,7 +318,6 @@ export default {
|
|||||||
window.$gz._.startsWith(queryTerms[0], "..") &&
|
window.$gz._.startsWith(queryTerms[0], "..") &&
|
||||||
window.$gz._.startsWith(queryTerms[1], "..")
|
window.$gz._.startsWith(queryTerms[1], "..")
|
||||||
) {
|
) {
|
||||||
console.log("Query invalid 2");
|
|
||||||
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -336,7 +327,6 @@ export default {
|
|||||||
!window.$gz._.startsWith(queryTerms[0], "..") &&
|
!window.$gz._.startsWith(queryTerms[0], "..") &&
|
||||||
!window.$gz._.startsWith(queryTerms[1], "..")
|
!window.$gz._.startsWith(queryTerms[1], "..")
|
||||||
) {
|
) {
|
||||||
console.log("Query invalid 3");
|
|
||||||
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
vm.errors.push(vm.$ay.t("ErrorPickListQueryInvalid"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user