aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzsloan2023-06-14 20:17:03 +0000
committerzsloan2023-06-14 20:25:35 +0000
commite15c81c7b3ea2ffc3650a637c913bd15b9206a67 (patch)
tree4c557eba7ba996c0cfbd6e900d7a3bb2cf531ecb
parentb05dd1c6a17a2889e4f3aeab20a7b24b09c83432 (diff)
downloadgenenetwork2-e15c81c7b3ea2ffc3650a637c913bd15b9206a67.tar.gz
Fix main search bug causing AND searches to no longer work
The cause of this bug is that, when the autocomplete feature was implemented, it checks the OR search field (in order to save its contents) and only submits the form if it isn't empty. This means that, if the user fills out the AND field and submits the form, nothing happens. I changed it to check both the AND and OR fields (and save both of their contents). While not perfect (since only one field is ever actually used), I figured it's best to just store everything (and there isn't really any way to know which search is intended when both fields are filled).
-rwxr-xr-xwqflask/wqflask/templates/index_page.html29
1 files changed, 18 insertions, 11 deletions
diff --git a/wqflask/wqflask/templates/index_page.html b/wqflask/wqflask/templates/index_page.html
index 12503326..a9908457 100755
--- a/wqflask/wqflask/templates/index_page.html
+++ b/wqflask/wqflask/templates/index_page.html
@@ -98,7 +98,7 @@
<div class="page-header">
<h2>Select and Search</h2>
</div>
- <form method="get" action="/search" target="_blank" id="gsearchform" name="SEARCHFORM",
+ <form method="get" action="/search" target="_blank" id="searchform" name="SEARCHFORM",
data-gn_server_url="{{gn_server_url}}">
<fieldset>
<div style="padding-left: 20px; padding-right: 20px;" class="form-horizontal">
@@ -175,8 +175,8 @@
<div class="form-group">
<label for="and_search" class="col-xs-1 control-label" style="padding-left: 0px; padding-right: 0px; width: 65px !important;">Combined:</label>
<div class="col-xs-10 controls" style="padding-left: 20px;">
- <div class="col-8">
- <textarea onkeydown="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="and_search"></textarea>
+ <div class="col-8 autocomplete">
+ <textarea id="myInput" onkeyup="pressed(event)" name="search_terms_and" rows="1" class="form-control search-query" style="resize: vertical; max-width: 550px; width: 450px !important;" id="and_search"></textarea>
</div>
</div>
</div>
@@ -336,15 +336,23 @@
<script type="text/javascript">
-$(document).on('submit', '#gsearchform', function(event){
+$(document).on('submit', '#searchform', function(event){
+
event.preventDefault()
- let user_search = $("#myInput").val().trim();
- if (user_search!=""){
- saveBeforeSubmit(user_search)
- $( "#gsearchform" )[0].submit();
- }
+ let user_searches = [];
+ $(".search-query").each(function() {
+ this_search = $(this).val().trim();
+ if (this_search != ""){
+ user_searches.push(this_search);
+ }
+ });
+
+ for (i=0; i<user_searches.length; ++i){
+ saveBeforeSubmit(user_searches[i])
+ }
+ $( "#searchform" )[0].submit();
- });
+});
</script>
<script>
@@ -357,7 +365,6 @@ $(document).on('submit', '#gsearchform', function(event){
if( event.target.value.trim() != "" ) {
saveBeforeSubmit(event.target.value.trim())
- //document.forms[1].submit();
$("#searchform")[0].submit();
}