From 5692777652a28ee66463fa4a4b79928fd90c79fc Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 3 Aug 2026 18:08:58 +0200 Subject: Share one flag stack between the account roster and the events list --- app/helpers/admin_helper.rb | 7 +++++++ app/views/events/index.html.erb | 9 ++++++--- app/views/users/_user.html.erb | 23 +++++++---------------- public/stylesheets/admin.css | 21 ++++++--------------- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 2684fffb..5a1a42a3 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -7,4 +7,11 @@ module AdminHelper link_to raw('Deutsch'), url_for(params.permit(:locale, :page_path).to_h.merge('locale' => 'de')) end end + + def flag(icon_name, hint, tier: nil) + classes = ["flag", tier && "flag_#{tier}"].compact.join(" ") + content_tag(:span, icon(icon_name, library: "tabler", "aria-hidden": true), + :role => "img", :class => classes, + :title => hint, "aria-label" => hint) + end end diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 7dfb854c..d07d6f82 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -15,7 +15,6 @@ <%= Event.human_attribute_name(:start_time) %> <%= Event.human_attribute_name(:end_time) %> <%= Event.human_attribute_name(:rrule) %> - <%= Event.human_attribute_name(:allday) %> <%= Event.human_attribute_name(:url) %> <%= Event.human_attribute_name(:start_node) %> @@ -23,11 +22,15 @@ <% @events.each do |event| %> - <%= link_to event.display_title, event %> + + + <%= flag("clock-off", Event.human_attribute_name(:allday)) if event.allday %> + + <%= link_to event.display_title, event %> + <%= admin_datetime(event.start_time) %> <%= admin_datetime(event.end_time) %> <%= rrule_with_break_opportunities(event.rrule) %> - <%= t("admin.common.#{event.allday ? "yes" : "no"}") %> <%= 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) %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index aa65cc3d..be92ad1d 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -1,28 +1,19 @@ <% users.each do |user| %> - + <% if user.otp_enrolled? %> - " aria-label="<%= t(".otp_enrolled") %>"> - <%= icon("shield-check", library: "tabler", "aria-hidden": true) %> - + <%= flag("shield-check", t(".otp_enrolled")) %> <% elsif user.otp_pending_secret.present? %> - " aria-label="<%= t(".otp_pending") %>"> - <%= icon("shield-half", library: "tabler", "aria-hidden": true) %> - + <%= flag("shield-half", t(".otp_pending"), :tier => :attention) %> <% else %> - " aria-label="<%= t(".otp_missing") %>"> - <%= icon("shield-off", library: "tabler", "aria-hidden": true) %> - + <%= flag("shield-off", t(".otp_missing"), :tier => :attention) %> <% end %> <% if (tier = user.staleness_tier) %> <% hint = tier == :never ? t(".stale_never") - : t(".stale_#{tier}", :year => user.last_login_at.year) %> - - <%= icon(tier == :amber ? "clock-exclamation" : "alert-triangle", - library: "tabler", "aria-hidden": true) %> - + : t(".stale_#{tier}", :year => user.last_login_at.year) %> + <%= flag(tier == :amber ? "clock-exclamation" : "alert-triangle", hint, + :tier => tier == :amber ? :attention : :alert) %> <% end %> <%= user.login %> diff --git a/public/stylesheets/admin.css b/public/stylesheets/admin.css index 9d8f4d49..1c74bbf5 100644 --- a/public/stylesheets/admin.css +++ b/public/stylesheets/admin.css @@ -912,33 +912,24 @@ table.revisions_table tr:hover { display: block; } -.user_table .user_login .user_flag_stack { +.flag_stack { display: inline-flex; flex-direction: column; align-items: center; + min-width: 1rem; gap: 0.25rem; vertical-align: -0.15em; margin-right: 0.5rem; } -.user_table .user_login svg { - color: var(--text-muted); +.flag_stack svg { width: 1rem; height: 1rem; + color: var(--text-muted); } -.user_table .user_login .otp_missing svg { - color: var(--accent); -} - -.user_table .user_login .stale_flag_amber svg { - color: var(--accent); -} - -.user_table .user_login .stale_flag_red svg, -.user_table .user_login .stale_flag_never svg { - color: var(--danger); -} +.flag_stack .flag_attention svg { color: var(--accent); } +.flag_stack .flag_alert svg { color: var(--danger); } .user_group_heading { margin-top: 1.5rem; -- cgit v1.3