Skip to content

Commit

Permalink
fixing edi transaction reinstate filter to adjust pagination with cli…
Browse files Browse the repository at this point in the history
…ck (#194)
  • Loading branch information
erubinst authored Apr 17, 2024
1 parent 1203bd5 commit 88b7798
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
10 changes: 8 additions & 2 deletions app/controllers/edi_transaction_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 1 addition & 18 deletions app/views/edi_transaction_sets/errors.html.haml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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';
}
}
}
}
15 changes: 14 additions & 1 deletion app/views/shared/_search.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
<div class="form-group">
<% if local_assigns[:range_search] %>
<%= label_tag :from, "From:" %>
Expand All @@ -25,8 +25,21 @@
</div>
<% end %>
<% if local_assigns[:show_reinstates] %>
<div class="col-sm-12">
<%= 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" %>
</div>
<% 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" } %>
</div>
<% end %>

<script>
function submitForm() {
document.getElementById("search_form").submit();
}
</script>

0 comments on commit 88b7798

Please sign in to comment.