File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed
Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ def case_contacts_latest_before(date)
1515 object . case_contacts . where ( "occurred_at < ?" , date ) . max_by ( &:occurred_at )
1616 end
1717
18+ def case_contacts_made
19+ object . case_contacts . where ( 'occurred_at > ?' , DateTime . now - 60 . days ) . count
20+ end
21+
22+ def last_attempted_contact_formatted ( volunteer_id )
23+ object . case_contacts . where ( creator_id : volunteer_id ) . order ( occurred_at : :desc ) . first &.occurred_at &.strftime ( "%B %d, %Y" )
24+ end
25+
1826 def case_contacts_filtered_by_active_assignment_ordered_by_occurred_at
1927 object . case_contacts
2028 . joins ( "INNER JOIN case_assignments on case_assignments.casa_case_id = case_contacts.casa_case_id and case_assignments.volunteer_id = case_contacts.creator_id" )
Original file line number Diff line number Diff line change @@ -134,8 +134,14 @@ $(() => { // JQuery's callback for the DOM loading
134134 }
135135 } )
136136 } ,
137- order : [ [ 7 , 'desc' ] ] ,
137+ order : [ [ 8 , 'desc' ] ] ,
138138 columns : [
139+ {
140+ className : 'dt-control' ,
141+ orderable : false ,
142+ data : null ,
143+ defaultContent : ''
144+ } ,
139145 {
140146 data : 'id' ,
141147 targets : 0 ,
@@ -304,6 +310,19 @@ $(() => { // JQuery's callback for the DOM loading
304310 }
305311 } )
306312
313+ volunteersTable . on ( 'click' , 'tbody td.dt-control' , function ( e ) {
314+ let tr = e . target . closest ( 'tr' ) ;
315+ let row = volunteersTable . row ( tr ) ;
316+
317+ if ( row . child . isShown ( ) ) {
318+ row . child . hide ( ) ;
319+ }
320+ else {
321+ const vdomId = `#volunteer-details-${ row . data ( ) . id } `
322+ row . child ( $ ( vdomId ) . html ( ) ) . show ( ) ;
323+ }
324+ } ) ;
325+
307326 // Because the table saves state, we have to check/uncheck modal inputs based on what
308327 // columns are visible
309328 volunteersTable . columns ( ) . every ( function ( index ) {
Original file line number Diff line number Diff line change 178178 < th >
179179 < input id ="checkbox-toggle-all " type ="checkbox " class ="form-check-input " data-select-all-target ="checkboxAll " data-action ="select-all#toggleAll ">
180180 </ th >
181+ < th > </ th >
181182 < th > Name</ th >
182183 < th > Email</ th >
183184 < th > Supervisor</ th >
247248
248249</ div >
249250</ div>
251+
252+ < div style ='display:none '>
253+ <% current_organization . volunteers . each do |volunteer | %>
254+ < div id ="volunteer-details- <%= volunteer . id %> ">
255+ <% if volunteer . casa_cases . any? %>
256+ < table >
257+ < tr >
258+ < th > Case Number </ th >
259+ < th > Transition Aged Youth </ th >
260+ < th > Last Attempted Contact </ th >
261+ < th > Contacts Made in Past 60 Days </ th >
262+ </ tr >
263+ <% volunteer . casa_cases . each do |casa_case | %>
264+ < tr >
265+ < td > <%= casa_case . case_number %> </ td >
266+ < td > <%= casa_case . decorate . transition_aged_youth %> </ td >
267+ < td > <%= casa_case . decorate . last_attempted_contact_formatted ( volunteer . id ) %> </ td >
268+ < td > <%= casa_case . decorate . case_contacts_made %>
269+ </ tr >
270+ <% end %>
271+ </ table >
272+ <% end %>
273+ </ div >
274+ <% end %>
275+ </ div >
You can’t perform that action at this time.
0 commit comments