Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(case_contact): fixed the order of case contacts #6148

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/javascript/src/case_contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ async function fireSwalFollowupAlert () {
})
}

$(document).on('turbo:load', function () {
$('.filter-form').on('change', '.filter-input', function () {
$(this).closest('form').submit()
})
})

$(() => { // JQuery's callback for the DOM loading
$('[data-toggle="tooltip"]').tooltip()
$('.followup-button').on('click', displayFollowupAlert)
Expand Down
21 changes: 9 additions & 12 deletions app/views/case_contacts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
</div>

<%= form_for_filterrific @filterrific, url: case_contacts_path, html: {class: "my-4"},
<%= form_for_filterrific @filterrific, url: case_contacts_path, html: {class: "my-4 filter-form"}, remote: true,
data: {turbo: true, turbo_frame: :case_contacts, turbo_action: :advance } do |f| %>
<%= hidden_field_tag 'casa_case_id', params[:casa_case_id] %>

Expand All @@ -38,18 +38,15 @@
<div class="select-style-1 mb-0">
<%= f.label :sorted_by %>
<div class="select-position">
<%= f.select(:sorted_by, @filterrific.select_options[:sorted_by], {}, {class: ""}) %>
<%= f.select(:sorted_by, @filterrific.select_options[:sorted_by], {}, {class: "filter-input"}) %>
</div>
</div>
<div class="form-check checkbox-style">
<%= f.check_box :no_drafts, class: "form-check-input case-contact-contact-type" %>
<%= f.check_box :no_drafts, class: "form-check-input case-contact-contact-type filter-input" %>
<label class="form-check-label" for="filterrific_no_drafts">Hide drafts</label>
</div>
</div>
<div>
<%= button_tag( :class=> "btn-sm main-btn dark-btn") do %>
<i class="lni lni-funnel mr-10"></i> Filter
<% end %>
<%= link_to("Reset filters", reset_filterrific_url,
class: "btn-sm main-btn dark-btn-outline btn-hove",
data: { turbo: true, turbo_frame: :case_contacts, turbo_action: :advance }) %>
Expand All @@ -65,11 +62,11 @@
</div>
<div class="col-sm-6 input-style-1">
<%= f.label "Starting from", for: "filterrific_occurred_starting_at" %>
<%= f.date_field(:occurred_starting_at, class: "") %>
<%= f.date_field(:occurred_starting_at, class: "filter-input") %>
</div>
<div class="col-sm-6 input-style-1">
<%= f.label "Ending at", for: "filterrific_occurred_ending_at" %>
<%= f.date_field(:occurred_ending_at, class: "") %>
<%= f.date_field(:occurred_ending_at, class: "filter-input") %>
</div>
</div>
<div class="row mb-4">
Expand All @@ -84,7 +81,7 @@
<div class="form-check checkbox-style">
<%=
f.check_box :contact_type,
{multiple: true, class: "form-check-input case-contact-contact-type"},
{multiple: true, class: "form-check-input case-contact-contact-type filter-input"},
contact_type.id,
nil
%>
Expand All @@ -107,21 +104,21 @@
<%= f.label :contact_medium %>
<div class="select-position">
<%= f.select(:contact_medium, options_from_collection_for_select(contact_mediums, "value", "label"),
{include_blank: "Display all"}) %>
{include_blank: "Display all", class: "filter-input"}) %>
</div>
</div>
<div class="col-md-3 select-style-1 pr-5">
<%= f.label :want_driving_reimbursement %>
<div class="select-position">
<%= f.select(:want_driving_reimbursement, @presenter.boolean_select_options,
{include_blank: "Display all"}) %>
{include_blank: "Display all", class: "filter-input"}) %>
</div>
</div>
<div class="col-md-3 select-style-1 pr-5">
<%= f.label :contact_made %>
<div class="select-position">
<%= f.select(:contact_made, @presenter.boolean_select_options,
{include_blank: "Display all"}) %>
{include_blank: "Display all", class: "filter-input"}) %>
</div>
</div>
</div>
Expand Down
14 changes: 3 additions & 11 deletions spec/system/case_contacts/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
end
end

describe "filtering case contacts" do
describe "automated filtering case contacts" do
describe "by date of contact" do
it "only shows the contacts with the correct date" do
yesterday = Time.zone.yesterday
Expand All @@ -88,8 +88,6 @@
fill_in "filterrific_occurred_starting_at", with: yesterday
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow

click_on "Filter"

expect(page).to have_no_content day_before_yesterday_display
expect(page).to have_content yesterday_display
expect(page).to have_content today_display
Expand Down Expand Up @@ -125,8 +123,6 @@

check "Hide drafts"

click_on "Filter"

expect(page).to have_no_content "Draft"
end
end
Expand All @@ -143,8 +139,6 @@
it "does not expand menu when filtering only by sticky filter" do
check "Hide drafts"

click_on "Filter"

expect(page).to have_field "Hide drafts", type: :checkbox
expect(page).to have_no_content "Other filters"
end
Expand All @@ -159,8 +153,6 @@
click_on "Expand / Hide"
select "In Person", from: "Contact medium"

click_on "Filter"

expect(page).to have_content "Other filters"
end
end
Expand Down Expand Up @@ -225,7 +217,7 @@
click_on "Expand / Hide"
fill_in "filterrific_occurred_starting_at", with: yesterday
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
click_on "Filter"

expect(page).to have_text("Case 2 Notes")
expect(page).to have_no_text("Case 1 Notes")

Expand All @@ -237,7 +229,7 @@
click_on "Expand / Hide"
fill_in "filterrific_occurred_starting_at", with: yesterday
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
click_on "Filter"

# no contacts because we're only showing case 1 and that occurred before the filter dates
expect(page).to have_no_text("Case 1 Notes")
expect(page).to have_no_text("Case 2 Notes")
Expand Down
Loading