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 } %> + + + + + + + + + + <% content_list.each do |document| %> + + + + + + <% end %> +
TitleLengthLast 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 + +
diff --git a/app/views/content/list/_list.html.erb b/app/views/content/list/_list.html.erb index fc44ee45..24bbe2ca 100644 --- a/app/views/content/list/_list.html.erb +++ b/app/views/content/list/_list.html.erb @@ -54,25 +54,27 @@ <% end %>

- <% content.page_tags.each do |tag| %> - <% if user_signed_in? && content.user == current_user %> - <%= - link_to send( - "page_tag_#{content.class.name.downcase.pluralize}_path", - slug: PageTagService.slug_for(tag.tag) - ) do - %> + <% if content.respond_to?(:page_tags) %> + <% content.page_tags.each do |tag| %> + <% if user_signed_in? && content.user == current_user %> + <%= + link_to send( + "page_tag_#{content.class.name.downcase.pluralize}_path", + slug: PageTagService.slug_for(tag.tag) + ) do + %> + + <% end %> + <% else %> <% end %> - <% else %> - <% end %> <% end %>

<% if user_signed_in? %> " style="font-size: 80%"> - mode_edit + mode_edit <% if content.updated_at == content.created_at diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index fdfad0de..6aa070d3 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -17,17 +17,20 @@

Recently-edited documents
<%= render partial: 'content/list/cards', locals: { content_list: @documents.first(3), content_type: Document, show_new_button: false } %> - +
+
- <%= render partial: 'content/components/list_filter_bar', locals: { content_type: Document } %>
All documents
+ <%= render partial: 'content/components/list_filter_bar', locals: { content_type: Document } %> <%= render partial: 'notice_dismissal/messages/02' %> - <%= render partial: 'content/list/cards', locals: { content_list: @documents, content_type: Document } %> + <%= render partial: 'content/list/document_table', locals: { content_list: @documents, content_type: Document } %>
<% end %> <% end %> + + <% if @documents.empty? %>