diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 32994c9e..09ca3920 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -22,8 +22,6 @@ class MainController < ApplicationController def dashboard return redirect_to new_user_session_path unless user_signed_in? - @content_types = @activated_content_types - set_random_content # for questions end diff --git a/app/views/content/cards/_in_universe_content_list.html.erb b/app/views/content/cards/_in_universe_content_list.html.erb index 30641b41..9f16bdd9 100644 --- a/app/views/content/cards/_in_universe_content_list.html.erb +++ b/app/views/content/cards/_in_universe_content_list.html.erb @@ -2,7 +2,21 @@ content_type_name = content_type.to_s.titleize # "Character" content_type_class = content_type_name.constantize # 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) + # todo description field + + content_ids = content_list.pluck(:id) + list_name_lookup_cache = Hash[ + name_field.attribute_values.where( + entity_type: content_type_name + ).pluck(:entity_id, :value) + ] + + #raise list_name_lookup_cache.inspect %> +
| Name | - +||
|---|---|---|
| <%= link_to content.name_field_value, polymorphic_path(content) %> | - +<%= link_to list_name_lookup_cache[content.id].presence || content.name, polymorphic_path(content) %> | +
<%= link_to edit_polymorphic_path(content) do %>
diff --git a/app/views/content/list/_list.html.erb b/app/views/content/list/_list.html.erb
index d5dbcaea..9d9e2676 100644
--- a/app/views/content/list/_list.html.erb
+++ b/app/views/content/list/_list.html.erb
@@ -1,5 +1,18 @@
<%# Usage: render partial: 'content/list/list', locals: { content_list: @content, content_type: @content_type_class, show_add_another_form: true } %>
+<%
+ 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)
+ # todo description field
+
+ content_ids = content_list.pluck(:id)
+ list_name_lookup_cache = Hash[
+ name_field.attribute_values.where(
+ entity_type: content_type.name
+ ).pluck(:entity_id, :value)
+ ]
+%>
+
- <%= content.description %> + <%# content.description %> @@ -58,7 +71,7 @@ <% end %> |