/
participants.html.erb
153 lines (137 loc) · 5.9 KB
/
participants.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<%- model_class = Event -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.titleize %> (<%= @event.kind.humanize %>)</h1>
</div>
<% if can? :view_participants, Event %>
<%= render :partial => 'participants_modal' %>
<%= render :partial => 'show_event' %>
<h1><%= t '.participants' %></h1>
<table class="table table-striped">
<tr>
<th><%= t 'activerecord.attributes.profile.name' %></th>
<th><%= t 'activerecord.attributes.profile.email' %></th>
<th><%= t 'agreement_letters.agreement_letter' %></th>
<th><%= sort_caret(ParticipantGroup.human_attribute_name(:group), :group) %></th>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %>
<th>
<label>
<input type="checkbox" id="select_all_participants" class="participant_selection" onclick="flipAllCheckboxes(this, 'participant_selection')">
<%= t 'events.agreement_letters_download.select_all' %>
</label>
</th>
<% end %>
<% if can? :show_eatings_habits, Event %>
<th>
<%= sort_caret(t('activerecord.methods.application_letter.eating_habits'), 'eating-habits') %>
</th>
<% end %>
</tr>
<% sort_participants
@participants.each do |participant|
application_letter = ApplicationLetter.find_by(user_id: participant.id, event_id: @event.id)
%>
<tr>
<td>
<%= participant.name %>
</td>
<td>
<%= participant.email %>
</td>
<td>
<% if participant.requires_agreement_letter_for_event?(@event) %>
<span class="text-muted"> <%= t '.unnecessary' %> </span>
<% elsif participant.agreement_letter_for_event?(@event) %>
<span class="text-success" title="<%= participant.agreement_letter_for_event(@event).updated_at %>"> <%= t '.available' %> </span>
<% else %>
<span class="text-danger"><%= t '.unavailable' %></span>
<% end %>
</td>
<td>
<%= render 'colorselect', participant_group: @event.participant_group_for(participant) %>
</td>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %>
<td>
<%= check_box_tag('selected_participants[]', participant.id, false, class: 'participant_selection') %>
</td>
<% end %>
<% if can? :show_eatings_habits, Event %>
<td>
<% if application_letter && ( application_letter.vegan || application_letter.vegetarian || application_letter.allergic ) %>
<ul id="eating-habit--list">
<% if application_letter.vegan %>
<li>
<img
class="img img-responsive eating-habit--icon"
src="<%= image_url('application_letter_vegan.png') %>"
>
</li>
<% end %>
<% if application_letter.vegetarian %>
<li>
<img
class="img img-responsive eating-habit--icon"
src="<%= image_url('application_letter_vegetarian.png') %>"
>
</li>
<% end %>
<% if application_letter.allergic %>
<li>
<%= image_tag('application_letter_allergic.png',
class: "img img-responsive eating-habit--icon has-popover",
tabindex: 50,
data: {
toggle: "popover",
content: application_letter.allergies,
placement: "bottom"
})
%>
</li>
<% end %>
</ul>
<% end %>
</td>
<% end %>
</tr>
<% end %>
</table>
<button class="btn btn-default" type="button" data-toggle="modal" data-target="#print_participant_modal" id="open_print_modal"><%= t("events.participants.print_participants") %>
</button>
<%= form_tag(event_path(@event) + "/participants/agreement_letters", { method: :post, id: 'downloadLettersForm' }) do %>
<% if can? :print_agreement_letters, Event and @has_agreement_letters %>
<div id="participants_download_submit_button">
<%= submit_tag t('events.agreement_letters_download.download_all_as'), name: "download_all", class: "btn btn-default" %>
<%= select_tag :download_type, options_for_select([['pdf'], ['zip']]) %>
</div>
<% end %>
<% if can? :print_applications_eating_habits, Event %>
<%= link_to t('events.participants.print_habits'),
event_path(@event) + "/print_applications_eating_habits",
:class => 'btn btn-default btn-sm',
:target => '_blank' %>
<% end %>
<% end %>
<br>
<%= link_to t('.back', :default => t('helpers.links.back')),
event_path(@event), :class => 'btn btn-default' %>
<% if @event.phase == :execution %>
<%= link_to t('events.badges.print_button_label'),
badges_event_path(@event),
:class => 'btn btn-default',
:disabled => @participants.empty?,
:target => '_blank' %>
<% end %>
<script>
$('.colorselector').colorselector();
$('#downloadLettersForm').submit(function() {
$('[name="selected_participants[]"]').each(function() {
if (this.checked) {
var input = document.createElement("input");
input.setAttribute("type", "hidden");
input.setAttribute("name", this.name);
input.setAttribute("value", this.value);
document.getElementById("downloadLettersForm").appendChild(input);
}
});
});
</script>
<% end %>