From 6290c20464ad5c622e902b4dd0de217c374b5905 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 6 Aug 2026 01:59:58 +0200 Subject: Reduce the events list to title, when and actions --- app/helpers/events_helper.rb | 33 +++++++++++++++++++++++- app/views/events/index.html.erb | 57 +++++++++++++++++++++++++++++++---------- 2 files changed, 76 insertions(+), 14 deletions(-) (limited to 'app') 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 def external_url_link(url) return nil if url.blank? - url.match?(%r{\Ahttps?://}i) ? link_to(url, url) : h(url) + return h(url) unless url.match?(%r{\Ahttps?://}i) + link_to(url, url, :target => "_blank", :rel => "noopener") end + + def event_date_range(event) + return t("events.schedule.none") if event.start_time.blank? + + from = event.start_time + to = event.end_time + + return one_day_range(from, event.allday) if to.blank? || to.to_date == from.to_date + + if !event.allday && (to - from) <= 12.hours + return t("events.schedule.evening", + :date => admin_date(from), + :from => I18n.l(from, :format => :time), + :to => I18n.l(to, :format => :time)) + end + + key = from.year == to.year && from.month == to.month ? :same_month : :spanning + t("events.schedule.#{key}", + :from_day => from.day, :to_day => to.day, + :from_month => I18n.l(from, :format => :ccc_month), + :to_month => I18n.l(to, :format => :ccc_month), + :from_full => admin_date(from), :to_full => admin_date(to)) + end + + private + + def one_day_range(from, allday) + return admin_date(from) if allday + admin_datetime(from) + end 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 @@ - - - - - + @@ -24,17 +20,52 @@ + + - - - - - - <% end %>
<%= t("admin.columns.title") %><%= Event.human_attribute_name(:start_time) %><%= Event.human_attribute_name(:end_time) %><%= Event.human_attribute_name(:rrule) %><%= Event.human_attribute_name(:url) %><%= Event.human_attribute_name(:start_node) %><%= t(".when") %>
- <%= flag("clock-off", Event.human_attribute_name(:allday)) if event.allday %> + <%= flag("hours-24", Event.human_attribute_name(:allday)) if event.allday %> + <%= flag("sticker", t(".flag_own_title")) if event.title.present? %> + +
+
<%= link_to event.display_title, event %>
+ <% if event.node %> +
+ <%= icon("file", library: "tabler", "aria-hidden": true) %> + <%= link_to event.node.unique_name, node_path(event.node) %> +
+ <% end %> + <% if event.url.present? %> +
+ <%= icon("external-link", library: "tabler", "aria-hidden": true) %> + <%= external_url_link(event.url) %> +
+ <% end %> +
+
+
+ <% if event.rrule.present? %> + <%= event_schedule_text(event) %> + <% if event.humanize_rrule.nil? && event.start_time %> +
<%= admin_date(event.start_time) %>
+ <% end %> + <% else %> + <%= event_date_range(event) %> + <% end %> +
+
+ + <%= link_to event_path(event), "aria-label" => t("admin.common.show"), + title: t("admin.common.show") do %> + <%= icon("eye", library: "tabler", "aria-hidden": true) %> + <% end %> + + + <%= link_to edit_event_path(event), "aria-label" => t("admin.common.edit"), + title: t("admin.common.edit") do %> + <%= icon("edit", library: "tabler", "aria-hidden": true) %> + <% end %> -
<%= link_to event.display_title, event %>
<%= admin_datetime(event.start_time) %><%= admin_datetime(event.end_time) %><%= rrule_with_break_opportunities(event.rrule) %><%= external_url_link(event.url) %><%= event.node ? link_to(event.node.unique_name, node_path(event.node)) : "" %><%= link_to t(".edit_link"), edit_event_path(event) %>
-- cgit v1.3