diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index 89b2a02a..947072f1 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -16,7 +16,7 @@ class DocumentsController < ApplicationController def index @page_title = "My documents" - @documents = @current_user_content.fetch('Document', []) + @documents = current_user.linkable_documents.order('favorite DESC, title ASC') @recent_documents = current_user.linkable_documents.order('updated_at DESC') end diff --git a/app/views/content/list/_document_table.html.erb b/app/views/content/list/_document_table.html.erb new file mode 100644 index 00000000..3d8b302c --- /dev/null +++ b/app/views/content/list/_document_table.html.erb @@ -0,0 +1,71 @@ +<%# Usage: render partial: 'content/list/document_table', locals: { content_list: @content, content_type: @content_type_class } %> + +
| Title | +Length | +Last edited | +
|---|---|---|
|
+
+ <%= Document.icon %>
+
+ <%
+ if document.favorite?
+ icon = 'star'
+ action = 'Unfavorite'
+ else
+ icon = 'star_border'
+ action = 'Favorite'
+ end
+ %>
+
+ <% if document.persisted? && user_signed_in? && document.user == current_user %>
+
+ <%= icon %>
+
+ <% end %>
+
+
+ <%= document.title %>
+
+
+
+ <% if current_user.can_update?(document) %>
+ <%= link_to edit_polymorphic_path(document), class: 'green white-text btn-flat', target: document.is_a?(Document) ? '_new' : '_self' do %>
+ <%= content_type.icon %>
+ Edit
+ <% end %>
+ <% end %>
+ <% if current_user.can_read?(document) %>
+ <%= link_to polymorphic_path(document), class: 'blue white-text text-lighten-1 btn-flat' do %>
+ <%= content_type.icon %>
+ View
+ <% end %>
+ <% end %>
+ <%= link_to '#', class: 'btn-flat orange white-text' do %>
+ bar_chart
+ Analyze
+ <% end %>
+
+ |
+ + <%= document.reading_estimate %> + <%# pluralize 0, 'word' %> + | ++ "> + <%= document.updated_at == document.created_at ? 'created' : 'updated' %> + <%= time_ago_in_words document.updated_at %> ago + + | +
<% if user_signed_in? %>