Browse Source

Enhance UI for `analysis ttab` in `documents#show`

pull/119/head
alexdbondoc17 4 years ago
parent
commit
7d79f9d9f4
  1. 15
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  2. 1
      app/controllers/documents_controller.rb
  3. 21
      app/views/documents/show.html.erb

15
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -1,24 +1,9 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"> <div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>">
<% if opts[:is_doctrines_index].blank? %>
<% if opts[:is_subjects_index].blank? %>
<% if opts[:is_doctrines_index].present? && opts[:subject_ids].reject(&:blank?).present? %>
<h5 style="color: darkred;"> <%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join(" ") %> </h5>
<% elsif subjects.present? %>
<% subjects.each do |subject| %>
<h5 style="color: darkred;"> <%= subject.lineage_name %> </h5>
<% end %>
<% else %>
<h5> (No Subjects Provided) </h5>
<% end %>
<% end %>
<% end %>
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>"> <div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<span> <b> <i> <%= headnote %> </i> </b> </span> <span> <b> <i> <%= headnote %> </i> </b> </span>
<p class="mb-0"> <%= raw content.html_safe %> </p> <p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0"> <div class="container-fluid p-0">
<% if opts[:is_doctrines_index].present? %> <% if opts[:is_doctrines_index].present? %>
<% document_title = jurisprudence.short_title || jurisprudence.title %> <% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>

1
app/controllers/documents_controller.rb

@ -16,7 +16,6 @@ class DocumentsController < ApplicationController
end end
def show def show
@subjects = Cdao::Subject.all
@doctrines = @document.doctrines.sort_by { |doctrine| [-doctrine.jurisprudences.first.year, -doctrine.jurisprudences.first.docdate.strftime("%Y-%m-%d")] } @doctrines = @document.doctrines.sort_by { |doctrine| [-doctrine.jurisprudences.first.year, -doctrine.jurisprudences.first.docdate.strftime("%Y-%m-%d")] }
where = { enabled: true, state: "published" } where = { enabled: true, state: "published" }

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

@ -73,7 +73,26 @@
</div> </div>
<div class="container-sm row-flex col-sm-12 p-0 doct-body-index" id="doctrinesIndexView"> <div class="container-sm row-flex col-sm-12 p-0 doct-body-index" id="doctrinesIndexView">
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines.sort_by { |doctrine| [-doctrine.doctrine_jurisprudences.first.jurisprudence.doc_date.strftime("%Y-%m-%d")] }, current_user: current_user, opts: { document_id: @document.id })) %> <div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="accordion accordion-flush" id="documentSubjectsAccordion">
<% @document.subjects.sort_by { |sub| sub.lineage_name }.each_with_index do |subject, i| %>
<div class="accordion-item">
<div class="accordion-header">
<div class="accordion-button collapsed m-0 p-0" data-bs-toggle="collapse" data-bs-target="#documentSubjectsAccordionBody<%= subject.id %>">
<h5 style="color: darkred;"> <%= subject.lineage_name %> </h5>
</div>
</div>
<% doctrines = @document.doctrines.includes(:doctrine_subjects).where(doctrine_subjects: { subject_id: subject.id }) %>
<div class="accordion-collapse collapse <%= i.eql?(0) ? 'show' : '' %>" id="documentSubjectsAccordionBody<%= subject.id %>" data-bs-parent="#documentSubjectsAccordion">
<div class="accordion-body pt-1 pb-1 sub-body1">
<%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { document_id: @document.id })) %>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div> </div>
</div> </div>

Loading…
Cancel
Save