From 88b77985944c2aec3ff67bab53da19f75e38dd82 Mon Sep 17 00:00:00 2001 From: Esme Rubinstein <51678367+erubinst@users.noreply.github.com> Date: Wed, 17 Apr 2024 09:38:06 -0400 Subject: [PATCH] fixing edi transaction reinstate filter to adjust pagination with click (#194) --- .../edi_transaction_sets_controller.rb | 10 ++++++++-- .../edi_transaction_sets/errors.html.haml | 19 +------------------ app/views/shared/_search.html.erb | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/controllers/edi_transaction_sets_controller.rb b/app/controllers/edi_transaction_sets_controller.rb index 6644d5ef7..cfcde3613 100644 --- a/app/controllers/edi_transaction_sets_controller.rb +++ b/app/controllers/edi_transaction_sets_controller.rb @@ -15,8 +15,14 @@ def errors @carrier = Carrier.find(params['carrier']) if params['carrier'].present? @to_date = (params["to_date"] || Date.today).to_date @from_date = (params["from_date"] || Date.new(2014,1,1)).to_date > @to_date ? @to_date : (params["from_date"] || Date.new(2014,1,1)).to_date - @result_set = Protocols::X12::TransactionSetEnrollment.where("error_list" => {"$exists" => true, "$not" => {"$size" => 0}}, - "submitted_at" => (@from_date.beginning_of_day..@to_date.end_of_day)).search({search_string: @q, carrier: @carrier}) + @show_reinstates = params["show_reinstates"] || 0 + @result_set = if params[:show_reinstates].present? + Protocols::X12::TransactionSetEnrollment.where("error_list" => { "$exists" => true, "$not" => { "$size" => 0 } }, + "submitted_at" => (@from_date.beginning_of_day..@to_date.end_of_day)).search({ search_string: @q, carrier: @carrier }) + else + Protocols::X12::TransactionSetEnrollment.where("error_list" => { "$exists" => true, "$not" => { "$size" => 0 }, "$nin" => [/inbound reinstatements are blocked for legacy imports/] }, + "submitted_at" => (@from_date.beginning_of_day..@to_date.end_of_day)).search({ search_string: @q, carrier: @carrier }) + end @transactions = @result_set.page(params[:page]).per(15) authorize! params, @transactions || Protocols::X12::TransactionSetEnrollment end diff --git a/app/views/edi_transaction_sets/errors.html.haml b/app/views/edi_transaction_sets/errors.html.haml index 035cf68d3..aee5fbced 100644 --- a/app/views/edi_transaction_sets/errors.html.haml +++ b/app/views/edi_transaction_sets/errors.html.haml @@ -1,8 +1,6 @@ .row .col-md-offset-1.col-md-10 - = render 'shared/search', url: errors_edi_transaction_sets_path, q: @q, range_search: true, carriers: @carriers, carrier: @carrier, from_date: @from_date, to_date: @to_date, placeholder: "Error List, Policy ID" - - %input#erroCheckbox{:onclick => "errorMessage()", :type => "checkbox"}Show Reinstate error messages + = render 'shared/search', url: errors_edi_transaction_sets_path, show_reinstates: @show_reinstates, q: @q, range_search: true, carriers: @carriers, carrier: @carrier, from_date: @from_date, to_date: @to_date, placeholder: "Error List, Policy ID" %table.table.margin-top-error.table-condensed %thead @@ -45,19 +43,4 @@ %small (transactions selected / total) :javascript - $(document).ready( function () { - errorMessage(); - }); - function errorMessage() { - var error_lists = document.getElementsByClassName("error-list"); - for (var i = 0; i < error_lists.length; i++) { - if(error_lists[i].innerText.includes('inbound reinstatements are blocked for legacy imports')){ - if(document.getElementById('erroCheckbox').checked == true) { - error_lists[i].style.display = 'table-row'; - }else{ - error_lists[i].style.display = 'none'; - } - } - } - } diff --git a/app/views/shared/_search.html.erb b/app/views/shared/_search.html.erb index 4e744c603..9d39b6d10 100644 --- a/app/views/shared/_search.html.erb +++ b/app/views/shared/_search.html.erb @@ -1,4 +1,4 @@ -<%= form_tag url, { method: :get, class: "form form-inline", role: "search"} do %> +<%= form_tag url, { method: :get, class: "form form-inline", role: "search", id: "search_form"} do %>
<% if local_assigns[:range_search] %> <%= label_tag :from, "From:" %> @@ -25,8 +25,21 @@
<% end %> + <% if local_assigns[:show_reinstates] %> +
+ <%= check_box_tag :show_reinstates, 1, local_assigns[:show_reinstates].to_i == 1, class: "checkbox", onchange: "submitForm();" %> + <%= label_tag :show_reinstates, "Show Reinstate error messages" %> +
+ <% end %> + <%= label_tag :q, "Search term", {class: "sr-only"} %> <%= text_field_tag :q, q, {placeholder: placeholder, class: "form-control", style: "width: 250px;"} %> <%= submit_tag "Search", { class: "btn btn-primary" } %> <% end %> + +