Files
nairobi/app/components/admin/stats/event_links_component.rb
Javi Martín b04ac817f6 Use a list of links for admin stats events
Using <h3> headings for the links had two disadvantages.

First, it was the wrong heading level to use, since there was no <h2>
tag before it.

Second, headings are supposed to be followed by content associated to
that heading; here, we had no content following the headings.

So we're using a list of links and giving it a heading. We're adding
styles so the page still looks like it used to, although these styles
are certainly asking for improvements.
2024-05-09 14:28:31 +02:00

29 lines
556 B
Ruby

class Admin::Stats::EventLinksComponent < ApplicationComponent
attr_reader :event_names
use_helpers :link_list
def initialize(event_names)
@event_names = event_names
end
private
def link_text(event)
text = t("admin.stats.graph.#{event}")
if text.to_s.match(/translation missing/)
text = event
end
text
end
def title
t("admin.stats.graph.title")
end
def links
event_names.map do |event|
[link_text(event), graph_admin_stats_path(event: event)]
end
end
end