Browse Source

Enhance UI for `documents`, `doctrines`, and `annotations#form`

pull/128/head
alexdbondoc17 4 years ago
parent
commit
411896fc81
  1. 25
      app/components/annotation_form_component.rb
  2. 2
      app/components/doctrine_index_component.rb
  3. 10
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  4. 14
      app/components/document_doctrine_show_component.rb
  5. 10
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  6. 24
      app/components/document_index_table_component.rb
  7. 25
      app/components/jurisprudences_index_table_component.rb
  8. 2
      app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb
  9. 2
      app/controllers/doctrines_controller.rb
  10. 9
      app/controllers/documents_controller.rb
  11. 1
      app/javascript/controllers/document_controller.js
  12. 66
      app/jobs/parse_linkable_content_job.rb
  13. 7
      app/models/cdao/document.rb
  14. 5
      app/models/cdao/jurisprudence.rb
  15. 6
      app/views/doctrines/new.html.erb
  16. 11
      app/views/doctrines/search.html.erb
  17. 2
      app/views/doctrines/show.html.erb
  18. 6
      app/views/document/doctrines/show.html.erb
  19. 2
      app/views/documents/index.html.erb
  20. 25
      app/views/documents/show.html.erb

25
app/components/annotation_form_component.rb

@ -12,13 +12,34 @@ class AnnotationFormComponent < BaseComponent
Cdao::Document.find(opts[:document_id].to_i) Cdao::Document.find(opts[:document_id].to_i)
end end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def display_text def display_text
return annotation.content if annotation.persisted? return annotation.content if annotation.persisted? && annotation.content.present? && annotation.content.include?("Phil")
display_text = nil
title = document.short_title || document.title title = document.short_title || document.title
year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
[title, document.clean_reference_number, year_or_date].join(", ") if annotation.new_record?
display_text = [title, document.clean_reference_number, year_or_date].join(", ")
else
contents = [[title, document.clean_reference_number, year_or_date].reject(&:blank?).join(", ")]
annotation.documents.each do |citing_doc|
citing_doc_title = citing_doc.short_title || citing_doc.title
citing_doc_year_or_date = citing_doc.doc_date.present? ? citing_doc.doc_date.strftime("%B %d, %Y") : citing_doc.year
contents << [citing_doc_title, citing_doc.clean_reference_number, citing_doc_year_or_date].join(", ")
end
display_text = contents.reject(&:blank?).join(" citing ")
end
display_text
end end
def phil_rep def phil_rep

2
app/components/doctrine_index_component.rb

@ -43,7 +43,7 @@ class DoctrineIndexComponent < BaseComponent
annotation.document.year annotation.document.year
end end
def show_url def doctrine_show_url
return document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) if jurisprudence.present? return document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) if jurisprudence.present?
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))

10
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -1,15 +1,13 @@
<p class="mb-0 clickable-link" href="<%= show_url %>"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0"> <div class="container-fluid p-0">
<% 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.doc_date.present? ? jurisprudence.doc_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 class="clickable-link" style="color: darkred;" href="<%= document_path(jurisprudence, is_index_table: false, subject_ids: params[:subject_ids]) %>"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5> <h5 class="clickable-link" style="color: darkred;" href="<%= document_path(jurisprudence.document.id, is_index_table: false, subject_ids: params[:subject_ids]) %>"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5>
<% annotations.each do |annotation| %> <% annotations.each do |annotation| %>
<% annotated_documents_title = [] %> <% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %> <% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> <% ad_date_or_year = annotated_document.doc_date.present? ? annotated_document.doc_date.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %> <% end %>
<% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %> <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
@ -20,7 +18,7 @@
</div> </div>
<% if annotation.editor_notes.present? %> <% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2 clickable-link" href="<%= show_url %>"> <div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;"> <div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span> <span> Editors Note: </span>
</div> </div>

14
app/components/document_doctrine_show_component.rb

@ -1,12 +1,11 @@
class DocumentDoctrineShowComponent < BaseComponent class DocumentDoctrineShowComponent < BaseComponent
attr_reader :current_user, :annotations, :jurisprudence_id, :doctrine, :subjects attr_reader :current_user, :doctrine, :opts
def initialize(current_user:, annotations:, doctrine:, jurisprudence_id:, subjects:, opts: {}) include AnnotationSearch
@annotations = annotations
def initialize(current_user:, doctrine:, opts: {})
@doctrine = doctrine @doctrine = doctrine
@jurisprudence_id = jurisprudence_id
@current_user = current_user @current_user = current_user
@subjects = subjects
@opts = opts @opts = opts
end end
@ -49,4 +48,9 @@ class DocumentDoctrineShowComponent < BaseComponent
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ") contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ") contents.join(" citing ")
end end
def annotations
search = annotation_search(doctrine_id: id)
search.results
end
end end

10
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -5,8 +5,8 @@
<h5> <b>Doctrine Details</b> </h5> <h5> <b>Doctrine Details</b> </h5>
</div> </div>
<div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>" > <div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>" >
<a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: jurisprudence_id) %>"> Edit </a> <a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: opts[:jurisprudence_id]) %>"> Edit </a>
<a class="btn btn-danger " data-action="click->doctrines#delete" > Delete </a> <a class="btn btn-danger " data-action="click->doctrines#delete" > Delete </a>
</div> </div>
</div> </div>
@ -56,7 +56,7 @@
</div> </div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse"> <div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>"> <div class="row" data-controller="document" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>">
<div class="col-sm-10 p-2"> <div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %> <%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
</div> </div>
@ -101,10 +101,10 @@
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div> <div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
<div class="col-sm-2 d-flex justify-content-end align-items-baseline"> <div class="col-sm-2 d-flex justify-content-end align-items-baseline">
<a class="btn btn-secondary btn-sm me-1" href="<%= edit_doctrine_annotation_path(annotation.doctrine_id, annotation.id, jurisprudence_id: jurisprudence_id, document_id: annotation.document_id) %>"> <a class="btn btn-secondary btn-sm me-1" href="<%= edit_doctrine_annotation_path(annotation.doctrine_id, annotation.id, jurisprudence_id: opts[:jurisprudence_id], document_id: annotation.document_id) %>">
Edit Edit
</a> </a>
<a class="btn btn-danger btn-sm ms-1" data-controller="annotations" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a> <a class="btn btn-danger btn-sm ms-1" data-controller="annotations" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a>
</div> </div>
</div> </div>

24
app/components/document_index_table_component.rb

@ -1,24 +0,0 @@
class DocumentIndexTableComponent < BaseComponent
with_collection_parameter :search_result
attr_reader :search_result, :opts
def initialize(search_result:, current_user:, opts: {})
@search_result = search_result
@opts = opts
end
delegate :id, to: :search_result
delegate :clean_reference_number, to: :search_result
delegate :title, to: :search_result
delegate :short_title, to: :search_result
def date_or_year
return search_result.docdate.strftime("%m/%d/%Y") if search_result.docdate.present?
search_result.year
end
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
end

25
app/components/jurisprudences_index_table_component.rb

@ -0,0 +1,25 @@
class JurisprudencesIndexTableComponent < BaseComponent
with_collection_parameter :jurisprudence
attr_reader :jurisprudence, :opts
def initialize(jurisprudence:, current_user:, opts: {})
@jurisprudence = jurisprudence
@opts = opts
end
delegate :id, to: :jurisprudence
delegate :clean_reference_number, to: :jurisprudence
delegate :title, to: :jurisprudence
delegate :short_title, to: :jurisprudence
delegate :document, to: :jurisprudence
def date_or_year
return jurisprudence.docdate.strftime("%B %d, %Y") if jurisprudence.docdate.present?
jurisprudence.year
end
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
end

2
app/components/document_index_table_component/document_index_table_component.html.erb → app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb

@ -1,4 +1,4 @@
<tr href="<%= document_path(id) %>" class="clickable-link" target="_blank"> <tr href="<%= document_path(document.id) %>" class="clickable-link" target="_blank">
<td> <%= clean_reference_number %> </td> <td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td> <td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td> <td> <%= date_or_year %> </td>

2
app/controllers/doctrines_controller.rb

@ -21,7 +21,7 @@ class DoctrinesController < ApplicationController
@search = doctrine_search(search_params) @search = doctrine_search(search_params)
@results = @search.results @results = @search.results
@uniq_doctrines = @results.uniq(&:headnote) @uniq_by_headnotes = @results.uniq(&:headnote)
respond_to do |format| respond_to do |format|
format.html format.html

9
app/controllers/documents_controller.rb

@ -2,7 +2,8 @@ class DocumentsController < ApplicationController
include JurisprudenceSearch include JurisprudenceSearch
include DoctrineSearch include DoctrineSearch
load_and_authorize_resource :document, class: "Cdao::Jurisprudence" load_and_authorize_resource :document, class: "Cdao::Jurisprudence", only: %i[index search]
load_and_authorize_resource :document, class: "Cdao::Document", only: %i[show]
def index def index
@search_params = search_params @search_params = search_params
@ -16,11 +17,13 @@ class DocumentsController < ApplicationController
end end
def show def show
@doctrines = @document.doctrines.sort_by { |doctrine| [-doctrine.jurisprudences.first.year, -doctrine.jurisprudences.first.docdate.strftime("%Y-%m-%d")] } if @document.library.document_type.eql?(Cdao::Library.first.document_type)
@jurisprudence = Cdao::Jurisprudence.find(@document.doc_id)
where = { enabled: true, state: "published" } where = { enabled: true, state: "published" }
@cited_in_documents = @document.class.citing_docs_of(@document, where) @cited_in_documents = @jurisprudence.class.citing_docs_of(@jurisprudence, where)
@paginated_cited_in_documents = Kaminari.paginate_array(@cited_in_documents, total_count: @cited_in_documents.count).page(params[:page]).per(20) @paginated_cited_in_documents = Kaminari.paginate_array(@cited_in_documents, total_count: @cited_in_documents.count).page(params[:page]).per(20)
end
# @cross_ref_documents = @document.class.cited_docs_of(document, where) # @cross_ref_documents = @document.class.cited_docs_of(document, where)
end end

1
app/javascript/controllers/document_controller.js

@ -7,7 +7,6 @@ export default class extends ApplicationController {
} }
search () { search () {
console.log(this.element.dataset)
this.stimulate("DocumentReflex#render_case_lists_search_results", this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 }, { q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"]) this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])

66
app/jobs/parse_linkable_content_job.rb

@ -0,0 +1,66 @@
class ParseLinkableContentJob < ActiveJob::Base
queue_as :default
def perform(annotation)
content = ""
document = annotation.document
citing_docs = annotation.documents
if annotation.content.present?
content = annotation.content.gsub("<div>", "").gsub("</div>", "")
contents = content.split(" citing ")
contents.each_with_index do |content, i|
linkable_content = nil
if i.eql?(0)
linkable_content = add_linkable_content(document.id, [content[i], clean_phil_rep(annotation)].reject(&:blank?).join(", "))
else
citing_docs.each do |citing_doc|
old_content = contents[i]
next if !old_content.include?(citing_doc.clean_reference_number)
linkable_content = add_linkable_content(citing_doc.id, old_content)
end
end
contents[i] = linkable_content
end
content = contents.join(" citing ")
else
contents = []
doc_title = document.short_title || document.title
doc_date_or_year = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
doc_ref_num = document.clean_reference_number
contents << add_linkable_content(document.id, [doc_title, doc_ref_num, doc_date_or_year, clean_phil_rep(annotation)].reject(&:blank?).join(", "))
if citing_docs.present?
citing_docs.each do |citing_doc|
citing_doc_title = citing_doc.short_title || citing_doc.title
citing_doc_date_or_year = citing_doc.doc_date.present? ? citing_doc.doc_date.strftime("%B %d, %Y") : citing_doc.year
citing_doc_ref_num = citing_doc.clean_reference_number
citing_content = [citing_doc_title, citing_doc_date_or_year, citing_doc_ref_num].join(", ")
contents << ["citing", add_linkable_content(citing_doc, citing_content)].join(" ")
end
end
content = contents.join(", ")
end
annotation.update_column(:content, content) if content.present?
annotation.index!
end
private
def add_linkable_content(document_id, content)
document_route = Rails.application.routes.url_helpers.document_path(document_id)
"<a href='#{document_route}'> #{content} </a>"
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
end

7
app/models/cdao/document.rb

@ -31,6 +31,13 @@ class Cdao::Document < Cdao::Base
libraries.all?(&:premium?) libraries.all?(&:premium?)
end end
def content
table_name = self.doc_type.tableize
sql = "select * from #{table_name} where id='#{self.doc_id}' LIMIT 1"
query = Cdao::Base.connection.execute(sql)
query.first.present? ? query.first["content"] : ""
end
def to_builder(ability = nil) def to_builder(ability = nil)
Jbuilder.new do |doc| Jbuilder.new do |doc|
doc.(self, *%i[id title short_title]) doc.(self, *%i[id title short_title])

5
app/models/cdao/jurisprudence.rb

@ -1,6 +1,7 @@
class Cdao::Jurisprudence < Cdao::Base class Cdao::Jurisprudence < Cdao::Base
self.table_name = "jurisprudences" self.table_name = "jurisprudences"
has_one :document, as: :doc, class_name: "Jurisprudence", dependent: :destroy
has_many :annotations, as: :document, dependent: :restrict_with_error has_many :annotations, as: :document, dependent: :restrict_with_error
has_many :doctrine_jurisprudences, dependent: :destroy has_many :doctrine_jurisprudences, dependent: :destroy
@ -29,6 +30,10 @@ class Cdao::Jurisprudence < Cdao::Base
Cdao::Citation.where(cited_doc_id: self.id, cited_doc_type: self.class.name.gsub("Cdao::", "")) Cdao::Citation.where(cited_doc_id: self.id, cited_doc_type: self.class.name.gsub("Cdao::", ""))
end end
def document
Cdao::Document.where(doc_id: self.id, doc_type: self.class.name.gsub("Cdao::", "")).first
end
def self.citing_docs_of(doc, where = {}) def self.citing_docs_of(doc, where = {})
citing_docs = [] citing_docs = []
c_arel = Cdao::Citation.arel_table c_arel = Cdao::Citation.arel_table

6
app/views/doctrines/new.html.erb

@ -13,7 +13,7 @@
</div> </div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse"> <div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document" data-jurisprudence-id="<%= params[:jurisprudence_id] %>"> <div class="row" data-controller="document">
<div class="col-sm-10 p-2"> <div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %> <%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
</div> </div>
@ -50,7 +50,7 @@
<% if params[:doctrine_id].present? %> <% if params[:doctrine_id].present? %>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], params[:doctrine_id]) %>">Back</a> <a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], params[:doctrine_id]) %>">Back</a>
<% else %> <% else %>
<a class="btn btn-danger ms-2" href="<%= document_path(params[:jurisprudence_id]) %>">Back</a> <a class="btn btn-danger ms-2" href="<%= document_path(params[:document_id]) %>">Back</a>
<% end %> <% end %>
</div> </div>
</div> </div>
@ -59,6 +59,6 @@
<% if @doctrine.new_record? %> <% if @doctrine.new_record? %>
<div class="row"> <div class="row">
<%= render partial: "/shared/doctrine_form_annotation_modal_form", locals: { jurisprudence_id: params[:jurisprudence_id] } %> <%= render partial: "/shared/doctrine_form_annotation_modal_form" %>
</div> </div>
<% end %> <% end %>

11
app/views/doctrines/search.html.erb

@ -1,14 +1,17 @@
<div class="container-fluid mt-1 p-0 doctrine-index-body"> <div class="container-fluid mt-1 p-0 doctrine-index-body">
<div class="container-fluid m-2 p-0"> <%= render PaginationComponent.new(data: @results, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids], is_index_table: params[:is_index_table] }) %> </div> <div class="container-fluid m-2 p-0"> <%= render PaginationComponent.new(data: @results, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids], is_index_table: params[:is_index_table] }) %> </div>
<hr class="mt-0"/> <hr class="mt-0"/>
<% @uniq_doctrines.each do |uniq_doctrine| %> <% @uniq_by_headnotes.each do |uniq_by_headnote| %>
<div class="row-flex m-3 mt-0 doctrine-content-body"> <div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="container-sm <%= params[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>"> <div class="container-sm <%= params[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<h5> <%= uniq_doctrine.headnote %> </h5> <h5> <%= uniq_by_headnote.headnote %> </h5>
<% uniq_by_contents = @results.map { |doctrine| doctrine if doctrine.headnote.eql?(uniq_by_headnote.headnote) }.uniq(&:content) %>
<% doctrines = @results.map { |doctrine| doctrine if doctrine.headnote.eql?(uniq_doctrine.headnote) } %> <% uniq_by_contents.each do |uniq_by_content| %>
<div class="mb-0"> <%= raw uniq_by_content.content.html_safe %> </div>
<% doctrines = @results.map { |doctrine| doctrine if doctrine.headnote.eql?(uniq_by_headnote.headnote) && doctrine.content.eql?(uniq_by_content.content) } %>
<%= render(DoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %> <%= render(DoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %>
<% end %>
</div> </div>
<hr/> <hr/>

2
app/views/doctrines/show.html.erb

@ -20,7 +20,7 @@
<div class="card-body pt-0"> <div class="card-body pt-0">
<div class="row"> <div class="row">
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, jurisprudence_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence, subjects: @subjects)) %> <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, jurisprudence_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence)) %>
</div> </div>
</div> </div>
</div> </div>

6
app/views/document/doctrines/show.html.erb

@ -8,7 +8,7 @@
<% if params[:is_index_table].present? %> <% if params[:is_index_table].present? %>
<a href="<%= search_doctrines_path(is_index_table: params[:is_index_table], subject_ids: params[:subject_ids] )%>"> <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> <a href="<%= search_doctrines_path(is_index_table: params[:is_index_table], subject_ids: params[:subject_ids] )%>"> <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 %> <% else %>
<a href="<%= document_path(@document)%>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to document"></i> </a> <a href="<%= document_path(@document.document)%>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to document"></i> </a>
<% end %> <% end %>
</div> </div>
<div class="col-lg-3 text-end"> <div class="col-lg-3 text-end">
@ -47,12 +47,12 @@
<div class="card-body pt-0"> <div class="card-body pt-0">
<div class="row"> <div class="row">
<div class="d-flex justify-content-end p-2"> <div class="d-flex justify-content-end p-2">
<a class="btn btn-success" href="<%= new_doctrine_path(jurisprudence_id: @document.id, doctrine_id: @doctrine.id) %>"> Add Doctrine </a> <a class="btn btn-warning" href="<%= new_doctrine_path(jurisprudence_id: @document.id, doctrine_id: @doctrine.id ) %>"> Add Doctrine </a>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, jurisprudence_id: @document.id, subjects: @subjects)) %> <%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, opts: { jurisprudence_id: @document.id })) %>
</div> </div>
</div> </div>
</div> </div>

2
app/views/documents/index.html.erb

@ -20,7 +20,7 @@
</thead> </thead>
<tbody> <tbody>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %> <%= render(JurisprudencesIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %>
</tbody> </tbody>
</table> </table>
</div> </div>

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

@ -50,32 +50,36 @@
</div> </div>
<div class="card-body p-0"> <div class="card-body p-0">
<ul class="doc-nav-body nav nav-tabs nav-justified" id="menuTab" role="tablist"> <ul class="doc-nav-body nav nav-tabs nav-justified" id="menuTab" role="tablist">
<% if @jurisprudence.present? %>
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active' : '' %>" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#analysisTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Analysis</button> <button class="nav-link <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active' : '' %>" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#analysisTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Analysis</button>
</li> </li>
<% end %>
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link <%= params[:is_document_view].to_s.eql?("true") ? 'active' : '' %>" id="documentMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button> <button class="nav-link <%= @jurisprudence.blank? ? 'active' : '' %>" id="documentMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button>
</li> </li>
<% if @jurisprudence.present? %>
<li class="nav-item" role="presentation"> <li class="nav-item" role="presentation">
<button class="nav-link <%= params[:is_citator_tab].to_s.eql?("true") ? 'active' : '' %>" id="citatorMenuTab" data-bs-toggle="tab" data-bs-target="#citatonTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Citator</button> <button class="nav-link <%= params[:is_citator_tab].to_s.eql?("true") ? 'active' : '' %>" id="citatorMenuTab" data-bs-toggle="tab" data-bs-target="#citatonTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Citator</button>
</li> </li>
<% end %>
</ul> </ul>
<div class="tab-content" style="height: 550px;overflow: auto;"> <div class="tab-content" style="height: 550px;overflow: auto;">
<% if @jurisprudence.present? %>
<div class="tab-pane fade show <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active show' : '' %>" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab"> <div class="tab-pane fade show <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active show' : '' %>" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab">
<div class="row"> <div class="row">
<div class="d-flex justify-content-end" style="margin: 10px 0 0 -20px;"> <div class="d-flex justify-content-end" style="margin: 10px 0 0 -20px;">
<a class="btn btn-warning" href="<%= new_doctrine_path(jurisprudence_id: @document.id) %>"> Add Doctrine </a> <a class="btn btn-warning" href="<%= new_doctrine_path(document_id: @document.id, jurisprudence_id: @jurisprudence.id) %>"> Add Doctrine </a>
</div>
<div class="container-sm row-flex col-sm-12 mt-2">
<%= render(DoctrineModalFormComponent.new(current_user: current_user)) %>
</div> </div>
</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">
<div class="row-flex m-3 mt-0 doctrine-content-body"> <div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="accordion accordion-flush" id="documentSubjectsAccordion"> <div class="accordion accordion-flush" id="documentSubjectsAccordion">
<% @document.subjects.sort_by { |sub| sub.lineage_name }.each_with_index do |subject, i| %> <% @jurisprudence.subjects.sort_by { |sub| sub.lineage_name }.each_with_index do |subject, i| %>
<div class="accordion-item"> <div class="accordion-item">
<div class="accordion-header"> <div class="accordion-header">
<div class="accordion-button collapsed m-0 p-0" data-bs-toggle="collapse" data-bs-target="#documentSubjectsAccordionBody<%= subject.id %>"> <div class="accordion-button collapsed m-0 p-0" data-bs-toggle="collapse" data-bs-target="#documentSubjectsAccordionBody<%= subject.id %>">
@ -83,10 +87,10 @@
</div> </div>
</div> </div>
<% doctrines = @document.doctrines.includes(:doctrine_subjects).where(doctrine_subjects: { subject_id: subject.id }) %> <% doctrines = @jurisprudence.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-collapse collapse <%= i.eql?(0) ? 'show' : '' %>" id="documentSubjectsAccordionBody<%= subject.id %>" data-bs-parent="#documentSubjectsAccordion">
<div class="accordion-body pt-1 pb-1 sub-body1"> <div class="accordion-body pt-1 pb-1 sub-body1">
<%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { document_id: @document.id })) %> <%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user)) %>
</div> </div>
</div> </div>
</div> </div>
@ -95,13 +99,15 @@
</div> </div>
</div> </div>
</div> </div>
<% end %>
<div class="tab-pane fade <%= params[:is_document_view].to_s.eql?("true") ? 'active show' : '' %>" id="documentTabContent" role="tabpanel"> <div class="tab-pane fade <%= @jurisprudence.blank? ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="container-sm mt-2"> <div class="container-sm mt-2">
<%= raw @document.content.html_safe%> <%= raw @document.content.html_safe%>
</div> </div>
</div> </div>
<% if @jurisprudence.present? %>
<div class="tab-pane fade cited-table-body <%= params[:is_citator_tab].to_s.eql?("true") ? 'active show' : '' %>" id="citatonTabContent" role="tabpanel"> <div class="tab-pane fade cited-table-body <%= params[:is_citator_tab].to_s.eql?("true") ? 'active show' : '' %>" id="citatonTabContent" role="tabpanel">
<div class="d-flex align-items-baseline"> <div class="d-flex align-items-baseline">
<div class="col-md-6 mt-3 ps-3"> <h4> Cited In </h4> </div> <div class="col-md-6 mt-3 ps-3"> <h4> Cited In </h4> </div>
@ -119,6 +125,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<% end %>
</div> </div>
</div> </div>
</div> </div>

Loading…
Cancel
Save