Files
grecia/app/components/concerns/header.rb
Javi Martín 4435673ace Move admin index to a component
This way we make it easier to modify.

Note that, since the title of the page is "Administration" and it's in
the "Admin" section, we're adding an option to the `header` method in
order to avoid having a confusing title like "Administration - Admin".

Also note that, by removing the `title` HTML class, we avoid inheriting
styles from the `dashboard.scss` stylesheet, and now the heading is
displayed in the position it was meant to.

Finally, the concept of using a `main-class` for the current page comes
from a branch (currently in development) which will replace the <div>
tag with the `admin-content` class with a `main` tag.
2023-10-16 15:06:15 +02:00

30 lines
723 B
Ruby

module Header
extend ActiveSupport::Concern
def header(before: nil, skip_section_title: false, &block)
provide(:title) do
[
(t("#{namespace}.header.title", default: "") unless skip_section_title),
strip_tags(title),
setting["org_name"]
].reject(&:blank?).join(" - ")
end
heading_tag = if %w[admin management moderation sdg_management valuation].include?(namespace)
"h2"
else
"h1"
end
tag.header do
safe_join([before, content_tag(heading_tag, title), (capture(&block) if block)].compact)
end
end
private
def namespace
controller_path.split("/").first
end
end