Browse Source

Implement `documents#search` when clicking to `subjects` Offcanvas

pull/89/head
alexdbondoc17 4 years ago
parent
commit
aef854de84
  1. 8
      app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb
  2. 2
      app/components/subjects_offcanvas_accordion_component.rb
  3. 4
      app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb
  4. 21
      app/views/documents/search.html.erb
  5. 6
      app/views/documents/show.html.erb
  6. 1
      app/views/shared/_annotation_modal_form.html.erb

8
app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb

@ -7,10 +7,10 @@
<tbody>
<% search_results.each do |search_result| %>
<tr href="<%= jurisprudence(search_result).present? ? params[:is_index_table] === "true"? document_path(jurisprudence(search_result).id)+ "?is_index_table="+params[:is_index_table] : '#' : "#"%> " class="clickable-link">
<td> <%= document_reference_number(jurisprudence(search_result)) %> </td>
<td> <%= document_title(jurisprudence(search_result)) %> </td>
<td> <%= date_or_year(jurisprudence(search_result)) %> </td>
<tr href="<%= document_path(search_result.id, is_index_table: true, subject_ids: opts[:subject_ids]) %> " class="clickable-link">
<td> <%= document_reference_number(search_result) %> </td>
<td> <%= document_title(search_result) %> </td>
<td> <%= date_or_year(search_result) %> </td>
</tr>
<% end %>
</tbody>

2
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

4
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" %>
</div>
<% 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 %>
</div>

21
app/views/documents/search.html.erb

@ -1,21 +1,8 @@
<div class="card mt-2 g-3">
<% Cdao::Subject.where(id: params[:subject_ids].split(",").map(&:strip).map(&:to_i)).each do |subject| %>
<div class="card-header mt-1 col-sm-12">
<%= subject.path.map(&:name).join(' > ') %>
</div>
<% end if %>
<div class="container-fluid mt-1 p-0 doctrine-index-body">
<div class="container-fluid m-2 p-0"> <%= render PaginationComponent.new(data: @jurisprudences, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids].split(","), is_index_table: params[:is_index_table] }) %> </div>
<hr class="mt-0"/>
<div class="card-body col-sm-12 tableFixHead p-0 mt-1">
<div class="container m-2"> <%= render PaginationComponent.new(data: @jurisprudences) %> </div>
<table class="table table-striped table-hover mb-0">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
</thead>
<tbody>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %>
</tbody>
</table>
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @jurisprudences, opts: { is_index_table: true, subject_ids: params[:subject_ids].split(",").map(&:to_i) })) %>
</div>
</div>

6
app/views/documents/show.html.erb

@ -11,7 +11,11 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<a class="<%= params[:is_index_table].present? || params[:is_citator_tab] === "true"? "d-none": '' %>" href="<%= documents_path %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% if params[:is_index_table].present? %>
<a href="<%= search_documents_path(is_index_table: true, subject_ids: params[:subject_ids].join(",")) %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% else %>
<a class="<%= params[:is_citator_tab] === "true"? "d-none": '' %>" href="<%= documents_path %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% end %>
</div>
<div class="col-lg-3 text-end">
<b>Date : </b>

1
app/views/shared/_annotation_modal_form.html.erb

@ -0,0 +1 @@
<%= render AnnotationMarksModalFormComponent.new(current_user: current_user, opts: { is_show: true }) %>
Loading…
Cancel
Save