From 56e26e8344328f98631b804bf47c1ed25c32ef23 Mon Sep 17 00:00:00 2001 From: alexdbondoc17 Date: Wed, 2 Mar 2022 01:32:49 +0000 Subject: [PATCH] Implement `documents#search` when clicking to `subjects` Offcanvas --- .../doctrine_index_table_component.html.erb | 8 +++---- .../subjects_offcanvas_accordion_component.rb | 2 +- .../subjects_offcanvas_component.html.erb | 4 ++-- app/views/documents/search.html.erb | 21 ++++--------------- app/views/documents/show.html.erb | 6 +++++- .../shared/_annotation_modal_form.html.erb | 1 + 6 files changed, 17 insertions(+), 25 deletions(-) create mode 100644 app/views/shared/_annotation_modal_form.html.erb diff --git a/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb b/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb index 8e6cb01..0135325 100644 --- a/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb +++ b/app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb @@ -7,10 +7,10 @@ <% search_results.each do |search_result| %> - " class="clickable-link"> - <%= document_reference_number(jurisprudence(search_result)) %> - <%= document_title(jurisprudence(search_result)) %> - <%= date_or_year(jurisprudence(search_result)) %> + + <%= document_reference_number(search_result) %> + <%= document_title(search_result) %> + <%= date_or_year(search_result) %> <% end %> diff --git a/app/components/subjects_offcanvas_accordion_component.rb b/app/components/subjects_offcanvas_accordion_component.rb index 2f445bc..31782af 100644 --- a/app/components/subjects_offcanvas_accordion_component.rb +++ b/app/components/subjects_offcanvas_accordion_component.rb @@ -34,6 +34,6 @@ class SubjectsOffcanvasAccordionComponent < BaseComponent end def index_url - search_doctrines_path(subject_ids: [search_result["id"]], is_index_table: true) + search_documents_path(subject_ids: search_result["id"], is_index_table: true) end end diff --git a/app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb b/app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb index c75633e..3103d4a 100644 --- a/app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb +++ b/app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb @@ -15,10 +15,10 @@ data-controller="subjects" data-subject-parent-id="<%= root.id %>" data-accordion-target="#<%= ['subjectsOffCanvasAccordionBody', root.id].join %>" data-action="click->subjects#loadSubjectsOffcanvasAccordion"> - <%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> + <%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <% else %> - <%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> + <%= link_to root.name, search_documents_path(subject_ids: root.id, is_index_table: true), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %> <% end %> diff --git a/app/views/documents/search.html.erb b/app/views/documents/search.html.erb index 5a9bba0..9e7fee8 100644 --- a/app/views/documents/search.html.erb +++ b/app/views/documents/search.html.erb @@ -1,21 +1,8 @@ -
- <% Cdao::Subject.where(id: params[:subject_ids].split(",").map(&:strip).map(&:to_i)).each do |subject| %> -
- <%= subject.path.map(&:name).join(' > ') %> -
- <% end if %> +
+
<%= render PaginationComponent.new(data: @jurisprudences, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids].split(","), is_index_table: params[:is_index_table] }) %>
+
-
<%= render PaginationComponent.new(data: @jurisprudences) %>
- - - - - - - - <%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %> - -
Reference No. Title Date
+ <%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @jurisprudences, opts: { is_index_table: true, subject_ids: params[:subject_ids].split(",").map(&:to_i) })) %>
diff --git a/app/views/documents/show.html.erb b/app/views/documents/show.html.erb index f4d3135..3a6792f 100644 --- a/app/views/documents/show.html.erb +++ b/app/views/documents/show.html.erb @@ -11,7 +11,11 @@
- " href="<%= documents_path %>"> + <% if params[:is_index_table].present? %> + "> + <% else %> + " href="<%= documents_path %>"> + <% end %>
Date : diff --git a/app/views/shared/_annotation_modal_form.html.erb b/app/views/shared/_annotation_modal_form.html.erb new file mode 100644 index 0000000..d8150fc --- /dev/null +++ b/app/views/shared/_annotation_modal_form.html.erb @@ -0,0 +1 @@ +<%= render AnnotationMarksModalFormComponent.new(current_user: current_user, opts: { is_show: true }) %>