diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/events_helper.rb | 33 | ||||
| -rw-r--r-- | app/views/events/index.html.erb | 57 |
2 files changed, 76 insertions, 14 deletions
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 1e2e91dc..b14395ab 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb | |||
| @@ -13,6 +13,37 @@ module EventsHelper | |||
| 13 | 13 | ||
| 14 | def external_url_link(url) | 14 | def external_url_link(url) |
| 15 | return nil if url.blank? | 15 | return nil if url.blank? |
| 16 | url.match?(%r{\Ahttps?://}i) ? link_to(url, url) : h(url) | 16 | return h(url) unless url.match?(%r{\Ahttps?://}i) |
| 17 | link_to(url, url, :target => "_blank", :rel => "noopener") | ||
| 17 | end | 18 | end |
| 19 | |||
| 20 | def event_date_range(event) | ||
| 21 | return t("events.schedule.none") if event.start_time.blank? | ||
| 22 | |||
| 23 | from = event.start_time | ||
| 24 | to = event.end_time | ||
| 25 | |||
| 26 | return one_day_range(from, event.allday) if to.blank? || to.to_date == from.to_date | ||
| 27 | |||
| 28 | if !event.allday && (to - from) <= 12.hours | ||
| 29 | return t("events.schedule.evening", | ||
| 30 | :date => admin_date(from), | ||
| 31 | :from => I18n.l(from, :format => :time), | ||
| 32 | :to => I18n.l(to, :format => :time)) | ||
| 33 | end | ||
| 34 | |||
| 35 | key = from.year == to.year && from.month == to.month ? :same_month : :spanning | ||
| 36 | t("events.schedule.#{key}", | ||
| 37 | :from_day => from.day, :to_day => to.day, | ||
| 38 | :from_month => I18n.l(from, :format => :ccc_month), | ||
| 39 | :to_month => I18n.l(to, :format => :ccc_month), | ||
| 40 | :from_full => admin_date(from), :to_full => admin_date(to)) | ||
| 41 | end | ||
| 42 | |||
| 43 | private | ||
| 44 | |||
| 45 | def one_day_range(from, allday) | ||
| 46 | return admin_date(from) if allday | ||
| 47 | admin_datetime(from) | ||
| 48 | end | ||
| 18 | end | 49 | end |
diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 14790526..51269282 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb | |||
| @@ -11,11 +11,7 @@ | |||
| 11 | <table class="events_table"> | 11 | <table class="events_table"> |
| 12 | <tr class="header"> | 12 | <tr class="header"> |
| 13 | <th><%= t("admin.columns.title") %></th> | 13 | <th><%= t("admin.columns.title") %></th> |
| 14 | <th><%= Event.human_attribute_name(:start_time) %></th> | 14 | <th><%= t(".when") %></th> |
| 15 | <th><%= Event.human_attribute_name(:end_time) %></th> | ||
| 16 | <th><%= Event.human_attribute_name(:rrule) %></th> | ||
| 17 | <th><%= Event.human_attribute_name(:url) %></th> | ||
| 18 | <th><%= Event.human_attribute_name(:start_node) %></th> | ||
| 19 | <th></th> | 15 | <th></th> |
| 20 | </tr> | 16 | </tr> |
| 21 | 17 | ||
| @@ -24,17 +20,52 @@ | |||
| 24 | <td> | 20 | <td> |
| 25 | <div class="title_with_flags"> | 21 | <div class="title_with_flags"> |
| 26 | <span class="flag_stack"> | 22 | <span class="flag_stack"> |
| 27 | <%= flag("clock-off", Event.human_attribute_name(:allday)) if event.allday %> | 23 | <%= flag("hours-24", Event.human_attribute_name(:allday)) if event.allday %> |
| 24 | <%= flag("sticker", t(".flag_own_title")) if event.title.present? %> | ||
| 25 | </span> | ||
| 26 | <div class="title_body"> | ||
| 27 | <div class="event_title"><%= link_to event.display_title, event %></div> | ||
| 28 | <% if event.node %> | ||
| 29 | <div class="event_meta"> | ||
| 30 | <%= icon("file", library: "tabler", "aria-hidden": true) %> | ||
| 31 | <%= link_to event.node.unique_name, node_path(event.node) %> | ||
| 32 | </div> | ||
| 33 | <% end %> | ||
| 34 | <% if event.url.present? %> | ||
| 35 | <div class="event_meta"> | ||
| 36 | <%= icon("external-link", library: "tabler", "aria-hidden": true) %> | ||
| 37 | <%= external_url_link(event.url) %> | ||
| 38 | </div> | ||
| 39 | <% end %> | ||
| 40 | </div> | ||
| 41 | </div> | ||
| 42 | </td> | ||
| 43 | <td class="event_when"> | ||
| 44 | <% if event.rrule.present? %> | ||
| 45 | <span class="rrule_raw" title="<%= event.rrule %>"><%= event_schedule_text(event) %></span> | ||
| 46 | <% if event.humanize_rrule.nil? && event.start_time %> | ||
| 47 | <div class="event_meta"><%= admin_date(event.start_time) %></div> | ||
| 48 | <% end %> | ||
| 49 | <% else %> | ||
| 50 | <%= event_date_range(event) %> | ||
| 51 | <% end %> | ||
| 52 | </td> | ||
| 53 | <td class="actions"> | ||
| 54 | <div class="action_grid"> | ||
| 55 | <span class="action_item"> | ||
| 56 | <%= link_to event_path(event), "aria-label" => t("admin.common.show"), | ||
| 57 | title: t("admin.common.show") do %> | ||
| 58 | <%= icon("eye", library: "tabler", "aria-hidden": true) %> | ||
| 59 | <% end %> | ||
| 60 | </span> | ||
| 61 | <span class="action_item"> | ||
| 62 | <%= link_to edit_event_path(event), "aria-label" => t("admin.common.edit"), | ||
| 63 | title: t("admin.common.edit") do %> | ||
| 64 | <%= icon("edit", library: "tabler", "aria-hidden": true) %> | ||
| 65 | <% end %> | ||
| 28 | </span> | 66 | </span> |
| 29 | <div class="title_body"><%= link_to event.display_title, event %></div> | ||
| 30 | </div> | 67 | </div> |
| 31 | </td> | 68 | </td> |
| 32 | <td><%= admin_datetime(event.start_time) %></td> | ||
| 33 | <td><%= admin_datetime(event.end_time) %></td> | ||
| 34 | <td class="rrule_cell"><span class="rrule_text"><%= rrule_with_break_opportunities(event.rrule) %></span></td> | ||
| 35 | <td class="url_cell"><span class="truncate"><%= external_url_link(event.url) %></span></td> | ||
| 36 | <td><%= event.node ? link_to(event.node.unique_name, node_path(event.node)) : "" %></td> | ||
| 37 | <td><%= link_to t(".edit_link"), edit_event_path(event) %></td> | ||
| 38 | </tr> | 69 | </tr> |
| 39 | <% end %> | 70 | <% end %> |
| 40 | </table> | 71 | </table> |
