Do not render "Number of colums" when create a sdg header card
Co-authored-by: Javi Martín <javim@elretirao.net>
This commit is contained in:
@@ -11,7 +11,7 @@ class Admin::Widget::Cards::EditComponent < ApplicationComponent
|
|||||||
private
|
private
|
||||||
|
|
||||||
def title
|
def title
|
||||||
if card.header?
|
if card.header_or_sdg_header?
|
||||||
t("admin.homepage.edit.header_title")
|
t("admin.homepage.edit.header_title")
|
||||||
else
|
else
|
||||||
t("admin.homepage.edit.card_title")
|
t("admin.homepage.edit.card_title")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Admin::Widget::Cards::NewComponent < ApplicationComponent
|
|||||||
private
|
private
|
||||||
|
|
||||||
def title
|
def title
|
||||||
if card.header?
|
if card.header_or_sdg_header?
|
||||||
t("admin.homepage.new.header_title")
|
t("admin.homepage.new.header_title")
|
||||||
else
|
else
|
||||||
t("admin.homepage.new.card_title")
|
t("admin.homepage.new.card_title")
|
||||||
|
|||||||
@@ -18,4 +18,12 @@ class Widget::Card < ApplicationRecord
|
|||||||
def self.body
|
def self.body
|
||||||
where(header: false, cardable_id: nil).order(:created_at)
|
where(header: false, cardable_id: nil).order(:created_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def header_or_sdg_header?
|
||||||
|
header? || sdg_header?
|
||||||
|
end
|
||||||
|
|
||||||
|
def sdg_header?
|
||||||
|
cardable == WebSection.find_by!(name: "sdg")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<% unless card.header? %>
|
<% unless card.header_or_sdg_header? %>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<%= f.label :columns %>
|
<%= f.label :columns %>
|
||||||
<p class="help-text"><%= t("admin.site_customization.pages.cards.columns_help") %></p>
|
<p class="help-text"><%= t("admin.site_customization.pages.cards.columns_help") %></p>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<%= f.submit(
|
<%= 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"
|
class: "button success"
|
||||||
) %>
|
) %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ describe "SDG homepage configuration" do
|
|||||||
visit sdg_management_homepage_path
|
visit sdg_management_homepage_path
|
||||||
click_link "Create planning card"
|
click_link "Create planning card"
|
||||||
|
|
||||||
|
expect(page).to have_field "Number of columns"
|
||||||
|
|
||||||
within(".translatable-fields") { fill_in "Title", with: "My planning card" }
|
within(".translatable-fields") { fill_in "Title", with: "My planning card" }
|
||||||
fill_in "Link URL", with: "/any_path"
|
fill_in "Link URL", with: "/any_path"
|
||||||
click_button "Create card"
|
click_button "Create card"
|
||||||
@@ -54,9 +56,11 @@ describe "SDG homepage configuration" do
|
|||||||
visit sdg_management_homepage_path
|
visit sdg_management_homepage_path
|
||||||
click_link "Create header"
|
click_link "Create header"
|
||||||
|
|
||||||
|
expect(page).not_to have_field "Number of columns"
|
||||||
|
|
||||||
within(".translatable-fields") { fill_in "Title", with: "My header" }
|
within(".translatable-fields") { fill_in "Title", with: "My header" }
|
||||||
fill_in "Link URL", with: "/any_path"
|
fill_in "Link URL", with: "/any_path"
|
||||||
click_button "Create card"
|
click_button "Create header"
|
||||||
|
|
||||||
within(".sdg-header") do
|
within(".sdg-header") do
|
||||||
expect(page).to have_content "My header"
|
expect(page).to have_content "My header"
|
||||||
@@ -72,7 +76,7 @@ describe "SDG homepage configuration" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
within(".translatable-fields") { fill_in "Title", with: "My header update" }
|
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"
|
expect(page).to have_content "My header update"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user