Skip to content
Merged
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
15 changes: 15 additions & 0 deletions app/helpers/schedule_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module ScheduleHelper
KIND_DISPLAY_OVERRIDES = { "lightning" => "Lightning Talks" }.freeze

def kind_display_label(kind)
return nil if kind.blank?
KIND_DISPLAY_OVERRIDES[kind.to_s] || kind.to_s.humanize
end

def visible_filter_kinds(user)
ScheduleItem.kinds.keys.reject do |kind|
kind == "reception" ||
(kind == "volunteer" && !(user&.volunteer? || user&.admin?))
end.sort_by { |kind| kind_display_label(kind) }
end
end
2 changes: 1 addition & 1 deletion app/views/admin/schedule_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</td>
<td>
<% if item.kind.present? %>
<span class="item-badge item-badge--<%= item.kind %>"><%= item.kind.humanize %></span>
<span class="item-badge item-badge--<%= item.kind %>"><%= kind_display_label(item.kind) %></span>
<% else %>
<span class="item-badge text-muted">unknown (<%= item.read_attribute_before_type_cast(:kind) %>)</span>
<% end %>
Expand Down
11 changes: 1 addition & 10 deletions app/views/schedule/_session_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
<%
kind_label = {
"talk" => "Talk",
"lightning" => "Lightning",
"embassy" => "Embassy",
"activity" => "Activity",
"reception" => "Reception",
"meal" => "Meal",
"community" => "Community",
"volunteer" => "Volunteer"
}[item.kind]
kind_label = kind_display_label(item.kind)
flexible_classes = item.flexible? ? "schedule-item--flexible" : ""

existing_plan = current_user.plan_items.find_by(schedule_item: item) if planned
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_kind_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
base_path + (qp_clear.any? ? "?#{qp_clear.to_query}" : ""),
class: "kind-filter__btn #{'kind-filter__btn--active' if selected_kind.blank?}" %>

<% ScheduleItem.kinds.each_key do |kind| %>
<%= link_to kind.humanize,
<% visible_filter_kinds(current_user).each do |kind| %>
<%= link_to kind_display_label(kind),
base_path + "?#{request.query_parameters.merge(kind: kind).to_query}",
class: "kind-filter__btn #{'kind-filter__btn--active' if selected_kind == kind}" %>
<% end %>
Expand Down
Loading