Add generic method for header

Unify Header to be able to use it from the admin as from the seg_management.
This commit is contained in:
taitus
2020-12-14 10:12:35 +01:00
committed by Javi Martín
parent dfec661a52
commit 6d5333fc7a
7 changed files with 13 additions and 20 deletions

View File

@@ -1,13 +0,0 @@
module Admin::Header
extend ActiveSupport::Concern
def header(options: {})
provide(:title) do
title
end
tag.h2 options do
title
end
end
end

View File

@@ -1,5 +1,5 @@
class Admin::SDG::Managers::IndexComponent < ApplicationComponent class Admin::SDG::Managers::IndexComponent < ApplicationComponent
include Admin::Header include Header
attr_reader :users attr_reader :users

View File

@@ -1,9 +1,9 @@
module SDGManagement::Header module Header
extend ActiveSupport::Concern extend ActiveSupport::Concern
def header(&block) def header(&block)
provide(:title) do provide(:title) do
"#{t("sdg_management.header.title")} - #{title}" "#{t("#{namespace}.header.title")} - #{title}"
end end
tag.header do tag.header do
@@ -14,4 +14,10 @@ module SDGManagement::Header
end end
end end
end end
private
def namespace
controller_path.split("/").first
end
end end

View File

@@ -1,5 +1,5 @@
class SDGManagement::Goals::IndexComponent < ApplicationComponent class SDGManagement::Goals::IndexComponent < ApplicationComponent
include SDGManagement::Header include Header
attr_reader :goals attr_reader :goals

View File

@@ -1,6 +1,6 @@
class SDGManagement::LocalTargets::FormComponent < ApplicationComponent class SDGManagement::LocalTargets::FormComponent < ApplicationComponent
delegate :back_link_to, to: :helpers delegate :back_link_to, to: :helpers
include SDGManagement::Header include Header
include TranslatableFormHelper include TranslatableFormHelper
include GlobalizeHelper include GlobalizeHelper

View File

@@ -1,5 +1,5 @@
class SDGManagement::LocalTargets::IndexComponent < ApplicationComponent class SDGManagement::LocalTargets::IndexComponent < ApplicationComponent
include SDGManagement::Header include Header
attr_reader :local_targets attr_reader :local_targets

View File

@@ -1,5 +1,5 @@
class SDGManagement::Targets::IndexComponent < ApplicationComponent class SDGManagement::Targets::IndexComponent < ApplicationComponent
include SDGManagement::Header include Header
attr_reader :targets attr_reader :targets