/
_list.html.erb
168 lines (160 loc) · 6.21 KB
/
_list.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<%
# Display a detailed list of Proposal records.
#
# Variables:
# * records => Array of Proposal records to display. REQUIRED.
# * kind => Treat these records as :sessions or :proposals. REQUIRED.
# * sorter => Display the sort toolbar? Defaults to false.
records = OpenConferenceWare::Proposal.sort(records, params[:sort] || "title", params[:dir] != "desc", current_user && current_user.id)
%>
<% if proposal_excerpts? %>
<% if sorter %>
<div>
<% sort_links = [sort_link_for("Title", 'title', kind)]
sort_links << sort_link_for("Track", 'track', kind) if event_tracks?
sort_links << sort_link_for("Submission date", 'submitted_at', kind) if kind == :proposals
sort_links << sort_link_for("Scheduled time", 'start_time', kind) if schedule_visible? && kind == :sessions
sort_links << sort_link_for("Status", 'status', kind) if proposal_statuses? && admin?
sort_links << sort_link_for("Random for content selection", 'random', kind) if selector?
%>
Sort by:
<%= sort_links.join(', ').html_safe %>
</div>
<% end %>
<% if records.blank? %>
<h4>— No <%= kind %> submitted yet —</h4>
<% else %>
<table class='proposals kind_<%= kind %>' cellspacing='0'>
<% previous_start_time = false %>
<% for record in records %>
<%
# Use prefetched values
track = record.respond_to?(:track_id) ? (@tracks_hash.try(:fetch, record.track_id, nil) || record.track) : nil
%>
<% if schedule_visible? && kind == :sessions && params[:sort]=='start_time' && (record.start_time != previous_start_time) %>
<tr>
<td colspan='3' class='schedule_header'>
<%= record.start_time.nil? ? 'Unscheduled' : record.start_time.strftime("%A, %B %d - %I:%M %p") %>
</td>
</tr>
<% end %>
<% previous_start_time = record.start_time %>
<% voted = selector? && @event.accept_selector_votes? && record.selector_votes.where(user_id: current_user.id).count > 0 %>
<tr class='proposal_row<%= " voted" if voted %>' id='proposal_row_<%= record.id %>'>
<td rowspan='2' class='description'>
<h3>
<%= user_favorite_control_for record %>
<% if multiple_presenters? %>
<%= link_to(h(record.title), record_path(record, kind), :class => "title") %>
<% else %>
<%= link_to(h(record.presenter)+" — "+h(record.title), record_path(record, kind), :class => "title") %>
<% end %>
<% if kind == :proposals && voted %>
<span class='vote-status'>(Voted)</span>
<% end %>
<% if kind == :proposals && proposal_statuses? && (admin? || (@event.proposal_status_published? && record.confirmed?)) %>
<span class='proposal-status <%= record.status %>'>(<%= record.status.titleize %>)</span>
<% end %>
</h3>
<div class="excerpt">
<%= h record.excerpt if proposal_excerpts? %>
</div>
</td>
<% if event_tracks? %>
<td class='track block <%= track_css_class(track) if track %>'>
<%= track.present? ? link_to(h(track.title), event_track_path(@event, track)) : "- N/A -" %>
</td>
<% end %>
<% if kind == :proposals %>
<td class='date'>
<%= record.submitted_at.localtime.to_s if record.submitted_at.present? %>
</td>
<% end %>
</tr>
<tr>
<td class="speakers" colspan='<%= event_tracks? ? 2 : 1 %>'>
<% if multiple_presenters? %>
<% users = record.respond_to?(:users) ? (@users_for_proposal_hash.try(:fetch, record.id, nil) || record.users) : [] %>
<% end %>
<% unless users.empty? %>
<%= users.map{|user| link_to(h(user.fullname), user_path(user))}.join(', ').html_safe %>
<% end %>
</td>
</tr>
<% end %>
</table>
<% end %>
<% else %>
<table id="proposal-listing">
<% if records.blank? %>
<tr>
<td colspan="2">
<p class="empty-text">— No <%= kind %> submitted yet —</p>
</td>
</td>
<% else %>
<thead>
<tr>
<th width="100%">
<% if multiple_presenters? %>
Title
<% else %>
Speaker and title
<% end %>
</th>
<% if event_tracks? %>
<th>
Track
</th>
<% end %>
<% if kind == :proposals %>
<th width="0">Submitted</th>
<% end %>
</tr>
</thead>
<% date_cache = {} %>
<% for record in records %>
<tr class="<%= cycle("even", "odd") %>" valign="top">
<td width="100%">
<p class="proposal">
<% styling = proposal_excerpts? ? 'display: inline-block' : 'inline' %>
<% if multiple_presenters? %>
<%= link_to(record.title, record, :class => "title", :style => styling) %>
<% else %>
<%= link_to("#{record.presenter} — #{record.title}".html_safe, record, :class => "title", :style => styling) %>
<% end %>
<span class="excerpt">
<%= h record.excerpt if proposal_excerpts? %>
</span>
<p class="speakers">
<% if multiple_presenters? %>
<%= record.users.map{|user| link_to(h(user.fullname), user_path(user), :style => "display: inline")}.join(', ') %>
<% end %>
</p>
</p>
</td>
<% if event_tracks? %>
<td>
<p>
<%= track.try(:title) || "- N/A -" %>
</p>
</td>
<% end %>
<td width="0" class="unbreakable">
<p>
<% date = record.submitted_at.localtime.strftime("%m/%d/%Y") if record.submitted_at.present? %>
<% if date_cache[date] %>
<!--
<span class="date-seen"><%= date %></span>
-->
<% else %>
<% date_cache[date] = true %>
<span class="date-unseen"><%= date %></span>
<% end %>
</p>
</td>
</tr>
<% end %>
<% end %>
</table>
<% end %>