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

Major fix: Filtering on events by shifts now works. #145

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions app/assets/stylesheets/dreamsis.css
Original file line number Diff line number Diff line change
Expand Up @@ -4586,6 +4586,7 @@ ul.mentor_stats_summary .section_id.tag {
.signup-numbers {
font-size: 85%;
color: #656565;
clear: both;
}

.signup-numbers span {
Expand Down
100 changes: 60 additions & 40 deletions app/views/event_attendances/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 class="pre-title"><%= @event.name %></h3>
<h1><%=h @audience.to_s %> Attendance</h1>

<table class="attendees">
<thead>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kritinvij Could you please go through these lines and change the spaces back to tabs, to keep the diff a little smaller?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I will get back home and do it today.

Kritin Vij
University of Washington
Computer Science | Math Minor
*[email protected] [email protected] | *
http://in.linkedin.com/pub/kritin-vij/2b/176/ab0/

On Tue, Jun 23, 2015 at 11:57 PM, Mitchell Harper [email protected]
wrote:

In app/views/event_attendances/index.html.erb
#145 (comment)
:

-

@kritinvij https://github.com/kritinvij Could you please go through
these lines and change the spaces back to tabs, to keep the diff a little
smaller?


Reply to this email directly or view it on GitHub
https://github.com/uwdreamproject/DreamSIS/pull/145/files#r33121558.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I converted all spaces to tabs to keep the file consistent.
I think the diff tool may complain about reindenting some lines from spaces
to tabs. But, I think keeping the same type of indentation throughtout the
file is necessary.

Thanks

Kritin Vij
University of Washington
Computer Science | Math Minor
*[email protected] [email protected] | *
http://in.linkedin.com/pub/kritin-vij/2b/176/ab0/

On Wed, Jun 24, 2015 at 10:20 AM, Kritin Vij [email protected] wrote:

Yes. I will get back home and do it today.

Kritin Vij
University of Washington
Computer Science | Math Minor
*[email protected] [email protected] | *
http://in.linkedin.com/pub/kritin-vij/2b/176/ab0/

On Tue, Jun 23, 2015 at 11:57 PM, Mitchell Harper <
[email protected]> wrote:

In app/views/event_attendances/index.html.erb
#145 (comment)
:

-

@kritinvij https://github.com/kritinvij Could you please go through
these lines and change the spaces back to tabs, to keep the diff a little
smaller?


Reply to this email directly or view it on GitHub
https://github.com/uwdreamproject/DreamSIS/pull/145/files#r33121558.

<tr>
Expand All @@ -12,16 +12,16 @@
<%= "<th class='centered'>Trained?</th>" if @event.training_required?(@audience.to_s) %>
<th class="centered">RSVP'd?
<%= link_to "E-mail",
"mailto:#{@event.attendees.rsvpd(@audience).collect{|a| a.email rescue nil }.compact.join(",")}",
:class => 'email button',
:id => 'attending_email_link' %>
</th>
"mailto:#{@event.attendees.rsvpd(@audience).collect{|a| a.email rescue nil }.compact.join(",")}",
:class => 'email button',
:id => 'attending_email_link' %>
</th>
<th class="centered">Attended?
<%= link_to "E-mail",
"mailto:#{@event.attendees.attended(@audience).collect{|a| a.email rescue nil }.compact.join(",")}",
:class => 'email button',
:id => 'attended_email_link' %>
</th>
"mailto:#{@event.attendees.attended(@audience).collect{|a| a.email rescue nil }.compact.join(",")}",
:class => 'email button',
:id => 'attended_email_link' %>
</th>
<th>Functions</th>
</tr>
</thead>
Expand All @@ -30,62 +30,82 @@
<%= render :partial => 'event_attendance', :collection => @event.attendees.audience(@audience).select{|a| a.rsvp? || a.attended? || a.admin? }, :locals => { :audience => @audience } %>

<%- if @event.attendees.empty? -%>
<tr class="empty">
<td colspan=10>No event attendees yet.</td>
</tr>
<tr class="empty">
<td colspan=10>No event attendees yet.</td>
</tr>
<% end -%>
</tbody>
</table>

<div id="sidebar">
<p><%= link_to "Back to Event", event_path(@event), :class => 'back button' %></p>
<p><%= link_to "Take Attendnace", checkin_event_event_attendances_path(@event, :audience => @audience), :class => "edit button" %></p>

<%- form_tag({}, :method => :get) do -%>
<p><%= label_tag :audience, "View Attendance For:" %>
<%= select_tag :audience,
options_for_select(%w[Participant Student Mentor Volunteer].collect{|a| ["#{a} (#{@event.rsvpd_count(a)})", a]},
@audience.to_s.classify),
:onchange => "this.form.submit()" %>
<p><%= label_tag :audience, "View Attendance For:" %>
<%= select_tag :audience,
options_for_select(%w[Participant Student Mentor Volunteer].collect{|a| ["#{a} (#{@event.rsvpd_count(a)})", a]},
@audience.to_s.classify),
:onchange => "this.form.submit()" %>
<%= submit_tag "Go" %>
</p>
<% end -%>
<% end -%>

<%- if @event.has_shifts?(@audience.to_s.classify) %>
<%- if @event.has_shifts?(@audience.to_s.classify) %>
<h3>Filter by Shift</h3>

<div id="event_shift_selectors">
<%- for event_shift in @event.shifts.for(@audience.to_s.classify) -%>
<%- for event_shift in @event.shifts.for(@audience.to_s.classify) -%>
<label for="event_shift_selector_<%= event_shift.id %>">
<input type="checkbox" id="event_shift_selector_<%= event_shift.id %>" data-shift-id="<%= event_shift.id %>" checked onChange="updateShiftSelections(this);">
<%= truncate(event_shift.title) %>
</label><br>
<% end -%>
<small class="light">Filtering the list will also update the email buttons above.</small>
<% end -%>
<small class="light">Filtering the list will also update the email buttons above.</small>
</div>

<% end -%>
</div>

<script type="text/javascript">
<% end -%>
</div>

function updateShiftSelections(elem) {
var rows = $$("tr.event_attendance")
rows = rows.findAll(function(e) { return e.readAttribute('data-shift-id') == elem.readAttribute('data-shift-id') })
if(elem.checked == true) {
rows.invoke('show')
<script type="text/javascript">

function updateShiftSelections(elem) {
// get the data shift id for the filter
var shiftid = elem.getAttribute("data-shift-id");

// get all rows that correspond to that shift id
var rows = $("tr.event_attendance[data-shift-id='" + shiftid + "']");

if (elem.checked) {
rows.show();
} else {
rows.invoke('hide')
rows.hide();
}
updateEmailLinks()
updateEmailLinks();
}

function updateEmailLinks() {
var rows = $$("tr.event_attendance").findAll(function(e) { return e.visible() })
var attending_rows = rows.findAll(function(e) { return e.readAttribute("data-attending") == "true" })
var attended_rows = rows.findAll(function(e) { return e.readAttribute("data-attended") == "true" })
$('attending_email_link').writeAttribute("href", "mailto:" + attending_rows.collect(function(e) { return e.readAttribute("data-email") }).join(","))
$('attended_email_link').writeAttribute("href", "mailto:" + attended_rows.collect(function(e) { return e.readAttribute("data-email") }).join(","))
// get rows which are visible and corresponding attributes are true
var attending_rows = $("tr.event_attendance[data-attending='true']:visible");
var attended_rows = $("tr.event_attendance[data-attended='true']:visible");

// create an email list of those people attending
var emailsAttending = [];
attending_rows.each(function(key, value) {
emailsAttending.push(value.getAttribute('data-email'));
});

// make the array into string and then set that as a value to the email link
emailsAttending = emailsAttending.join(',');
$('#attending_email_link').attr("href", "mailto:" + emailsAttending);

// similarly for the Attended emails
var emailsAttended = [];
attended_rows.each(function(key, value) {
mailsAttended.push(value.getAttribute('data-email'));
});
emailsAttended = emailsAttended.join(',');
$('#attended_email_link').attr("href", "mailto:" + emailsAttended);
}

</script>
2 changes: 1 addition & 1 deletion app/views/events/_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
title="<%= number_to_percentage details.percent_full, :precision => 0 %> full">

<div class="size" style="width: <%= details.percent_full %>%">
<%= details.full? ? content_tag(:span, "full", :class => "full_label") : "&nbsp;" %>
<%= details.full? ? content_tag(:span, "full", :class => "full_label") : "&nbsp;".html_safe %>
</div>
</div>
</div>
Expand Down