<% content_type_name = content_type.to_s.titleize # "Character" content_type_class = content_class_from_name(content_type_name) # Character content_type_pluralized = content_type_name.downcase.pluralize # characters category_ids_for_this_content_type = AttributeCategory.where(entity_type: content_type_name.downcase, user_id: current_user).pluck(:id) name_field = AttributeField.find_by(field_type: 'name', attribute_category_id: category_ids_for_this_content_type) content_ids = content_list.pluck(:id) if name_field list_name_lookup_cache = Hash[ name_field.attribute_values.where( entity_type: content_type_name ).pluck(:entity_id, :value) ] else list_name_lookup_cache = {} end %>
<% 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? %> <% content_list.each do |content| %> <% end %>
Name
<%= 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 %>
<% 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 %>