Only render position field on table when cards rendered are not headers

This commit is contained in:
taitus
2023-10-27 11:00:08 +02:00
parent 4e9d5d8c5a
commit bce1474527
6 changed files with 21 additions and 0 deletions

View File

@@ -9,6 +9,12 @@
<%= card.link_url %>
</td>
<% unless header_section? %>
<td>
<%= card.order %>
</td>
<% end %>
<!-- remove conditional once specs have image validations -->
<td>
<% if card.image.present? %>

View File

@@ -5,4 +5,10 @@ class Admin::Widget::Cards::RowComponent < ApplicationComponent
@card = card
@options = options
end
private
def header_section?
card.header_or_sdg_header?
end
end

View File

@@ -5,6 +5,9 @@
<th><%= attribute_name(:title) %></th>
<th class="small-4"><%= attribute_name(:description) %></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.actions") %></th>
</tr>

View File

@@ -12,4 +12,8 @@ class Admin::Widget::Cards::TableComponent < ApplicationComponent
def attribute_name(attribute)
::Widget::Card.human_attribute_name(attribute)
end
def header_section?
cards.first.header_or_sdg_header?
end
end