From f32f5e7f5a4cf314849eedb01d0e98bb0b5908c9 Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Wed, 2 Feb 2022 09:10:21 +0000 Subject: [PATCH] Implement `subjects#doctrines` UI --- .../document_doctrine_index_component.rb | 8 ++++ ...document_doctrine_index_component.html.erb | 48 +++++++++++-------- .../sidenav_component.html.erb | 20 +------- .../subjects_sidenav_sub_menu_component.rb | 6 ++- ...bjects_sidenav_sub_menu_component.html.erb | 20 ++++---- app/controllers/subject_indexes_controller.rb | 4 +- app/views/doctrines/index.html.erb | 4 +- app/views/documents/show.html.erb | 2 +- app/views/subject_indexes/show.html.erb | 27 ++--------- 9 files changed, 62 insertions(+), 77 deletions(-) diff --git a/app/components/document_doctrine_index_component.rb b/app/components/document_doctrine_index_component.rb index 94bb04a..3a84c62 100644 --- a/app/components/document_doctrine_index_component.rb +++ b/app/components/document_doctrine_index_component.rb @@ -21,4 +21,12 @@ class DocumentDoctrineIndexComponent < BaseComponent def annotation_form_url doctrine_annotations_path(doctrine_id: id) end + + def subject_names + "(No Subjects Provided)" + end + + def render? + doctrine.present? && doctrine.persisted? + end end diff --git a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb index 7a7adb4..3496bc1 100644 --- a/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb +++ b/app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb @@ -1,23 +1,31 @@ -<% if id.present? %> - -
-
- <% Cdao::Subject.roots.each do |root| %> -
-
-
- <% if root.children.present? %> - - <% else %> -
<%= link_to root.name, search_documensearch_subject_indexes_pathts_path(subject_ids: root.id), class: "accordion-link text-decoration-none text-dark" %>
- <% end %> -
-
-
- <% end %> -
-
+ <%= render(SubjectsSidenavSubMenuComponent.new(current_user: current_user, opts: { is_subjects_index: true, main_sub_menu: "mainSubjectIndexSubMenu", second_sub_menu: "secondSubjectIndexSubMenu", third_sub_menu: "thirdSubjectIndexSubMenu", fourth_sub_menu: "fourthSubjectIndexSubMenu", fifth_sub_menu: "fifthSubjectIndexSubMenu" })) %>
diff --git a/app/components/subjects_sidenav_sub_menu_component.rb b/app/components/subjects_sidenav_sub_menu_component.rb index ccde43a..d26651d 100644 --- a/app/components/subjects_sidenav_sub_menu_component.rb +++ b/app/components/subjects_sidenav_sub_menu_component.rb @@ -5,7 +5,9 @@ class SubjectsSidenavSubMenuComponent < BaseComponent @opts = opts end - def doctrines_search_url(subject_id) - doctrines_path(subject_ids: [subject_id]) + def index_url(subject_id) + return doctrines_path(subject_ids: [subject_id]) if opts[:is_doctrines_index].present? + + subject_index_path(subject_id) end end diff --git a/app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb b/app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb index a5c862d..eb2163d 100644 --- a/app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb +++ b/app/components/subjects_sidenav_sub_menu_component/subjects_sidenav_sub_menu_component.html.erb @@ -6,10 +6,10 @@
<% if root.children.present? %> <% else %> -
<%= link_to root.name, search_documents_path(subject_ids: root.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
+
<%= link_to root.name, index_url(root.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
<% end %>
@@ -22,10 +22,10 @@
<% if sub1.children.present? %> <% else %> -
<%= link_to sub1.name, search_documents_path(subject_ids: sub1.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
+
<%= link_to sub1.name, index_url(sub1.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
<% end %>
@@ -37,10 +37,10 @@
<% if sub2.children.present? %> <% else %> -
<%= link_to sub2.name, search_documents_path(subject_ids: sub2.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
+
<%= link_to sub2.name, index_url(sub2.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
<% end %> @@ -51,11 +51,11 @@
<% if sub3.children.present? %> - <% else%> -
<%= link_to sub3.name, search_documents_path(subject_ids: sub3.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
+
<%= link_to sub3.name, index_url(sub3.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
<% end %> @@ -64,7 +64,7 @@ <% sub3.children.each do |sub4| %>
- <%= link_to sub4.name, doctrines_path(subject_ids: [sub4.id]), class: "accordion-link text-decoration-none text-dark clickable-link" %> + <%= link_to sub4.name, index_url(sub4.id), class: "accordion-link text-decoration-none text-dark clickable-link" %>
<% end if sub3.children.present? %> diff --git a/app/controllers/subject_indexes_controller.rb b/app/controllers/subject_indexes_controller.rb index b30581c..5546125 100644 --- a/app/controllers/subject_indexes_controller.rb +++ b/app/controllers/subject_indexes_controller.rb @@ -9,7 +9,9 @@ class SubjectIndexesController < ApplicationController def edit; end - def show; end + def show + @doctrines = @subject_index.doctrines + end def search @search = search_subject(search_params) diff --git a/app/views/doctrines/index.html.erb b/app/views/doctrines/index.html.erb index 7cd73ed..af9baea 100644 --- a/app/views/doctrines/index.html.erb +++ b/app/views/doctrines/index.html.erb @@ -1,3 +1,3 @@ -
- <%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_index: true })) %> +
+ <%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_disable_clickable_link: true, is_doctrines_index: true, subject_ids: params[:subject_ids] })) %>
diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb index 7058286..e0f3e2f 100644 --- a/app/views/documents/show.html.erb +++ b/app/views/documents/show.html.erb @@ -17,7 +17,7 @@
-
+