Skip to content

Commit 9a65487

Browse files
authored
Merge pull request #6148 from Raushan998/bug/case_contacts
bug(case_contact): fixed the order of case contacts
2 parents 24ebd5a + c9cc5e8 commit 9a65487

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

app/javascript/src/case_contact.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ async function fireSwalFollowupAlert () {
4242
})
4343
}
4444

45+
$(document).on('turbo:load', function () {
46+
$('.filter-form').on('change', '.filter-input', function () {
47+
$(this).closest('form').submit()
48+
})
49+
})
50+
4551
$(() => { // JQuery's callback for the DOM loading
4652
$('[data-toggle="tooltip"]').tooltip()
4753
$('.followup-button').on('click', displayFollowupAlert)

app/views/case_contacts/index.html.erb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</div>
1616
</div>
1717

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

@@ -38,18 +38,15 @@
3838
<div class="select-style-1 mb-0">
3939
<%= f.label :sorted_by %>
4040
<div class="select-position">
41-
<%= f.select(:sorted_by, @filterrific.select_options[:sorted_by], {}, {class: ""}) %>
41+
<%= f.select(:sorted_by, @filterrific.select_options[:sorted_by], {}, {class: "filter-input"}) %>
4242
</div>
4343
</div>
4444
<div class="form-check checkbox-style">
45-
<%= f.check_box :no_drafts, class: "form-check-input case-contact-contact-type" %>
45+
<%= f.check_box :no_drafts, class: "form-check-input case-contact-contact-type filter-input" %>
4646
<label class="form-check-label" for="filterrific_no_drafts">Hide drafts</label>
4747
</div>
4848
</div>
4949
<div>
50-
<%= button_tag( :class=> "btn-sm main-btn dark-btn") do %>
51-
<i class="lni lni-funnel mr-10"></i> Filter
52-
<% end %>
5350
<%= link_to("Reset filters", reset_filterrific_url,
5451
class: "btn-sm main-btn dark-btn-outline btn-hove",
5552
data: { turbo: true, turbo_frame: :case_contacts, turbo_action: :advance }) %>
@@ -65,11 +62,11 @@
6562
</div>
6663
<div class="col-sm-6 input-style-1">
6764
<%= f.label "Starting from", for: "filterrific_occurred_starting_at" %>
68-
<%= f.date_field(:occurred_starting_at, class: "") %>
65+
<%= f.date_field(:occurred_starting_at, class: "filter-input") %>
6966
</div>
7067
<div class="col-sm-6 input-style-1">
7168
<%= f.label "Ending at", for: "filterrific_occurred_ending_at" %>
72-
<%= f.date_field(:occurred_ending_at, class: "") %>
69+
<%= f.date_field(:occurred_ending_at, class: "filter-input") %>
7370
</div>
7471
</div>
7572
<div class="row mb-4">
@@ -84,7 +81,7 @@
8481
<div class="form-check checkbox-style">
8582
<%=
8683
f.check_box :contact_type,
87-
{multiple: true, class: "form-check-input case-contact-contact-type"},
84+
{multiple: true, class: "form-check-input case-contact-contact-type filter-input"},
8885
contact_type.id,
8986
nil
9087
%>
@@ -107,21 +104,21 @@
107104
<%= f.label :contact_medium %>
108105
<div class="select-position">
109106
<%= f.select(:contact_medium, options_from_collection_for_select(contact_mediums, "value", "label"),
110-
{include_blank: "Display all"}) %>
107+
{include_blank: "Display all", class: "filter-input"}) %>
111108
</div>
112109
</div>
113110
<div class="col-md-3 select-style-1 pr-5">
114111
<%= f.label :want_driving_reimbursement %>
115112
<div class="select-position">
116113
<%= f.select(:want_driving_reimbursement, @presenter.boolean_select_options,
117-
{include_blank: "Display all"}) %>
114+
{include_blank: "Display all", class: "filter-input"}) %>
118115
</div>
119116
</div>
120117
<div class="col-md-3 select-style-1 pr-5">
121118
<%= f.label :contact_made %>
122119
<div class="select-position">
123120
<%= f.select(:contact_made, @presenter.boolean_select_options,
124-
{include_blank: "Display all"}) %>
121+
{include_blank: "Display all", class: "filter-input"}) %>
125122
</div>
126123
</div>
127124
</div>

spec/system/case_contacts/index_spec.rb

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
end
6666
end
6767

68-
describe "filtering case contacts" do
68+
describe "automated filtering case contacts" do
6969
describe "by date of contact" do
7070
it "only shows the contacts with the correct date" do
7171
yesterday = Time.zone.yesterday
@@ -88,8 +88,6 @@
8888
fill_in "filterrific_occurred_starting_at", with: yesterday
8989
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
9090

91-
click_on "Filter"
92-
9391
expect(page).to have_no_content day_before_yesterday_display
9492
expect(page).to have_content yesterday_display
9593
expect(page).to have_content today_display
@@ -125,8 +123,6 @@
125123

126124
check "Hide drafts"
127125

128-
click_on "Filter"
129-
130126
expect(page).to have_no_content "Draft"
131127
end
132128
end
@@ -143,8 +139,6 @@
143139
it "does not expand menu when filtering only by sticky filter" do
144140
check "Hide drafts"
145141

146-
click_on "Filter"
147-
148142
expect(page).to have_field "Hide drafts", type: :checkbox
149143
expect(page).to have_no_content "Other filters"
150144
end
@@ -159,8 +153,6 @@
159153
click_on "Expand / Hide"
160154
select "In Person", from: "Contact medium"
161155

162-
click_on "Filter"
163-
164156
expect(page).to have_content "Other filters"
165157
end
166158
end
@@ -225,7 +217,7 @@
225217
click_on "Expand / Hide"
226218
fill_in "filterrific_occurred_starting_at", with: yesterday
227219
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
228-
click_on "Filter"
220+
229221
expect(page).to have_text("Case 2 Notes")
230222
expect(page).to have_no_text("Case 1 Notes")
231223

@@ -237,7 +229,7 @@
237229
click_on "Expand / Hide"
238230
fill_in "filterrific_occurred_starting_at", with: yesterday
239231
fill_in "filterrific_occurred_ending_at", with: Time.zone.tomorrow
240-
click_on "Filter"
232+
241233
# no contacts because we're only showing case 1 and that occurred before the filter dates
242234
expect(page).to have_no_text("Case 1 Notes")
243235
expect(page).to have_no_text("Case 2 Notes")

0 commit comments

Comments
 (0)