Only render position field on table when cards rendered are not headers
This commit is contained in:
@@ -9,6 +9,12 @@
|
|||||||
<%= card.link_url %>
|
<%= card.link_url %>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<% unless header_section? %>
|
||||||
|
<td>
|
||||||
|
<%= card.order %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<!-- remove conditional once specs have image validations -->
|
<!-- remove conditional once specs have image validations -->
|
||||||
<td>
|
<td>
|
||||||
<% if card.image.present? %>
|
<% if card.image.present? %>
|
||||||
|
|||||||
@@ -5,4 +5,10 @@ class Admin::Widget::Cards::RowComponent < ApplicationComponent
|
|||||||
@card = card
|
@card = card
|
||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def header_section?
|
||||||
|
card.header_or_sdg_header?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
<th><%= attribute_name(:title) %></th>
|
<th><%= attribute_name(:title) %></th>
|
||||||
<th class="small-4"><%= attribute_name(:description) %></th>
|
<th class="small-4"><%= attribute_name(:description) %></th>
|
||||||
<th><%= attribute_name(:link_text) %> / <%= attribute_name(:link_url) %></th>
|
<th><%= attribute_name(:link_text) %> / <%= attribute_name(:link_url) %></th>
|
||||||
|
<% unless header_section? %>
|
||||||
|
<th><%= attribute_name(:order) %></th>
|
||||||
|
<% end %>
|
||||||
<th><%= t("admin.shared.image") %></th>
|
<th><%= t("admin.shared.image") %></th>
|
||||||
<th><%= t("admin.shared.actions") %></th>
|
<th><%= t("admin.shared.actions") %></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ class Admin::Widget::Cards::TableComponent < ApplicationComponent
|
|||||||
def attribute_name(attribute)
|
def attribute_name(attribute)
|
||||||
::Widget::Card.human_attribute_name(attribute)
|
::Widget::Card.human_attribute_name(attribute)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def header_section?
|
||||||
|
cards.first.header_or_sdg_header?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ describe "Cards", :admin do
|
|||||||
|
|
||||||
within("#header") do
|
within("#header") do
|
||||||
expect(page).to have_css(".homepage-card", count: 1)
|
expect(page).to have_css(".homepage-card", count: 1)
|
||||||
|
expect(page).not_to have_css "th", exact_text: "Position"
|
||||||
expect(page).to have_content "Header label"
|
expect(page).to have_content "Header label"
|
||||||
expect(page).to have_content "Header text"
|
expect(page).to have_content "Header text"
|
||||||
expect(page).to have_content "Header description"
|
expect(page).to have_content "Header description"
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ describe "SDG homepage configuration" do
|
|||||||
within(".sdg-header") do
|
within(".sdg-header") do
|
||||||
expect(page).to have_content "My header"
|
expect(page).to have_content "My header"
|
||||||
expect(page).not_to have_content "Create header"
|
expect(page).not_to have_content "Create header"
|
||||||
|
expect(page).not_to have_css "th", exact_text: "Position"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user