From e9383af20c03ca8dbdfec310564e44fd294b2fda Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Thu, 17 Jun 2021 20:42:41 -0700 Subject: [PATCH] show recent docs --- app/controllers/documents_controller.rb | 25 ++++++----- app/views/content/list/_cards.html.erb | 60 +++++++++++++------------ app/views/documents/index.html.erb | 18 ++++++-- 3 files changed, 59 insertions(+), 44 deletions(-) diff --git a/app/controllers/documents_controller.rb b/app/controllers/documents_controller.rb index e89a3efa..89b2a02a 100644 --- a/app/controllers/documents_controller.rb +++ b/app/controllers/documents_controller.rb @@ -16,7 +16,8 @@ class DocumentsController < ApplicationController def index @page_title = "My documents" - @documents = @current_user_content['Document'] + @documents = @current_user_content.fetch('Document', []) + @recent_documents = current_user.linkable_documents.order('updated_at DESC') end def show @@ -234,18 +235,18 @@ class DocumentsController < ApplicationController @navbar_actions = [] return unless user_signed_in? - if @current_user_content && @current_user_content['Document'].present? - @navbar_actions << { - label: "Your #{@current_user_content['Document'].count} Document#{'s' unless @navbar_actions == 1}", - href: documents_path - } - end + # if @current_user_content && @current_user_content['Document'].present? + # @navbar_actions << { + # label: "Your #{@current_user_content['Document'].count} Document#{'s' unless @navbar_actions == 1}", + # href: documents_path + # } + # end - @navbar_actions << { - label: "New Document", - href: new_document_path, - target: '_blank' - } + # @navbar_actions << { + # label: "New Document", + # href: new_document_path, + # target: '_blank' + # } end def set_footer_visibility diff --git a/app/views/content/list/_cards.html.erb b/app/views/content/list/_cards.html.erb index 285d10c9..03dd14dc 100644 --- a/app/views/content/list/_cards.html.erb +++ b/app/views/content/list/_cards.html.erb @@ -97,39 +97,41 @@ <% end %> - <% if current_user.can_create?(content_type) %> -
- <%= link_to new_polymorphic_path(content_type), class: 'white-text' do %> -
-
-

- add + <% if local_assigns.fetch(:show_new_button, true) %> + <% if current_user.can_create?(content_type) %> +

+ <%= link_to new_polymorphic_path(content_type), class: 'white-text' do %> +
+
+

+ add +

+ + New
+ <%= content_type.name %> +
+
+
+ <% end %> +
+ <% else %> +
+
+
+

+ <%= content_type.icon %> +

+

+ An active + <%= link_to 'Notebook.ai Premium', subscription_path, class: 'blue-text text-darken-2' %> subscription + is required to create additional + <%= content_type.name.downcase %> pages, but pages you've already created will always + be available here.

- - New
- <%= content_type.name %> -
- <% end %> -
- <% else %> -
-
-
-

- <%= content_type.icon %> -

-

- An active - <%= link_to 'Notebook.ai Premium', subscription_path, class: 'blue-text text-darken-2' %> subscription - is required to create additional - <%= content_type.name.downcase %> pages, but pages you've already created will always - be available here. -

-
-
+ <% end %> <% end %> <% if local_assigns.fetch(:show_template_editor_form, false) %> diff --git a/app/views/documents/index.html.erb b/app/views/documents/index.html.erb index 5d6e1b89..fdfad0de 100644 --- a/app/views/documents/index.html.erb +++ b/app/views/documents/index.html.erb @@ -11,9 +11,21 @@ <% end %> <% if @documents.any? %> - <%= 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 } %> + <%= content_for :full_width_page_content do %> +
+
+
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: 'notice_dismissal/messages/02' %> + <%= render partial: 'content/list/cards', locals: { content_list: @documents, content_type: Document } %> +
+
+ <% end %> <% end %> <% if @documents.empty? %>