diff --git a/app/components/admin/widget/cards/edit_component.rb b/app/components/admin/widget/cards/edit_component.rb index 5a5734f0a..4c9b7d263 100644 --- a/app/components/admin/widget/cards/edit_component.rb +++ b/app/components/admin/widget/cards/edit_component.rb @@ -11,7 +11,7 @@ class Admin::Widget::Cards::EditComponent < ApplicationComponent private def title - if card.header? + if card.header_or_sdg_header? t("admin.homepage.edit.header_title") else t("admin.homepage.edit.card_title") diff --git a/app/components/admin/widget/cards/new_component.rb b/app/components/admin/widget/cards/new_component.rb index 5e195f9d4..5bb856344 100644 --- a/app/components/admin/widget/cards/new_component.rb +++ b/app/components/admin/widget/cards/new_component.rb @@ -11,7 +11,7 @@ class Admin::Widget::Cards::NewComponent < ApplicationComponent private def title - if card.header? + if card.header_or_sdg_header? t("admin.homepage.new.header_title") else t("admin.homepage.new.card_title") diff --git a/app/models/widget/card.rb b/app/models/widget/card.rb index 835defe6c..cdf28776b 100644 --- a/app/models/widget/card.rb +++ b/app/models/widget/card.rb @@ -18,4 +18,12 @@ class Widget::Card < ApplicationRecord def self.body where(header: false, cardable_id: nil).order(:created_at) end + + def header_or_sdg_header? + header? || sdg_header? + end + + def sdg_header? + cardable == WebSection.find_by!(name: "sdg") + end end diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb index d01dc0cc1..3ea238768 100644 --- a/app/views/admin/widget/cards/_form.html.erb +++ b/app/views/admin/widget/cards/_form.html.erb @@ -30,7 +30,7 @@
- <% unless card.header? %> + <% unless card.header_or_sdg_header? %>
<%= f.label :columns %>

<%= t("admin.site_customization.pages.cards.columns_help") %>

@@ -50,7 +50,7 @@
<%= f.submit( - t("admin.homepage.#{admin_submit_action(card)}.#{card.header? ? "submit_header" : "submit_card"}"), + t("admin.homepage.#{admin_submit_action(card)}.#{card.header_or_sdg_header? ? "submit_header" : "submit_card"}"), class: "button success" ) %>
diff --git a/spec/system/sdg_management/homepage_spec.rb b/spec/system/sdg_management/homepage_spec.rb index bc60cc7b2..715ae9249 100644 --- a/spec/system/sdg_management/homepage_spec.rb +++ b/spec/system/sdg_management/homepage_spec.rb @@ -21,6 +21,8 @@ describe "SDG homepage configuration" do visit sdg_management_homepage_path click_link "Create planning card" + expect(page).to have_field "Number of columns" + within(".translatable-fields") { fill_in "Title", with: "My planning card" } fill_in "Link URL", with: "/any_path" click_button "Create card" @@ -54,9 +56,11 @@ describe "SDG homepage configuration" do visit sdg_management_homepage_path click_link "Create header" + expect(page).not_to have_field "Number of columns" + within(".translatable-fields") { fill_in "Title", with: "My header" } fill_in "Link URL", with: "/any_path" - click_button "Create card" + click_button "Create header" within(".sdg-header") do expect(page).to have_content "My header" @@ -72,7 +76,7 @@ describe "SDG homepage configuration" do end within(".translatable-fields") { fill_in "Title", with: "My header update" } - click_button "Save card" + click_button "Save header" expect(page).to have_content "My header update" end