<% images = ImageUpload.where(content_type: content_type_name, content_id: content_list.pluck(:id)) %>
<%
category_image = if rand(3) < 2 && images.any?
images.sample.src(:original)
else
asset_path("card-headers/#{content_type_pluralized}.webp")
end
%>
<% if defined?(card_title) && !card_title.blank? %>
<%= card_title %>
<% else %>
<%= pluralize(content_list.count, content_type.to_s) %>
<% end %>
<% if user_signed_in? %>
<%= link_to new_polymorphic_path(content_type), class: "btn-floating btn-large hoverable halfway-fab waves-effect waves-light #{content_type_class.color} tooltipped #{'grey' unless current_user.can_create?(content_type_class)}",
data: {
position: 'bottom',
tooltip: current_user.can_create?(content_type_class) ? "Create a#{'n' if %w(a e i o u).include?(content_type.to_s[0]) && content_type.to_s != 'universe'} #{content_type.to_s}"
: "#{content_type.to_s.pluralize.titleize} require a Premium subscription to create.",
enterDelay: 50
} do %>
add
<% end %>
<% end %>
<% if defined?(@content) && @content.is_a?(Universe) && content_type != :universe && content_type.to_s.downcase != 'universe' %>
<%= link_to send("#{content_type_pluralized}_universe_path", { id: @content.id }),
class: "btn-floating hoverable halfway-fab waves-effect waves-light grey black-text tooltipped mp-iucl-view-all",
style: "right: 90px",
data: {
position: 'bottom',
tooltip: "View all #{content_type_pluralized} in this universe",
enterDelay: 50
} do %>
reorder
<% end %>
<% else %>
<%= link_to polymorphic_path(content_type_class),
class: "btn-floating hoverable halfway-fab waves-effect waves-light grey black-text tooltipped mp-iucl-view-all",
style: "right: 90px",
data: {
position: 'bottom',
tooltip: "View all #{content_type_pluralized}",
enterDelay: 50
} do %>
reorder
<% end %>
<% end %>
<% if content_list.any? %>
<%= content_type_class.icon %>
<% end %>
<% if defined?(@content) && @content.is_a?(Universe) && content_type != :universe && content_type.to_s.downcase != 'universe' %>
<%= link_to content_type_pluralized.titleize, send("#{content_type_pluralized}_universe_path", { id: @content.id }), class: "#{content_type_class.text_color}" %>
<% else %>
<%= content_type_pluralized.titleize %>
<% end %>
close
<% if content_list.any? %>
Name |
|
|
<% content_list.each do |content| %>
<%= link_to polymorphic_path(content.page_type.downcase, id: content.id) do %>
<%= content_type_class.icon %>
<%= list_name_lookup_cache[content.id].presence || content.name.presence || "Untitled #{content.page_type}" %>
<% end %>
|
<%= truncate(content.description, length: 200) %> |
<%= link_to edit_polymorphic_path(content.page_type.downcase, id: content.id) do %>
edit
<% end %>
|
<% end %>
<% if defined?(@content) && @content.is_a?(Universe) && content_type != :universe && content_type.to_s.downcase != 'universe' %>
<%= link_to "Browse #{content_type_pluralized}", send("#{content_type_pluralized}_universe_path", { id: @content.id }), class: "btn #{content_type_class.color} lighten-1" %>
<% else %>
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(content_type), class: "btn #{content_type_class.color}" if user_signed_in? %>
<% end %>
<% elsif content_list.empty? %>
<%= content_type_class.icon %>
<%= t("content_descriptions.#{content_type}") %>
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(content_type), class: "btn #{content_type_class.color}" if user_signed_in? %>
<% button_text = content_list.any? ? "Create another #{content_type}" : "Create one" %>
<%= link_to button_text, new_polymorphic_path(content_type), class: "btn #{content_type_class.color}" if user_signed_in? %>
<% end %>