|
1 | 1 | <h3 class="pre-title"><%= @event.name %></h3>
|
2 | 2 | <h1><%=h @audience.to_s %> Attendance</h1>
|
3 |
| - |
| 3 | + |
4 | 4 | <table class="attendees">
|
5 |
| - <thead> |
6 |
| - <tr> |
7 |
| - <th>Attendee</th> |
8 |
| - <%= content_tag(:th, "High School") if @audience.to_s.downcase == "participant" || @audience.to_s.downcase == "student" %> |
9 |
| - <th>Program(s)</th> |
10 |
| - <th>Phone</th> |
11 |
| - <th>Shift</th> |
12 |
| - <%= "<th class='centered'>Trained?</th>" if @event.training_required?(@audience.to_s) %> |
13 |
| - <th class="centered">RSVP'd? |
14 |
| - <%= link_to "E-mail", |
15 |
| - "mailto:#{@event.attendees.rsvpd(@audience).collect{|a| a.email rescue nil }.compact.join(",")}", |
16 |
| - :class => 'email button', |
17 |
| - :id => 'attending_email_link' %> |
18 |
| - </th> |
19 |
| - <th class="centered">Attended? |
20 |
| - <%= link_to "E-mail", |
21 |
| - "mailto:#{@event.attendees.attended(@audience).collect{|a| a.email rescue nil }.compact.join(",")}", |
22 |
| - :class => 'email button', |
23 |
| - :id => 'attended_email_link' %> |
24 |
| - </th> |
25 |
| - <th>Functions</th> |
26 |
| - </tr> |
27 |
| - </thead> |
28 |
| - |
29 |
| - <tbody> |
30 |
| - <%= render :partial => 'event_attendance', :collection => @event.attendees.audience(@audience).select{|a| a.rsvp? || a.attended? || a.admin? }, :locals => { :audience => @audience } %> |
31 |
| - |
32 |
| - <%- if @event.attendees.empty? -%> |
33 |
| - <tr class="empty"> |
34 |
| - <td colspan=10>No event attendees yet.</td> |
35 |
| - </tr> |
36 |
| - <% end -%> |
37 |
| - </tbody> |
| 5 | + <thead> |
| 6 | + <tr> |
| 7 | + <th>Attendee</th> |
| 8 | + <%= content_tag(:th, "High School") if @audience.to_s.downcase == "participant" || @audience.to_s.downcase == "student" %> |
| 9 | + <th>Program(s)</th> |
| 10 | + <th>Phone</th> |
| 11 | + <th>Shift</th> |
| 12 | + <%= "<th class='centered'>Trained?</th>" if @event.training_required?(@audience.to_s) %> |
| 13 | + <th class="centered">RSVP'd? |
| 14 | + <%= link_to "E-mail", |
| 15 | + "mailto:#{@event.attendees.rsvpd(@audience).collect{|a| a.email rescue nil }.compact.join(",")}", |
| 16 | + :class => 'email button', |
| 17 | + :id => 'attending_email_link' %> |
| 18 | + </th> |
| 19 | + <th class="centered">Attended? |
| 20 | + <%= link_to "E-mail", |
| 21 | + "mailto:#{@event.attendees.attended(@audience).collect{|a| a.email rescue nil }.compact.join(",")}", |
| 22 | + :class => 'email button', |
| 23 | + :id => 'attended_email_link' %> |
| 24 | + </th> |
| 25 | + <th>Functions</th> |
| 26 | + </tr> |
| 27 | + </thead> |
| 28 | + |
| 29 | + <tbody> |
| 30 | + <%= render :partial => 'event_attendance', :collection => @event.attendees.audience(@audience).select{|a| a.rsvp? || a.attended? || a.admin? }, :locals => { :audience => @audience } %> |
| 31 | + |
| 32 | + <%- if @event.attendees.empty? -%> |
| 33 | + <tr class="empty"> |
| 34 | + <td colspan=10>No event attendees yet.</td> |
| 35 | + </tr> |
| 36 | + <% end -%> |
| 37 | + </tbody> |
38 | 38 | </table>
|
39 | 39 |
|
40 | 40 | <div id="sidebar">
|
41 |
| - <p><%= link_to "Back to Event", event_path(@event), :class => 'back button' %></p> |
42 |
| - <p><%= link_to "Take Attendnace", checkin_event_event_attendances_path(@event, :audience => @audience), :class => "edit button" %></p> |
43 |
| - |
44 |
| - <%- form_tag({}, :method => :get) do -%> |
45 |
| - <p><%= label_tag :audience, "View Attendance For:" %> |
46 |
| - <%= select_tag :audience, |
47 |
| - options_for_select(%w[Participant Student Mentor Volunteer].collect{|a| ["#{a} (#{@event.rsvpd_count(a)})", a]}, |
48 |
| - @audience.to_s.classify), |
49 |
| - :onchange => "this.form.submit()" %> |
50 |
| - <%= submit_tag "Go" %> |
51 |
| - </p> |
52 |
| - <% end -%> |
53 |
| - |
54 |
| - <%- if @event.has_shifts?(@audience.to_s.classify) %> |
55 |
| - <h3>Filter by Shift</h3> |
56 |
| - |
57 |
| - <div id="event_shift_selectors"> |
58 |
| - <%- for event_shift in @event.shifts.for(@audience.to_s.classify) -%> |
59 |
| - <label for="event_shift_selector_<%= event_shift.id %>"> |
60 |
| - <input type="checkbox" id="event_shift_selector_<%= event_shift.id %>" data-shift-id="<%= event_shift.id %>" checked onChange="updateShiftSelections(this);"> |
61 |
| - <%= truncate(event_shift.title) %> |
62 |
| - </label><br> |
63 |
| - <% end -%> |
64 |
| - <small class="light">Filtering the list will also update the email buttons above.</small> |
65 |
| - </div> |
66 |
| - |
67 |
| - <% end -%> |
| 41 | + <p><%= link_to "Back to Event", event_path(@event), :class => 'back button' %></p> |
| 42 | + <p><%= link_to "Take Attendnace", checkin_event_event_attendances_path(@event, :audience => @audience), :class => "edit button" %></p> |
| 43 | + |
| 44 | + <%- form_tag({}, :method => :get) do -%> |
| 45 | + <p><%= label_tag :audience, "View Attendance For:" %> |
| 46 | + <%= select_tag :audience, |
| 47 | + options_for_select(%w[Participant Student Mentor Volunteer].collect{|a| ["#{a} (#{@event.rsvpd_count(a)})", a]}, |
| 48 | + @audience.to_s.classify), |
| 49 | + :onchange => "this.form.submit()" %> |
| 50 | + <%= submit_tag "Go" %> |
| 51 | + </p> |
| 52 | + <% end -%> |
| 53 | + |
| 54 | + <%- if @event.has_shifts?(@audience.to_s.classify) %> |
| 55 | + <h3>Filter by Shift</h3> |
| 56 | + |
| 57 | + <div id="event_shift_selectors"> |
| 58 | + <%- for event_shift in @event.shifts.for(@audience.to_s.classify) -%> |
| 59 | + <label for="event_shift_selector_<%= event_shift.id %>"> |
| 60 | + <input type="checkbox" id="event_shift_selector_<%= event_shift.id %>" data-shift-id="<%= event_shift.id %>" checked onChange="updateShiftSelections(this);"> |
| 61 | + <%= truncate(event_shift.title) %> |
| 62 | + </label><br> |
| 63 | + <% end -%> |
| 64 | + <small class="light">Filtering the list will also update the email buttons above.</small> |
| 65 | + </div> |
| 66 | + |
| 67 | + <% end -%> |
68 | 68 | </div>
|
69 | 69 |
|
70 | 70 | <script type="text/javascript">
|
71 | 71 |
|
| 72 | +function filterEvents() { |
| 73 | + |
| 74 | +} |
| 75 | + |
| 76 | + |
72 | 77 | function updateShiftSelections(elem) {
|
73 |
| - var rows = $$("tr.event_attendance") |
74 |
| - rows = rows.findAll(function(e) { return e.readAttribute('data-shift-id') == elem.readAttribute('data-shift-id') }) |
75 |
| - if(elem.checked == true) { |
76 |
| - rows.invoke('show') |
77 |
| - } else { |
78 |
| - rows.invoke('hide') |
79 |
| - } |
80 |
| - updateEmailLinks() |
| 78 | + // get the data shift id for the filter |
| 79 | + var shiftid = elem.getAttribute("data-shift-id"); |
| 80 | + |
| 81 | + // get all rows that correspond to that shift id |
| 82 | + var rows = $("tr.event_attendance[data-shift-id='" + shiftid + "']"); |
| 83 | + |
| 84 | + if (elem.checked) { |
| 85 | + rows.show(); |
| 86 | + } else { |
| 87 | + rows.hide(); |
| 88 | + } |
| 89 | + |
| 90 | + updateEmailLinks(); |
81 | 91 | }
|
82 | 92 |
|
83 | 93 | function updateEmailLinks() {
|
84 |
| - var rows = $$("tr.event_attendance").findAll(function(e) { return e.visible() }) |
85 |
| - var attending_rows = rows.findAll(function(e) { return e.readAttribute("data-attending") == "true" }) |
86 |
| - var attended_rows = rows.findAll(function(e) { return e.readAttribute("data-attended") == "true" }) |
87 |
| - $('attending_email_link').writeAttribute("href", "mailto:" + attending_rows.collect(function(e) { return e.readAttribute("data-email") }).join(",")) |
88 |
| - $('attended_email_link').writeAttribute("href", "mailto:" + attended_rows.collect(function(e) { return e.readAttribute("data-email") }).join(",")) |
| 94 | + // get rows which are visible and corresponding attributes are true |
| 95 | + var attending_rows = $("tr.event_attendance[data-attending='true']:visible"); |
| 96 | + var attended_rows = $("tr.event_attendance[data-attended='true']:visible"); |
| 97 | + |
| 98 | + // create an email list of those people attending |
| 99 | + var emailsAttending = []; |
| 100 | + function getAttending() { |
| 101 | + attending_rows.each(function(key, value) { |
| 102 | + emailsAttending.push(value.getAttribute('data-email')); |
| 103 | + }); |
| 104 | + } |
| 105 | + getAttending(); |
| 106 | + |
| 107 | + // make the array into string and then set that as a value to the email link |
| 108 | + emailsAttending = emailsAttending.splice(',').join(','); |
| 109 | + $('#attending_email_link').attr("href", "mailto:" + emailsAttending); |
| 110 | + |
| 111 | + // similarly for the Attended emails |
| 112 | + var emailsAttended = []; |
| 113 | + function getAttended() { |
| 114 | + attended_rows.each(function(key, value) { |
| 115 | + emailsAttended.push(value.getAttribute('data-email')); |
| 116 | + }); |
| 117 | + } |
| 118 | + getAttended(); |
| 119 | + emailsAttended = emailsAttended.splice(',').join(','); |
| 120 | + $('#attended_email_link').attr("href", "mailto:" + emailsAttended); |
89 | 121 | }
|
90 | 122 |
|
91 | 123 | </script>
|
0 commit comments