<% images = ImageUpload.where(content_type: content_type_class.to_s, content_id: relations.map { |r| r[1].id }) %>
<% if images.any? && rand(3) < 2 %>
<%= image_tag images.sample.src(:large), class: 'activator', style: 'height: 265px' %>
<% else %>
<%= image_tag "card-headers/#{content_type.to_s.pluralize}.webp", class: 'activator', style: 'height: 265px' %>
<% end %>
<% if defined? card_title %>
<%
formatted_card_title = card_title.dup
if formatted_card_title.include? ''
formatted_card_title.gsub!('', pluralize(relations.count, singular_content_type))
end
formatted_card_title[0] = formatted_card_title[0].upcase
%>
<%= formatted_card_title %>
<% else %>
<%= pluralize(relations.count, singular_content_type.to_s) %>
<% end %>
arrow_upward
<%= link_to "Create #{relations.empty? ? 'your first one!' : ['another ', singular_content_type].join}", new_polymorphic_path(singular_content_type) if current_user %>
<% if relations.any? %>
<%= content_type_class.icon %>
<% end %>
<%= content_type.to_s.titleize %>
close
<% if relations.any? %>
Relation |
<%= singular_content_type.titleize %> |
|
<% relations.each do |relation, content| %>
<%
relation.gsub!('', '')
relation.strip!
relation = relation.singularize
relation[0] = relation[0].upcase
%>
<%= relation.to_s %> |
<%= link_to content.name, content %> |
<%= link_to edit_polymorphic_path(content) do %>
edit
<% end %>
|
<% end %>
<% elsif relations.empty? %>
<%= content_type_class.icon %>
<%= t("content_descriptions.#{singular_content_type}") %>
<% button_text = relations.any? ? "Create another #{singular_content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(singular_content_type), class: "btn #{content_type_class.color}" if current_user %>
<% button_text = relations.any? ? "Create another #{singular_content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(singular_content_type), class: "btn #{content_type_class.color}" if current_user %>
<% end %>