Compare commits

..

1 Commits

Author SHA1 Message Date
Angel Aviel Domaoan c2f94c34de Implement workers 4 years ago
  1. 2
      .github/workflows/deployment.yml
  2. 51
      app/components/annotation_form_component.rb
  3. 51
      app/components/annotation_form_component/annotation_form_component.html.erb
  4. 7
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  5. 6
      app/components/citation_index_table_component.rb
  6. 4
      app/components/citation_index_table_component/citation_index_table_component.html.erb
  7. 10
      app/components/doctrine_form_component.rb
  8. 38
      app/components/doctrine_form_component/doctrine_form_component.html.erb
  9. 55
      app/components/doctrine_index_component.rb
  10. 59
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  11. 10
      app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb
  12. 9
      app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb
  13. 6
      app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb
  14. 6
      app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb
  15. 4
      app/components/document_advanced_search_component.rb
  16. 4
      app/components/document_advanced_search_component/document_advanced_search_component.html.erb
  17. 23
      app/components/document_doctrine_index_component.rb
  18. 36
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  19. 32
      app/components/document_doctrine_show_component.rb
  20. 51
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  21. 24
      app/components/document_index_table_component.rb
  22. 5
      app/components/document_index_table_component/document_index_table_component.html.erb
  23. 2
      app/components/documents_years_component/documents_years_component.html.erb
  24. 25
      app/components/jurisprudences_index_table_component.rb
  25. 6
      app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb
  26. 6
      app/components/reports_search_results_component/reports_search_results_component.html.erb
  27. 9
      app/components/sidenav_component/sidenav_component.html.erb
  28. 12
      app/components/subjects_accordion_component/subjects_accordion_component.html.erb
  29. 2
      app/components/subjects_offcanvas_accordion_component.rb
  30. 6
      app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb
  31. 6
      app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb
  32. 8
      app/controllers/api/doctrine/annotations_controller.rb
  33. 18
      app/controllers/api/doctrines_controller.rb
  34. 2
      app/controllers/api/documents_controller.rb
  35. 4
      app/controllers/api/jurisprudences_controller.rb
  36. 4
      app/controllers/concerns/annotation_search.rb
  37. 21
      app/controllers/concerns/doctrine_search.rb
  38. 52
      app/controllers/concerns/document_search.rb
  39. 52
      app/controllers/concerns/jurisprudence_search.rb
  40. 7
      app/controllers/decisions_controller.rb
  41. 4
      app/controllers/doctrine/annotations_controller.rb
  42. 8
      app/controllers/doctrines_controller.rb
  43. 11
      app/controllers/documents_controller.rb
  44. 45
      app/javascript/controllers/annotations_controller.js
  45. 32
      app/javascript/controllers/application_controller.js
  46. 171
      app/javascript/controllers/doctrines_controller.js
  47. 22
      app/javascript/controllers/document_controller.js
  48. 16
      app/javascript/controllers/selectize_controller.js
  49. 3
      app/javascript/controllers/subjects_controller.js
  50. 8
      app/javascript/packs/application.js
  51. 34
      app/javascript/src/application.scss
  52. 9
      app/javascript/src/application/subject-accordion.scss
  53. 66
      app/jobs/parse_linkable_content_job.rb
  54. 17
      app/models/annotation.rb
  55. 23
      app/models/cdao/document.rb
  56. 7
      app/models/cdao/jurisprudence.rb
  57. 9
      app/models/cdao/subject.rb
  58. 104
      app/models/doctrine.rb
  59. 1
      app/models/doctrine_jurisprudence.rb
  60. 6
      app/reflexes/annotation_reflex.rb
  61. 42
      app/reflexes/doctrines_reflex.rb
  62. 13
      app/reflexes/document_reflex.rb
  63. 3
      app/views/api/doctrines/suggested_contents.json.jbuilder
  64. 15
      app/views/doctrine/annotations/edit.html.erb
  65. 16
      app/views/doctrine/annotations/new.html.erb
  66. 12
      app/views/doctrines/edit.html.erb
  67. 64
      app/views/doctrines/new.html.erb
  68. 11
      app/views/doctrines/search.html.erb
  69. 2
      app/views/doctrines/show.html.erb
  70. 8
      app/views/document/doctrines/_document_search_results_table.html.erb
  71. 8
      app/views/document/doctrines/show.html.erb
  72. 2
      app/views/documents/index.html.erb
  73. 21
      app/views/documents/search.html.erb
  74. 46
      app/views/documents/show.html.erb
  75. 16
      app/views/layouts/application.html.erb
  76. 4
      app/views/reports/index.html.erb
  77. 7
      app/views/shared/_annotated_documents_search_results.html.erb
  78. 64
      app/views/shared/_annotation_form.html.erb
  79. 2
      app/views/shared/_annotations_index_view.html.erb
  80. 23
      app/views/shared/_case_lists_no_results.html.erb
  81. 52
      app/views/shared/_case_lists_search_results.html.erb
  82. 71
      app/views/shared/_doctrine_form_annotation_modal_form.html.erb
  83. 38
      app/views/shared/_doctrine_form_annotations_view.html.erb
  84. 108
      app/views/shared/_doctrine_form_case_lists.html.erb
  85. 101
      app/views/shared/_doctrine_form_citing_documents_search_results.html.erb
  86. 23
      app/views/shared/_doctrine_form_default_case_lists.html.erb
  87. 59
      app/views/shared/_doctrines_pagination.html.erb
  88. 4
      app/views/shared/_document_doctrines_index.html.erb
  89. 6
      app/views/subject_indexes/index.html.erb
  90. 12
      app/views/subject_indexes/show.html.erb
  91. 23
      config/application.rb
  92. 14
      config/application.yml
  93. 2
      config/credentials/development.yml.enc
  94. 2
      config/credentials/production.yml.enc
  95. 1
      config/deploy/production.rb
  96. 1
      config/deploy/staging.rb
  97. 14
      config/initializers/okcomputer.rb
  98. 13
      config/routes.rb
  99. 11
      data/csvs/labor_new.csv
  100. 5
      db/migrate/20220307043427_add_content_in_annotation.rb
  101. Some files were not shown because too many files have changed in this diff Show More

2
.github/workflows/deployment.yml

@ -1,8 +1,6 @@
name: Deployment
on:
push:
branches:
- stable
tags:
- v*
workflow_dispatch:

51
app/components/annotation_form_component.rb

@ -1,51 +0,0 @@
class AnnotationFormComponent < BaseComponent
attr_reader :annotation, :opts
def initialize(current_user:, annotation:, opts: {})
@annotation = annotation
@opts = opts
end
def document
return annotation.document if annotation.persisted?
Cdao::Document.find(opts[:document_id].to_i)
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def display_text
return annotation.content if annotation.persisted? && annotation.content.present? && annotation.content.include?("Phil")
display_text = nil
title = document.short_title || document.title
year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
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
def phil_rep
return annotation.phil_rep if annotation.persisted?
document.phil_rep
end
end

51
app/components/annotation_form_component/annotation_form_component.html.erb

@ -1,51 +0,0 @@
<div class="row">
<div class="col-sm-12 p-2">
<strong> Annotation Marks </strong>
<%= hidden_field_tag :document_ids, annotation.citing_document_ids, data: { target: "annotations.document_ids" } %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name, annotation.annomark_ids),
class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :document_title %> </strong>
<%= rich_text_area_tag :content, display_text, placeholder: "Document Title" %>
</div>
</div>
<div id="annotatedDocumentsSearchResults">
<div class="row">
<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: "annotations.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-success" data-action="click->annotations#searchDocuments"> Search </button>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :phil_rep %> </strong>
<%= text_field_tag :phil_rep, phil_rep, class: "form-control", data: { target: "annotations.phil_rep" } %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor's Note", data: { target: "annotations.editor_notes" } %>
</div>
</div>

7
app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb

@ -11,7 +11,6 @@
<div class="col-sm-12 p-2">
<strong> <%= label_tag :annotation_marks %> </strong>
<%= hidden_field_tag :annotation_id, nil, data: { target: "annotations.annotation_id" } %>
<%= hidden_field_tag :current_document_id, nil, data: { target: "annotations.current_document_id" } %>
<%= hidden_field_tag :doctrine_id, nil, data: { target: "annotations.doctrine_id" } %>
<%= hidden_field_tag :document_id, nil, data: { target: "annotations.document_id" } %>
<%= hidden_field_tag :document_ids, nil, data: { target: "annotations.document_ids" } %>
@ -31,7 +30,7 @@
<div id="annotatedDocumentsSearchResults">
<div class="row">
<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: "annotations.q" } %>
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "annotations.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-success" data-action="click->annotations#searchDocuments"> Search </button>
@ -59,8 +58,8 @@
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor's Note", data: { target: "annotations.editor_notes" } %>
<strong> <%= label_tag :editor_notes %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes", data: { target: "annotations.editor_notes" } %>
</div>
</div>
</div>

6
app/components/citation_index_table_component.rb

@ -20,10 +20,4 @@ class CitationIndexTableComponent < BaseComponent
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
def citator_path
return document_path(search_result.document.id) if search_result.document.present?
document_path(search_result.id)
end
end

4
app/components/citation_index_table_component/citation_index_table_component.html.erb

@ -1,6 +1,4 @@
<tr class="clickable-tr" data-controller="application"
data-href="<%= citator_path %>"
data-action="click->application#openLinkToNewTab">
<tr href="<%= document_path(search_result.id, is_citator_tab: true) %>" class="clickable-tr" target="_blank">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>

10
app/components/doctrine_form_component.rb

@ -1,10 +0,0 @@
class DoctrineFormComponent < BaseComponent
attr_reader :doctrine, :jurisprudence_id, :opts
def initialize(current_user:, doctrine:, jurisprudence_id:, opts: {})
@doctrine = doctrine
@jurisprudence_id = jurisprudence_id
@opts = opts
end
end

38
app/components/doctrine_form_component/doctrine_form_component.html.erb

@ -1,38 +0,0 @@
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label"> Subjects </label>
<%= hidden_field_tag :document_id, jurisprudence_id, data: { target: "doctrines.document_id" } %>
<%= hidden_field_tag :doctrine_id, doctrine.id, data: { target: "doctrines.doctrine_id" } %>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required>
<% doctrine.subjects.each do |subject| %>
<option value="<%= subject.id %>" selected> <%= subject.lineage_name %> </option>
<% end if doctrine.persisted? %>
</select>
<div class="invalid-feedback" id="subjects-blank-message"> Subject/s cannot be blank. </div>
</div>
</div>
<% if doctrine.new_record? %>
<div class="row" id="doctine_content_suggestions_div">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Doctine content suggestions</label>
<select id="doctine_content_suggestions" class="form-control ps-0"> </select>
</div>
</div>
<% end %>
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Head Note</label>
<%= text_field_tag :headnote, doctrine.headnote, class: "form-control", placeholder: "Head note", required: true, data: { target: "doctrines.headnote" } %>
<div class="invalid-feedback" id="headnote-blank-message"> Headnote cannot be blank. </div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, doctrine.content, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
<div class="invalid-feedback" id="content-blank-message"> Content cannot be blank. </div>
<div>
</div>

55
app/components/doctrine_index_component.rb

@ -1,14 +1,19 @@
class DoctrineIndexComponent < BaseComponent
attr_reader :search_results, :opts
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
include AnnotationSearch
include DoctrineSearch
def initialize(search_results:, current_user:, opts: {})
@search_results = search_results
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
@opts = opts
end
delegate :id, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
delegate :doctrine_jurisprudences, to: :doctrine
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
end
@ -17,6 +22,12 @@ class DoctrineIndexComponent < BaseComponent
"(No Subjects Provided)"
end
def jurisprudence
return nil if doctrine_jurisprudences.blank?
doctrine_jurisprudences.first.jurisprudence
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
@ -29,37 +40,7 @@ class DoctrineIndexComponent < BaseComponent
annotation.document.year
end
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?
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def search_annotations(search_params)
search = annotation_search(search_params)
search.results
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def search_doctrines(search_params)
search = doctrine_search(search_params)
search
end
def render?
search_results.present?
doctrine.present? && doctrine.persisted?
end
end

59
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -1,44 +1,35 @@
<div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="container-sm <%= params[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<% search_results.uniq(&:headnote).each do |uniq_by_headnote| %>
<h5> <%= uniq_by_headnote.headnote %> </h5>
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) : doctrine_path(id, is_index_table: false)%>">
<% if opts[:subject_ids].reject(&:blank?).present? %>
<h5 style="color: darkred;"> <%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join("") %> </h5>
<% else %>
<h5> (No Subjects Provided) </h5>
<% end %>
<% grouped_by_content_search_params = { subject_ids: opts[:subject_ids], headnote: uniq_by_headnote.headnote, is_grouped_by_content: true } %>
<% search_doctrines(grouped_by_content_search_params).group(:content).groups.each do |group_by_content| %>
<% group_by_content.results.each do |content_result| %>
<div class="mb-0 fs-5"> <%= raw content_result.content.html_safe %> </div>
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
<% grouped_by_juris_search_params = { subject_ids: opts[:subject_ids], content: content_result.content, is_grouped_by_juris_id: true } %>
<% search_doctrines(grouped_by_juris_search_params).group(:jurisprudence_id).groups.each do |grouped_by_juris| %>
<% grouped_by_juris.results.each do |juris_result| %>
<h5 class="clickable-link" style="color: darkred;" data-controller="application"
data-href="<%= document_path(juris_result.jurisprudence.document.id, is_index_table: false, subject_ids: params[:subject_ids]) %>"
data-action="click->application#openLink">
<% document_title = juris_result.jurisprudence.short_title || juris_result.jurisprudence.title %>
<% date_or_year = juris_result.jurisprudence.doc_date.present? ? juris_result.jurisprudence.doc_date.strftime("%B, %d, %Y") : doctrine.jurisprudence.year %>
<%= [document_title, juris_result.jurisprudence.clean_reference_number, date_or_year].join(", ") %>
</h5>
<div class="container-fluid p-0">
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<% search_params = { subject_ids: opts[:subject_ids], headnote: uniq_by_headnote.headnote, content: content_result.content, jurisprudence_id: juris_result.jurisprudence.id } %>
<% search_doctrines(search_params).results.each do |doctrine| %>
<% search_annotations({ doctrine_id: doctrine.id }).each do |annotation| %>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-3">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% 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(", ") %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% 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 %>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
</div>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2">
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
@ -47,12 +38,8 @@
</div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<hr/>
</div>

10
app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb

@ -7,12 +7,10 @@
<tbody>
<% search_results.each do |search_result| %>
<tr class="clickable-link" data-controller="application"
data-href="<%= document_path(search_result.document.id, is_index_table: true, subject_ids: opts[:subject_ids]) %>"
data-action="click->application#openLink">
<td> <%= document_reference_number(search_result) %> </td>
<td> <%= document_title(search_result) %> </td>
<td> <%= date_or_year(search_result) %> </td>
<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>
<% end %>
</tbody>

9
app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb

@ -11,8 +11,7 @@
<label for="subject-name" class="col-form-label"> Subjects </label>
<%= hidden_field_tag :document_id, nil, data: { target: "doctrines.document_id" } %>
<%= hidden_field_tag :doctrine_id, nil, data: { target: "doctrines.doctrine_id" } %>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required> </select>
<div class="invalid-feedback" id="subjects-blank-message"> Subject/s cannot be blank. </div>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
</div>
<div class="mb-3" id="doctine_content_suggestions_div">
@ -22,14 +21,12 @@
<div class="mb-3">
<label for="subject-name" class="col-form-label">Head Note</label>
<%= text_field_tag :headnote, nil, class: "form-control", placeholder: "Head note", required: true, data: { target: "doctrines.headnote" } %>
<div class="invalid-feedback" id="headnote-blank-message"> Headnote cannot be blank. </div>
<%= text_field_tag :headnote, nil, class: "form-control", placeholder: "Head note", data: { target: "doctrines.headnote" } %>
</div>
<div class="mb-3">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
<div class="invalid-feedback" id="content-blank-message"> Content cannot be blank. </div>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", data: { target: "doctrines.content" } %>
</div>
</div>
<div class="modal-footer">

6
app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb

@ -5,12 +5,10 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
</div>
<% else %>
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
<% end %>
</div>

6
app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb

@ -15,12 +15,10 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['doctrinesOffCanvasAccordionBody', root.id].join %>"
data-action="click->subjects#loadDoctrinesOffcanvasAccordion">
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
<%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: false), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
</div>
<% else %>
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_doctrines_path(subject_ids: [root.id], is_index_table: false), action: "click->application#openLink" } %>
<%= link_to root.name, search_doctrines_path(subject_ids: [root.id], is_index_table: false), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<% end %>
</div>

4
app/components/document_advanced_search_component.rb

@ -6,8 +6,6 @@ class DocumentAdvancedSearchComponent < BaseComponent
end
def years
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
(start_year..end_year).entries.reverse
(1901..Time.zone.today.year).entries.reverse
end
end

4
app/components/document_advanced_search_component/document_advanced_search_component.html.erb

@ -10,7 +10,7 @@
<div class="mb-2">
<label for="exampleFormControlInput1" class="form-label text-white">Title</label>
<%= text_field_tag :title, params[:title], class: "form-control mb-0" %>
<%= text_field_tag :title, params[:short_title], class: "form-control mb-0" %>
</div>
<div class="d-flex align-items-end">
@ -30,7 +30,7 @@
</div>
<div class="d-flex justify-content-end mt-3">
<button class="btn btn-success reset-document-advanced-search me-2 mb-2"><i class="fas fa-sync"></i> Refresh</button>
<button type="reset" class="btn btn-success me-2 mb-2"><i class="fas fa-sync"></i> Refresh</button>
<button type="submit" class="btn btn-danger mb-2">Search</button>
</div>
<% end %>

23
app/components/document_doctrine_index_component.rb

@ -2,8 +2,6 @@ class DocumentDoctrineIndexComponent < BaseComponent
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
include AnnotationSearch
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
@opts = opts
@ -12,8 +10,8 @@ class DocumentDoctrineIndexComponent < BaseComponent
delegate :id, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
delegate :headnote, to: :doctrine
delegate :doctrine_jurisprudences, to: :doctrine
def annotation_form_url
@ -42,25 +40,6 @@ class DocumentDoctrineIndexComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def annotations
search = annotation_search(doctrine_id: id)
search.results
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def render?
doctrine.present? && doctrine.persisted?
end

36
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -1,35 +1,45 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<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' : '' %>">
<span> <b> <i> <%= headnote %> </i> </b> </span>
<p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0">
<% if opts[:is_doctrines_index].present? %>
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<% end %>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-3">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% 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 %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% 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 %>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
</div>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2">
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">

32
app/components/document_doctrine_show_component.rb

@ -1,11 +1,12 @@
class DocumentDoctrineShowComponent < BaseComponent
attr_reader :current_user, :doctrine, :opts
attr_reader :current_user, :annotations, :document_id, :doctrine, :subjects
include AnnotationSearch
def initialize(current_user:, doctrine:, opts: {})
def initialize(current_user:, annotations:, doctrine:, document_id:, subjects:, opts: {})
@annotations = annotations
@doctrine = doctrine
@document_id = document_id
@current_user = current_user
@subjects = subjects
@opts = opts
end
@ -25,8 +26,8 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title
end
def jurisprudence
Cdao::Jurisprudence.find(opts[:jurisprudence_id])
def document
Document.find(document_id)
end
def date_or_year(annotation)
@ -34,23 +35,4 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.year
end
def clean_phil_rep(annotation)
return if annotation.phil_rep.blank?
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end
def content_diplay_text(annotation)
return annotation.content.gsub("<div>", "").gsub("</div>", "") if annotation.content.include?("Phil")
contents = annotation.content.gsub("<div>", "").gsub("</div>", "").split(" citing ")
contents[0] = [contents[0], clean_phil_rep(annotation)].reject(&:blank?).join(", ")
contents.join(" citing ")
end
def annotations
search = annotation_search(doctrine_id: id)
search.results
end
end

51
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -5,9 +5,9 @@
<h5> <b>Doctrine Details</b> </h5>
</div>
<div class="col-sm-2 d-flex justify-content-end pe-0" >
<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-controller="doctrines" data-doctrine-id="<%= id %>" data-document-id="<%= jurisprudence.document.id %>" data-action="click->doctrines#delete" > Delete </a>
<div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>" >
<a class="btn btn-success me-3"data-action="click->doctrines#renderForm" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Edit </a>
<a class="btn btn-danger" data-action="click->doctrines#delete" > Delete </a>
</div>
</div>
@ -51,21 +51,17 @@
<div class="row">
<div class="col-sm-10"> </div>
<div class="col-sm-2 p-2">
<button type="button" class="btn btn-info d-block ms-auto text-white" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case List </button>
<button type="button" class="btn btn-success d-block ms-auto" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button>
</div>
</div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>">
<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" } %>
<div class="row" data-controller="document" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>">
<div class="col-sm-11 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "document.input" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success btn-sm me-2", data: { action: "click->document#search" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, nil, class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
<div class="col p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %>
</div>
</div>
@ -76,6 +72,7 @@
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>
@ -85,6 +82,7 @@
<div class="row-flex">
<div class="annot-header"> <h5> Annotations </h5> </div>
<div class="" id="annotationsIndexView">
<%= render(partial: "/shared/annotations_pagination", locals: { annotations: annotations, opts: { current_page: 1 } }) %>
<% annotations.each do |annotation| %>
<% document_title = annotation.document.short_title || annotation.document.title %>
<% date_or_year = annotation.document.docdate.present? ? annotation.document.docdate.strftime("%B %d, %Y") : annotation.document.year %>
@ -92,26 +90,31 @@
<% annotation.documents.each do |annotated_document| %>
<% 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 %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% 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.reference_number, date_or_year, annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
<div class="row">
<div class="col-sm-10">
<p class="pb-0 ms-3">
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw citing_document_title %>
</p>
</div>
<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: opts[:jurisprudence_id], document_id: annotation.document_id) %>">
Edit
</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>
<a class="btn btn-secondary me-3" data-bs-toggle="modal" data-bs-target="#annotationModal"
data-controller="annotations" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>"
data-document-title="<%= citing_document_title %>"
data-action="click->annotations#renderForm"> Edit </a>
<a class="btn btn-danger" data-controller="annotations" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a>
</div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row mb-2">
<div class="row">
<div class="col-sm-1 ms-5 p-0" style="width: 105px;">
<span> Editor's Note: </span>
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">

24
app/components/document_index_table_component.rb

@ -0,0 +1,24 @@
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

5
app/components/document_index_table_component/document_index_table_component.html.erb

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

2
app/components/documents_years_component/documents_years_component.html.erb

@ -4,7 +4,7 @@
<td>
<div class="container-sm p-0">
<% year_arr.each do |year| %>
<strong> <%= link_to year, documents_path(year_start: year.to_i, year_end: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<strong> <%= link_to year, documents_path(year: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<% end %>
</div>
</td>

25
app/components/jurisprudences_index_table_component.rb

@ -1,25 +0,0 @@
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

6
app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb

@ -1,6 +0,0 @@
<tr class="clickable-link" data-controller="application" data-href="<%= document_path(document.id) %>"
data-action="click->application#openLink">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>
</tr>

6
app/components/reports_search_results_component/reports_search_results_component.html.erb

@ -1,6 +1,4 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" data-controller="application"
data-href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"
data-action="click->application#openLink">
<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="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
@ -26,7 +24,7 @@
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">

9
app/components/sidenav_component/sidenav_component.html.erb

@ -81,15 +81,20 @@
</div>
<form class="d-flex">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item p-2">
<%= link_to ' <i class="fas fa-home me-2"></i>Home'.html_safe, root_path, class: "nav-link" %>
</li>
<li class="nav-item p-2">
<%= link_to '<i class="fas fa-search me-2"></i>Search'.html_safe, documents_path, class: "nav-link" %>
</li>
<li class="nav-item p-2">
<a class="nav-link" style="cursor: pointer" data-bs-toggle="offcanvas" data-bs-target="#subjectsOffCanvas">
<a class="nav-link" data-bs-toggle="offcanvas" data-bs-target="#subjectsOffCanvas"
data-controller="subjects" data-accordion-target="#subjectsOffCanvasAccordionBody"
data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<i class="fas fa-indent me-2"></i> Subjects
</a>
</li>
<li class="nav-item p-2" style="cursor: pointer">
<li class="nav-item p-2">
<a class="nav-link" data-bs-toggle="offcanvas" data-bs-target="#doctrinesOffCanvas">
<i class="fas fa-book me-2"></i> Doctrines
</a>

12
app/components/subjects_accordion_component/subjects_accordion_component.html.erb

@ -5,16 +5,12 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 me-5" %>
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]), class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: custom_url, action: "click->application#openLink" } %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]),
class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 non-toggle" %>
<%= link_to search_result["name"], custom_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: search_result["id"]), class: "text-decoration-none d-block sub#{search_result["heirarchy_level"]} clickable-link position-absolute end-0 non-toggle" %>
<% end %>
</div>

2
app/components/subjects_offcanvas_accordion_component.rb

@ -34,6 +34,6 @@ class SubjectsOffcanvasAccordionComponent < BaseComponent
end
def index_url
search_documents_path(subject_ids: search_result["id"], is_index_table: true)
search_doctrines_path(subject_ids: [search_result["id"]], is_index_table: true)
end
end

6
app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb

@ -5,12 +5,10 @@
<div class="accordion-button collapsed m-0 p-0 sub-label<%= search_result["heirarchy_level"] + 1 %>" data-bs-toggle="collapse" data-bs-target="#<%= children_accordion_id %>"
data-controller="subjects" data-subject-parent-id="<%= search_result["id"] %>" data-accordion-target="#<%= accordion_body_id %>"
data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
</div>
<% else %>
<%= link_to search_result["name"], "#", class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link",
data: { controller: "application", href: index_url, action: "click->application#openLink" } %>
<%= link_to search_result["name"], index_url, class: "accordion-link text-decoration-none text-dark d-block sub#{search_result["heirarchy_level"] + 1} clickable-link" %>
<% end %>
</div>

6
app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb

@ -15,12 +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, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
<%= 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" %>
</div>
<% else %>
<%= 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",
data: { controller: "application", href: search_documents_path(subject_ids: root.id, is_index_table: true), action: "click->application#openLink" } %>
<%= 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" %>
<% end %>
</div>

8
app/controllers/api/doctrine/annotations_controller.rb

@ -43,7 +43,6 @@ module Api
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
respond_with @annotation
@annotation.index!
else
render errors: @annotation.errors, status: 422
end
@ -55,10 +54,10 @@ module Api
document_ids = params[:document_ids].split(",")
if document_ids.present?
@documents = Cdao::Document.where(id: document_ids)
@documents = Cdao::Jurisprudence.where(id: document_ids)
end
attrs[:document] = Cdao::Document.find(document_id) if document_id.present?
attrs[:document] = Cdao::Jurisprudence.find(document_id) if document_id.present?
if @annotation.update(attrs)
@annotation.annotation_documents.each do |annotation_document|
@ -68,7 +67,6 @@ module Api
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
respond_with @annotation
@annotation.index!
else
render errors: @annotation.errors, status: 422
end
@ -83,7 +81,7 @@ module Api
private
def resource_params
params.permit(:document_id, :content, :phil_rep, :editor_notes, :rank, annomark_ids: [])
params.permit(:document_id, :phil_rep, :editor_notes, :rank, annomark_ids: [])
end
def search_params

18
app/controllers/api/doctrines_controller.rb

@ -28,12 +28,10 @@ module Api
@doctrine.subject_ids = subject_ids if subject_ids.present?
jurisprudence_ids.each do |jurisprudence_id|
doctrine_jurisprudence = @doctrine.doctrine_jurisprudences.create(jurisprudence_id: jurisprudence_id)
doctrine_jurisprudence.jurisprudence.index! if doctrine_jurisprudence.persisted?
@doctrine.doctrine_jurisprudences.create(jurisprudence_id: jurisprudence_id)
end
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
@ -47,7 +45,6 @@ module Api
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
@ -59,19 +56,6 @@ module Api
respond_with @doctrine
end
def suggested_contents
@doctrines = []
search = doctrine_search(search_params.to_unsafe_h.merge({ is_grouped_by_content: true, per_page: 100000 }))
search.group(:content).groups.each do |group_by_content|
group_by_content.results.each do |result|
@doctrines << result
end
end
respond_with @doctrines
end
private
def resource_params

2
app/controllers/api/documents_controller.rb

@ -46,7 +46,7 @@ module Api
def search_params
params.permit(:reference_number, :title, :short_title, :year, :citation_finder,
:q, :page, :per_page,
exclude_ids: [], sort_by: %i[search_year reference_number search_doc_date])
exclude_ids: [])
end
end
end

4
app/controllers/api/jurisprudences_controller.rb

@ -19,9 +19,7 @@ module Api
def years
authorize! :index, Cdao::Jurisprudence
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse
@years = (1901..Time.zone.today.year).entries.reverse
respond_with @years
end

4
app/controllers/concerns/annotation_search.rb

@ -9,10 +9,6 @@ module AnnotationSearch
with field, search_params[field] if search_params[field].present?
end
order_by :library_rank, :asc
order_by :search_year, :desc
order_by :search_doc_date, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end

21
app/controllers/concerns/doctrine_search.rb

@ -9,12 +9,6 @@ module DoctrineSearch
with(:user_ids).any_of(search_params[:user_ids].map(&:to_i)) if search_params[:user_ids].present?
with(:jurisprudence_id, search_params[:jurisprudence_id]) if search_params[:jurisprudence_id].present?
%i[headnote content].each do |field|
with(field, search_params[field]) if search_params[field].present?
end
if search_params[:created_at].present?
with(:created_at).between(Date.parse(search_params[:created_at])..Time.zone.today.to_date)
end
@ -29,21 +23,6 @@ module DoctrineSearch
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
if search_params[:is_grouped_by_headnote].to_s.eql?("true")
group :headnote
end
if search_params[:is_grouped_by_content].to_s.eql?("true")
group :content
end
if search_params[:is_grouped_by_juris_id].to_s.eql?("true")
group :jurisprudence_id
end
order_by :search_year, :desc
order_by :search_doc_date, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end

52
app/controllers/concerns/document_search.rb

@ -1,6 +1,5 @@
module DocumentSearch
def document_search(search_params)
search_params.each { |k, v| params[k] = v.gsub(/“|”/, '"') if v.is_a?(String) }
fulltext_fields = %i[reference_number title short_title].freeze
search = Cdao::Document.search do
@ -14,57 +13,16 @@ module DocumentSearch
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
with(:citation_finders_names).any_of(search_params[:citation_finder]) if search_params[:citation_finder].present?
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
with(:is_only_in_premium_libraries, false)
order_by :doc_date, :desc
order_by :year, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end
search
end
def sanitize_citer_finder_param(citation_finder_param)
citation_finder = []
params_vol = []
params_type = []
params_page = []
params[:citation_finder].scan(/\b((\d+\-?\w?)\s(SCRA|PhilRep|Phil|\S+)\.?,?\s?([-,\d\s]+)?)\b/i).map do |cit_fin|
params_vol << cit_fin[1].gsub(/\s+/, "").gsub(/\A0*/, "")
params_type.concat(case cit_fin[2]
when /SCRA/i
["SCRA"]
when /(PhilRep|Phil)\.?,?/i
["Phil"]
else
[]
end
)
cit_fin[3].scan(/\d+-?\d*/).each do |page|
if page.match?(/-/)
page_range = []
page.scan(/\d+?\d*/).each do |each_page|
page_range << each_page.to_i
end
params_page.concat((page_range[0]..page_range[1]).to_a)
else
params_page << page.to_i if params_page.index(page.to_i).blank?
end
end if cit_fin[3].present?
end
params_type.compact.each do |type|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type}" if params_page.blank?
params_page.compact.uniq.each do |page|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type} #{page}"
end
end
return [] if citation_finder.blank?
citation_finder
end
end

52
app/controllers/concerns/jurisprudence_search.rb

@ -1,6 +1,5 @@
module JurisprudenceSearch
def jurisprudence_search(search_params)
search_params.each { |k, v| params[k] = v.gsub(/“|”/, '"') if v.is_a?(String) }
fulltext_fields = %i[reference_number title short_title].freeze
search = Cdao::Jurisprudence.search do
@ -20,59 +19,18 @@ module JurisprudenceSearch
with(:subject_ids).any_of(search_params[:subject_ids].split(",").map(&:strip).map(&:to_i)) if search_params[:subject_ids].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
with(:citation_finders_names).any_of(search_params[:citation_finder]) if search_params[:citation_finder].present?
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
with(:is_only_in_premium_libraries, false)
order_by :doc_date, :desc
order_by :year, :desc
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20
end
search
end
def sanitize_citer_finder_param(citation_finder_param)
citation_finder = []
params_vol = []
params_type = []
params_page = []
params[:citation_finder].scan(/\b((\d+\-?\w?)\s(SCRA|PhilRep|Phil|\S+)\.?,?\s?([-,\d\s]+)?)\b/i).map do |cit_fin|
params_vol << cit_fin[1].gsub(/\s+/, "").gsub(/\A0*/, "")
params_type.concat(case cit_fin[2]
when /SCRA/i
["SCRA"]
when /(PhilRep|Phil)\.?,?/i
["Phil"]
else
[]
end
)
cit_fin[3].scan(/\d+-?\d*/).each do |page|
if page.match?(/-/)
page_range = []
page.scan(/\d+?\d*/).each do |each_page|
page_range << each_page.to_i
end
params_page.concat((page_range[0]..page_range[1]).to_a)
else
params_page << page.to_i if params_page.index(page.to_i).blank?
end
end if cit_fin[3].present?
end
params_type.compact.each do |type|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type}" if params_page.blank?
params_page.compact.uniq.each do |page|
citation_finder << "#{params_vol[0] if params_vol.present?} #{type} #{page}"
end
end
return [] if citation_finder.blank?
citation_finder
end
end

7
app/controllers/decisions_controller.rb

@ -9,10 +9,7 @@ class DecisionsController < ApplicationController
search = jurisprudence_search(search_params)
@jurisprudences = search.results
start_year = Cdao::Jurisprudence.order(year: :asc).first(10).map(&:year).compact.uniq.first || "1900"
end_year = Cdao::Jurisprudence.order(year: :asc).last(10).map(&:year).compact.uniq.last || Time.zone.today.year
@years = (start_year..end_year).entries.reverse
@years = (1901..Time.zone.today.year).entries.reverse
respond_to do |format|
format.html
@ -23,6 +20,6 @@ class DecisionsController < ApplicationController
def search_params
params.permit(:reference_number, :title, :short_title, :q, :page, :per_page,
:subject_ids, sort_by: %i[search_year reference_number search_doc_date])
:subject_ids)
end
end

4
app/controllers/doctrine/annotations_controller.rb

@ -2,10 +2,6 @@ class Doctrine::AnnotationsController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def new; end
def edit; end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id)

8
app/controllers/doctrines_controller.rb

@ -4,10 +4,6 @@ class DoctrinesController < ApplicationController
load_and_authorize_resource :doctrine, class: "Doctrine"
def new; end
def edit; end
def index
@search = doctrine_search(search_params)
@doctrines = @search.results
@ -19,7 +15,7 @@ class DoctrinesController < ApplicationController
def search
@search = doctrine_search(search_params)
@search_results = @search.results
@doctrines = @search.results
respond_to do |format|
format.html
@ -74,6 +70,6 @@ class DoctrinesController < ApplicationController
end
def search_params
params.permit(:page, :per_page, jurisprudence_ids: [], subject_ids: [])
params.permit(jurisprudence_ids: [], subject_ids: [])
end
end

11
app/controllers/documents_controller.rb

@ -1,9 +1,7 @@
class DocumentsController < ApplicationController
include JurisprudenceSearch
include DoctrineSearch
load_and_authorize_resource :document, class: "Cdao::Jurisprudence", only: %i[index search]
load_and_authorize_resource :document, class: "Cdao::Document", only: %i[show]
load_and_authorize_resource :document, class: "Cdao::Jurisprudence"
def index
@search_params = search_params
@ -17,13 +15,12 @@ class DocumentsController < ApplicationController
end
def show
if @document.library.document_type.eql?(Cdao::Library.first.document_type)
@jurisprudence = Cdao::Jurisprudence.find(@document.doc_id)
@subjects = Cdao::Subject.all
@doctrines = @document.doctrines
where = { enabled: true, state: "published" }
@cited_in_documents = @jurisprudence.class.citing_docs_of(@jurisprudence, where)
@cited_in_documents = @document.class.citing_docs_of(@document, where)
@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)
end

45
app/javascript/controllers/annotations_controller.js

@ -1,6 +1,7 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["q", "document_ids", "annomark_ids", "phil_rep", "editor_notes"]
static targets = ["q", "annotation_id", "doctrine_id", "document_id", "document_ids",
"annomark_ids", "phil_rep", "editor_notes"]
connect () {
super.connect()
@ -18,14 +19,13 @@ export default class extends ApplicationController {
var $this = this, annotation_id = $this.element.dataset["annotationId"], doctrine_id = $this.element.dataset["doctrineId"],
document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#annotationModal")
$modal.find("#current_document_id").val($this.element.dataset["currentDocumentId"])
if(annotation_id !== null && annotation_id !== undefined && annotation_id !== "") {
$modal.find(".modal-title").text("Edit Annotation")
$.get("/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id + ".json", {}, function(result, status) {
$modal.find("#annotation_id").val(annotation_id)
$modal.find("#doctrine_id").val(doctrine_id)
$modal.find("#document_id").val(result.document_id)
$modal.find("#document_ids").val(result.citing_document_ids)
$modal.find("#document_id").val(result.citing_document_ids)
$modal.find("#document_ids").val(result.document_id)
$modal.find("#phil_rep").val(result.phil_rep)
$modal.find("#document_title").val($this.element.dataset["documentTitle"])
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(result.annomark_ids)
@ -46,8 +46,8 @@ export default class extends ApplicationController {
addAnnotatedDocument () {
var document_id = "", document_ref_no = "", document_date = "", document_title = "",
$form = $("#annotationForm"), $doc_title = $form.find("trix-editor[placeholder='Document Title']"),
$citing_document_ids = $form.find("#document_ids")
$modal = $("#annotationModal"), $doc_title = $modal.find("#document_title"),
$citing_document_ids = $modal.find("#document_ids")
document_id = this.element.dataset["documentId"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
@ -68,11 +68,10 @@ export default class extends ApplicationController {
}
save () {
var $this = this, $form = $("#annotationForm"), annotation_id = $this.element.dataset["annotationId"],
jurisprudence_id = $this.element.dataset["jurisprudenceId"], doctrine_id = $this.element.dataset["doctrineId"]
const params = { annomark_ids: $form.find("select[name='annomark_ids[]']").val(), document_id: $this.element.dataset["documentId"],
var $this = this, $modal = $("#annotationModal"), annotation_id = $this.annotation_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
const params = { annomark_ids: $modal.find("select[name='annomark_ids[]']").val(), document_id: $this.document_idTarget.value,
document_ids: $this.document_idsTarget.value || "", phil_rep: $this.phil_repTarget.value || "",
editor_notes: $this.editor_notesTarget.value || "", content: $form.find("input[name='content']").val() }
editor_notes: $this.editor_notesTarget.value || "" }
if (annotation_id !== null && annotation_id !== undefined && annotation_id !== "") {
$.ajax({
@ -81,35 +80,21 @@ export default class extends ApplicationController {
data: params,
success: function() {
$(".btn-close-x").trigger("click")
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
},
error: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$this.stimulate("AnnotationReflex#render_annotations_views", { page: 1 })
}
})
} else {
$.post("/api/doctrines/" + doctrine_id + "/annotations", params, function(result, status) {
if(status === "success") {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
} else {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$(".btn-close-x").trigger("click")
$this.stimulate("AnnotationReflex#render_annotations_views", { page: 1 })
}
})
}
}
delete(ev) {
var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"],
jurisprudence_id = $this.element.dataset["jurisprudenceId"]
var $this = this, doctrine_id = $this.element.dataset["doctrineId"], annotation_id = this.element.dataset["annotationId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
@ -118,9 +103,7 @@ export default class extends ApplicationController {
url: "/api/doctrines/" + doctrine_id + "/annotations/" + annotation_id,
type: 'DELETE',
success: function() {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
location.pathname = "/documents/" + jurisprudence_id + "/doctrines/" + doctrine_id
$this.stimulate("AnnotationReflex#render_annotations_views", { page: 1 })
}
})
}

32
app/javascript/controllers/application_controller.js

@ -21,31 +21,23 @@ import Selectize from "selectize";
*/
export default class extends Controller {
connect () {
$(".reset-document-advanced-search").on("click", function (ev) {
ev.preventDefault()
$(".clickable-link").on("click", function (e) {
e.preventDefault();
var $advanced_search_box = $(".advanced-search-box")
$.each($advanced_search_box.find("input[type='text']"), function(_, el) {
$(el).val("")
})
$.each($advanced_search_box.find("select"), function(_, el) {
$(el).val("")
})
})
StimulusReflex.register(this)
let $href = $(this).attr("href");
if ($href !== undefined) {
window.location.href = $href;
}
});
openLink ($event) {
$event.preventDefault()
window.location.href = this.element.dataset['href']
$(".clickable-tr").on("click", function () {
let $href = $(this).attr("href");
if ($href !== undefined) {
window.open($href);
}
})
openLinkToNewTab ($event) {
$event.preventDefault()
window.open(this.element.dataset['href'])
StimulusReflex.register(this)
}
/* Application-wide lifecycle methods

171
app/javascript/controllers/doctrines_controller.js

@ -1,7 +1,6 @@
import ApplicationController from './application_controller'
var annotations_attributes = []
export default class extends ApplicationController {
static targets = ["input", "q", "document_id", "doctrine_id", "headnote", "content"]
static targets = ["input", "document_id", "doctrine_id", "headnote", "content"]
connect () {
super.connect()
@ -50,77 +49,27 @@ export default class extends ApplicationController {
}
save () {
var $this = this, $form = $("#doctrineForm"), document_id = $this.document_idTarget.value, doctrine_id = $this.doctrine_idTarget.value
var params = { subject_ids: $form.find("select[name='subject_ids[]']").val(), headnote: $this.headnoteTarget.value,
content: $this.contentTarget.value }
var $modal = $("#doctrineModal"), document_id = this.document_idTarget.value, doctrine_id = this.doctrine_idTarget.value
var params = { subject_ids: $modal.find("select[name='subject_ids[]']").val(), headnote: this.headnoteTarget.value,
content: this.contentTarget.value }
if (!params.subject_ids.length) {
$form.find("#subjects-blank-message").show()
}
if (!params.headnote.length) {
$form.find("#headnote-blank-message").show()
}
if (!params.content.length) {
$form.find("#content-blank-message").show()
}
if (params.subject_ids.length && params.headnote.length && params.content.length) {
if (doctrine_id !== null && doctrine_id !== undefined && doctrine_id !== "") {
$.ajax({
url: "/api/doctrines/" + doctrine_id,
type: 'PUT',
data: params,
success: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
},
error: function() {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show();
$('.toast').fadeOut(5000);
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
}
})
} else {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(doctrine, status) {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(data, status) {
if(status === 'success') {
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Doctrine was successfully saved</b></span>" );
$('.toast').fadeOut(5000);
if (annotations_attributes.length > 0) {
$.each(annotations_attributes, function(index, annotation) {
$.post("/api/doctrines/" + doctrine.id + "/annotations", annotation, function(result, status) {
if(status === 'success') {
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Case Lists was successfully saved</b></span>" );
$('.toast').fadeOut(5000);
if (index === annotations_attributes.length - 1) {
$(window).delay(5000).queue(function() {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
})
}
}
})
})
} else {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
}
} else {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id + "/doctrines/" + data.id
}
})
}
}
}
delete(ev) {
var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"]
@ -132,117 +81,9 @@ export default class extends ApplicationController {
url: "/api/doctrines/" + doctrine_id,
type: 'DELETE',
success: function() {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id
},
error: function () {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
$('.toast').fadeOut(5000);
}
})
}
}
searchCitingDocuments () {
this.stimulate("DoctrinesReflex#render_citing_documents_search_results", { q: this.qTarget.value, page: 1 })
}
paginateCitingDocuments () {
this.stimulate("AnnotationReflex#render_citing_documents_search_results", { q: this.element.dataset["q"], page: this.element.dataset["page"] })
}
addCitingDocument () {
var document_id = "", document_ref_no = "", document_date = "", document_title = "",
$modal = $("#annotationModal"), $doc_title = $modal.find("trix-editor[placeholder='Document Title']"),
$citing_document_ids = $modal.find("#document_ids")
document_id = this.element.dataset["documentId"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
document_date = this.element.dataset["documentDate"]
document_title = this.element.dataset["documentTitle"]
var document_ids = []
if ($citing_document_ids.val() !== null && $citing_document_ids.val() !== undefined && $citing_document_ids.val() !== "") {
document_ids = $citing_document_ids.val().split(",")
}
document_ids.push(document_id)
$citing_document_ids.val(document_ids.join(","))
var doc_title = $doc_title.val()
$doc_title.val(doc_title + " citing " + [document_title, document_ref_no, document_date].join(", "))
}
removeAnnotation () {
var index = this.element.dataset["annotationsAttributesIndex"]
const contrim_alert = confirm("Are you sure that you want to remove this Case List?")
if (contrim_alert) {
annotations_attributes.splice(index, 1)
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Case List is successfully removed.</b></span>" );
$('.toast').fadeOut(5000)
this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes)
}
}
saveAnnotation () {
var $modal = $("#annotationModal"), annotaitons_attributes_index = $modal.find("#annotaitons_attributes_index").val()
var params = { document_id: $modal.find("#document_id").val(), document_ids: $modal.find("#document_ids").val().split(","),
content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(),
editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
if (annotaitons_attributes_index.length > 0) {
annotations_attributes.splice(annotaitons_attributes_index, 1, params)
$( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" );
} else {
annotations_attributes.push(params)
$( ".toast-body" ).html( "<span><b>Case List is successfully added.</b></span>" );
}
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$('.toast').fadeOut(5000);
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue([])
this.stimulate("DoctrinesReflex#render_doctrine_form_annotations_view", annotations_attributes)
this.stimulate("DoctrinesReflex#render_default_citing_documents")
this.stimulate("DoctrinesReflex#render_default_case_lists")
}
newAnnotation () {
var document_title = "", document_ref_no = "", document_date_or_year = "", $modal = $("#annotationModal")
$modal.find(".modal-title").text("New Annotation")
document_title = this.element.dataset["documentTitle"]
document_ref_no = this.element.dataset["documentReferenceNumber"]
document_date_or_year = this.element.dataset["documentDateOrYear"]
$modal.find("select[name='annomark_ids[]']").val([])
$modal.find("#doctrine_id").val(null)
$modal.find("trix-editor[placeholder='Document Title']").val([document_title, document_ref_no, document_date_or_year].join(", "))
$modal.find("#document_id").val(this.element.dataset["documentId"])
$modal.find("#phil_rep").val(this.element.dataset["documentPhilRep"])
}
editAnnotation () {
var $modal = $("#annotationModal"), annotations_attributes_index = this.element.dataset["annotationsAttributesIndex"],
annotation = annotations_attributes[annotations_attributes_index]
$modal.find(".modal-title").text("Edit Annotation")
$modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(annotation.annomark_ids)
$modal.find("trix-editor[placeholder='Document Title']").val(annotation.content)
$modal.find("#document_id").val(annotation.document_id)
$modal.find("#annotaitons_attributes_index")[0].selectize.setValue(annotations_attributes_index)
if (annotation.document_ids.length) {
$modal.find("#document_ids").val(annotation.document_ids.join(","))
}
$modal.find("#phil_rep").val(annotation.phil_rep)
}
}

22
app/javascript/controllers/document_controller.js

@ -1,6 +1,6 @@
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["input", "citation_finder"]
static targets = ["input"]
connect () {
super.connect()
@ -8,26 +8,14 @@ export default class extends ApplicationController {
search () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
searchDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 })
}
paginateDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] })
{ q: this.inputTarget.value, page: 1 },
this.element.dataset["doctrineId"])
}
paginate () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
{ q: this.element.dataset["q"], page: this.element.dataset["page"] },
this.element.dataset["doctrineId"])
}
loadYears () {

16
app/javascript/controllers/selectize_controller.js

@ -18,9 +18,8 @@ export default class extends ApplicationController {
$(".default-selectize").selectize(default_opts);
var $doctrine_form = $("#doctrineForm")
var $doctrine_content = $doctrine_form.find("input[name='content']");
var $trix_content = $doctrine_form.find("trix-editor[placeholder='Doctrine Content']");
var $doctrine_content = $("#doctrineModal").find("input[name='content']");
var $trix_content = $("#doctrineModal").find(".trix-content");
var doctrine_content_suggestions_opts = {
onChange: function (value) {
@ -31,7 +30,6 @@ export default class extends ApplicationController {
$.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) {
if (status === "success") {
$doctrine_content.val(doctrine.content);
$doctrine_form.find("input[name='headnote']").val(doctrine.headnote)
$trix_content.val(doctrine.content);
}
});
@ -49,12 +47,12 @@ export default class extends ApplicationController {
},
onChange: function (value) {
var selectize_options = []
var $selectize = $("#doctrineForm").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
if (value.length === 0) {
if ($selectize.length) $selectize[0].selectize.clearOptions();
} else {
$.get("/api/doctrines/suggested_contents.json", { subject_ids: value }, function(data, status) {
$.get("/api/doctrines.json", { subject_ids: value }, function(data, status) {
if (status === "success") {
$.each(data, function (i, doctrine) {
selectize_options.push({ id: doctrine.id, value: doctrine.content, text: doctrine.plain_content });
@ -90,9 +88,9 @@ export default class extends ApplicationController {
if ($subjects_selectize.length) $subjects_selectize[0].selectize.addOption(result, true);
})
//this code will be autoFocus on the first selectize
// if ($subject_ids_selectize.length) $subject_ids_selectize[0].selectize.refreshOptions();
// if ($subjects_selectize.length) $subjects_selectize[0].selectize.refreshOptions();
if ($subject_ids_selectize.length) $subject_ids_selectize[0].selectize.refreshOptions();
if ($subjects_selectize.length) $subjects_selectize[0].selectize.refreshOptions();
}
});

3
app/javascript/controllers/subjects_controller.js

@ -9,6 +9,7 @@ export default class extends ApplicationController {
opts = { parent_accordion_id: $this.element.dataset["accordionId"], accordionTarget: $this.element.dataset["accordionTarget"],
accordionFor: $this.element.dataset["accordionFor"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {
@ -28,6 +29,7 @@ export default class extends ApplicationController {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {
@ -47,6 +49,7 @@ export default class extends ApplicationController {
var $this = this, params = { per_page: 10000 }, parent_id = $this.element.dataset["subjectParentId"],
opts = { accordionTarget: $this.element.dataset["accordionTarget"] }
console.log(opts)
if (parent_id !== null && parent_id !== undefined && parent_id !== "") {
params.parent_id = parent_id
} else {

8
app/javascript/packs/application.js

@ -36,12 +36,6 @@ $(document).on("ready turbolinks:load", function () {
$('#sidenav').toggleClass('active');
});
$("#toast-close").click(function(){
$('.toast').hide();
});
$(".spinner-border").hide();
var default_config = { altFormat: "m/d/Y", altInput: true, enableTime: false, dateFormat: "Y-m-d", isMobile: true };
$('.default-flatpickr').flatpickr(default_config);
@ -62,7 +56,7 @@ $(document).on("ready turbolinks:load", function () {
a = $(this), b = $(a.attr('href'))
if(b.length<=0)return
event.preventDefault()
document.getElementById(b[0].id).scrollIntoView( {behavior: "smooth", duration: 700 })
$('html, body, .tab-content').animate({ scrollTop: b.offset().top }, 700, 'linear')
})
});

34
app/javascript/src/application.scss

@ -117,37 +117,3 @@
overflow-x: hidden;
// box-shadow: inset 0 0 0 2000px rgba(251, 251, 251, 0.3);
}
.subject-ids-selectize {
width: auto !important;
}
.not-full input {
width: auto !important;
}
// Footnotes
.footnote-x a {
font-size:12px; vertical-align: 20%;
color: red;
font-weight: bold;
text-decoration: none;
}
.footnote-x a.tip span{
display: none
}
.footnote-x a.tip:hover span{
border: #c0c0c0 1px dotted;
padding: 5px 20px 5px 5px;
display: block;
z-index: 100;
background-color: #87cefa;
left: 0px;
margin: 10px;
width: 250px;
position: absolute;
top: 10px;
text-decoration: none
}

9
app/javascript/src/application/subject-accordion.scss

@ -27,12 +27,3 @@
margin-right: 65px !important;
}
.sub-icon-add a {
font-size: large;
color: #4caf50;
}
.sub-icon-add a:hover {
color: darkred;
}

66
app/jobs/parse_linkable_content_job.rb

@ -1,66 +0,0 @@
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

17
app/models/annotation.rb

@ -11,8 +11,6 @@ class Annotation < ApplicationRecord
has_many :annotation_annomarks, dependent: :destroy
has_many :annomarks, through: :annotation_annomarks
validates :content, presence: true
def documents
annotation_documents.collect(&:document)
end
@ -35,21 +33,6 @@ class Annotation < ApplicationRecord
integer :document_id
integer :doctrine_id
integer :library_rank do
document.library.rank
end
integer :search_year do
document.year.present? && document.year > 0 ? document.year : (document.doc_date.try :year)
end
date :search_doc_date do
document.doc_date.presence || Date.new(year.presence || 0)
end
date :created_at
date :updated_at
text :phil_rep
string :phil_rep

23
app/models/cdao/document.rb

@ -1,8 +1,6 @@
class Cdao::Document < Cdao::Base
self.table_name = "documents"
belongs_to :library, class_name: "Cdao::Library", optional: false
alias_attribute :docdate, :doc_date
alias_attribute :short_title, :title
@ -14,15 +12,6 @@ class Cdao::Document < Cdao::Base
(reference_number.presence || "").gsub(/<!--\d+-->/, "")
end
def doc_date_display
doc_date.present? ? doc_date.strftime("%B %d, %Y") : year
end
def display_text
title_display = short_title || title
[title_display, clean_reference_number, doc_date_display].join(", ")
end
def libraries
Cdao::DocumentLibrary.where(library_product_type: doc_type, library_product_id: doc_id).map(&:library)
end
@ -31,13 +20,6 @@ class Cdao::Document < Cdao::Base
libraries.all?(&:premium?)
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)
Jbuilder.new do |doc|
doc.(self, *%i[id title short_title])
@ -87,11 +69,6 @@ class Cdao::Document < Cdao::Base
integer :id
integer :year
integer :library_rank do
library.rank
end
integer :search_year do
year.present? && year > 0 ? year : (doc_date.try :year)
end

7
app/models/cdao/jurisprudence.rb

@ -1,7 +1,6 @@
class Cdao::Jurisprudence < Cdao::Base
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 :doctrine_jurisprudences, dependent: :destroy
@ -30,10 +29,6 @@ class Cdao::Jurisprudence < Cdao::Base
Cdao::Citation.where(cited_doc_id: self.id, cited_doc_type: self.class.name.gsub("Cdao::", ""))
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 = {})
citing_docs = []
c_arel = Cdao::Citation.arel_table
@ -168,5 +163,7 @@ class Cdao::Jurisprudence < Cdao::Base
boolean :is_only_in_premium_libraries do
is_only_in_premium_libraries?
end
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :document_id, :to => :id })
end
end

9
app/models/cdao/subject.rb

@ -67,19 +67,14 @@ class Cdao::Subject < Cdao::Base
sub6_name = names[6]
root = Cdao::Subject.find_or_create_by(name: root_name, ancestry: nil) if root_name.present?
root.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if root.persisted?
sub1 = root.children.find_or_create_by(name: sub1_name) if root.present? && sub1_name.present?
sub1.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub1.present? && sub1.persisted?
sub2 = sub1.children.find_or_create_by(name: sub2_name) if sub1.present? && sub2_name.present?
sub2.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub2.present? && sub2.persisted?
sub3 = sub2.children.find_or_create_by(name: sub3_name) if sub2.present? && sub3_name.present?
sub3.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub3.present? && sub3.persisted?
sub4 = sub3.children.find_or_create_by(name: sub4_name) if sub3.present? && sub4_name.present?
sub4.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub4.present? && sub4.persisted?
sub5 = sub4.children.find_or_create_by(name: sub5_name) if sub4.present? && sub5_name.present?
sub5.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub5.present? && sub5.persisted?
sub6 = sub5.children.find_or_create_by(name: sub6_name) if sub5.present? && sub6_name.present?
sub6.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub6.present? && sub6.persisted?
root.descendants.each { |a| a.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] } if root.present?
end
end

104
app/models/doctrine.rb

@ -10,6 +10,7 @@ class Doctrine < ApplicationRecord
has_many :annotations, dependent: :destroy
validates :content, presence: true
validates :content_fingerprint, uniqueness: true
before_validation do
self.content_fingerprint = Digest::SHA256.hexdigest(content)
@ -19,14 +20,6 @@ class Doctrine < ApplicationRecord
DoctrineSubject.where(doctrine_id: self.id)
end
def jurisprudences
Cdao::Jurisprudence.where(id: doctrine_jurisprudences.map(&:jurisprudence_id)).order(year: :desc, docdate: :desc)
end
def jurisprudence
jurisprudences.first
end
def subjects
Cdao::Subject.where(id: doctrine_subjects.map(&:subject_id))
end
@ -90,86 +83,8 @@ class Doctrine < ApplicationRecord
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
end
end
end
def self.parse_csv_file_new(parent_id, path)
::CSV.foreach(path).each_with_index do |data, index|
row_no = index + 1
subject_name = data[0].strip
headnote = ""
content = data[1].strip
doc_url = data[8].strip
# Annotations
annomark_name = (data[2] || "").strip
editor_note = (data[4] || "").strip
phil_rep = ""
doc_urls = (data[5] || "").strip.split("citing").map(&:strip)
if doc_urls.present?
anno_doc_url = doc_urls.first
citing_doc_url = doc_urls.count > 1 ? doc_urls.last : ""
end
next if [content, doc_url].any?(&:blank?)
parent = Cdao::Subject.find(parent_id)
subject = parent.descendants.find_or_initialize_by(name: subject_name)
if subject.new_record?
subject.save
subject.library_ids = [27]
end
logger = Logger.new(Rails.root.join("log/import.doctrines.log"))
if subject.blank?
logger.info "[#{row_no}] - no subject found"
next
end
subject_id = subject.id
doc_id = doc_url.split("?").first.split("/").map(&:strip).last
if anno_doc_url.present?
anno_doc_args = anno_doc_url.split("?").first.split("/").map(&:strip).last(2)
anno_doc_type = anno_doc_args.first.classify
anno_doc_id = anno_doc_args.last
annotation_document = Cdao::Document.find_by(doc_type: anno_doc_type, doc_id: anno_doc_id)
end
if citing_doc_url.present?
citing_doc_args = citing_doc_url.split("?").first.split("/").map(&:strip).last(2)
citing_doc_type = citing_doc_args.first.classify
citing_doc_id = citing_doc_args.last
citing_document = Cdao::Document.find_by(doc_type: citing_doc_type, doc_id: citing_doc_id)
end
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.library_subjects.find_or_create_by(library_id: 27)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
# Annotations
phil_rep = ""
annomark = Annomark.find_by(name: annomark_name)
annotation = record.annotations.new
annotation.annomark_ids = [annomark.id] if annomark.present?
annotation.document = annotation_document
annotation.phil_rep = phil_rep || annotation_document.phil_rep
annotation.editor_notes = editor_note
if annotation.save
annotation.add_document(citing_document) if citing_document.present?
end
else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
end
@ -181,27 +96,14 @@ class Doctrine < ApplicationRecord
integer :id
integer :jurisprudence_id do
jurisprudence.id
end
integer :subject_ids, multiple: true
integer :user_ids, multiple: true do
paper_trail.originator.to_i
end
integer :search_year do
jurisprudence.year.present? && jurisprudence.year > 0 ? jurisprudence.year : (jurisprudence.doc_date.try :year)
end
date :search_doc_date do
jurisprudence.doc_date.presence || Date.new(jurisprudence.year.presence || 0)
end
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :annotation_doctrine_id, :to => :id })
date :created_at
string :headnote
string :content
end
end

1
app/models/doctrine_jurisprudence.rb

@ -3,5 +3,4 @@ class DoctrineJurisprudence < ApplicationRecord
belongs_to :doctrine, optional: false
belongs_to :jurisprudence, class_name: "Cdao::Jurisprudence", optional: false
end

6
app/reflexes/annotation_reflex.rb

@ -5,7 +5,7 @@ class AnnotationReflex < ApplicationReflex
include AnnotationSearch
def render_document_search_results(search_params)
search = document_search(search_params.merge(sort_by: %w[reference_number_texts title_texts short_title_texts]))
search = document_search(search_params)
@documents = search.results
opts = { current_page: search_params[:page], q: search_params[:q] }
morph "#annotatedDocumentsSearchResults", render(partial: "/shared/annotated_documents_search_results", locals: { documents: @documents, opts: opts })
@ -17,8 +17,4 @@ class AnnotationReflex < ApplicationReflex
morph "#annotationsIndexView", render(partial: "/shared/annotations_index_view", locals: { annotations: @annotations,
opts: { doctrine_id: search_params[:doctrine_id], current_page: search_params[:page] } })
end
def render_default_case_lists_search(doctrine_id)
morph "#caseListsCollapse", render(partial: "/shared/case_lists_no_results", locals: { doctrine_id: doctrine_id })
end
end

42
app/reflexes/doctrines_reflex.rb

@ -1,42 +0,0 @@
# frozen_string_literal: true
class DoctrinesReflex < ApplicationReflex
include DoctrineSearch
include DocumentSearch
def render_document_doctrines_index(search_params)
search = doctrine_search(search_params)
morph "#doctrinesIndexView", render(partial: "/shared/document_doctrines_index", locals: { doctrines: search.results, current_user: current_user, opts: { document_id: search_params[:jurisprudence_id], current_page: search_params[:page] } })
end
def render_annotation_modal_form(document_id, doctrine_id)
jurisprudence = Cdao::Jurisprudence.find(document_id)
document = Cdao::Document.where(reference_number: jurisprudence.reference_number).first
morph "#doctrineModal", render(partial: "/shared/annotation_modal_form", locals: { document: document, doctrine_id: doctrine_id, jurisprudence: jurisprudence })
end
def render_annotation_form(document_id, doctrine_id)
jurisprudence = Cdao::Jurisprudence.find(document_id)
document = Cdao::Document.where(reference_number: jurisprudence.reference_number).first
morph "#doctrineForm", render(partial: "/shared/annotation_form", locals: { annotation: Annotation.new, document: document, doctrine_id: doctrine_id, jurisprudence: jurisprudence })
end
def render_doctrine_form_annotations_view(annotations)
morph "#doctrineAnnotationsView", render(partial: "/shared/doctrine_form_annotations_view", locals: { annotations: annotations })
end
def render_citing_documents_search_results(search_params)
search = document_search(search_params.merge(sort_by: %w[reference_number_texts title_texts short_title_texts]))
@documents = search.results
opts = { current_page: search_params[:page], q: search_params[:q] }
morph "#citingDocumentsSearchResults", render(partial: "/shared/doctrine_form_citing_documents_search_results", locals: { documents: @documents, opts: opts })
end
def render_default_citing_documents
morph "#citingDocumentsSearchResults", render(partial: "/shared/doctrine_form_citing_documents_search_results", locals: { documents: [], opts: {} })
end
def render_default_case_lists
morph "#caseListsCollapse", render(partial: "/shared/doctrine_form_default_case_lists", locals: { documents: @documents, opts: {} })
end
end

13
app/reflexes/document_reflex.rb

@ -3,10 +3,10 @@
class DocumentReflex < ApplicationReflex
include DocumentSearch
def render_case_lists_search_results(search_params, doctrine_id, jurisprudence_id)
search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts]))
def render_case_lists_search_results(search_params, doctrine_id)
search = document_search(search_params)
@documents = search.results
opts = { doctrine_id: doctrine_id, jurisprudence_id: jurisprudence_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
opts = { doctrine_id: doctrine_id, current_page: search_params[:page], q: search_params[:q] }
morph "#caseListsCollapse", render(partial: "/shared/case_lists_search_results", locals: { documents: @documents, opts: opts })
end
@ -19,11 +19,4 @@ class DocumentReflex < ApplicationReflex
@documents = search.results
morph "tbody#modalDocumentSearchTable", render(partial: "document_search_results_table", locals: { search_results: @documents, opts: { is_citing_document: true } })
end
def render_doctrine_form_case_lists(search_params)
search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts]))
@documents = search.results
opts = { current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
morph "#caseListsCollapse", render(partial: "/shared/doctrine_form_case_lists", locals: { documents: @documents, opts: opts })
end
end

3
app/views/api/doctrines/suggested_contents.json.jbuilder

@ -1,3 +0,0 @@
json.array!(@doctrines) do |doctrine|
json.extract! doctrine, *%i[id subject_ids headnote content plain_content created_at updated_at]
end

15
app/views/doctrine/annotations/edit.html.erb

@ -1,15 +0,0 @@
<div class="container-fluid mt-2 p-0" id="annotationForm"
data-controller="annotations" data-annotation-id="<%= @annotation.id %>" data-doctrine-id="<%= @annotation.doctrine_id %>"
data-document-id="<%= @annotation.document_id %>" data-jurisprudence-id="<%= params[:jurisprudence_id] %>">
<div class="col-sm-12">
<div class="card-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> Edit Annotation </h4> </div>
<div class="card-body">
<%= render(AnnotationFormComponent.new(current_user: current_user, annotation: @annotation)) %>
</div>
<div class="card-footer d-flex justify-content-end mt-2">
<button type="button" class="btn btn-success me-2" data-action="click->annotations#save">Save</button>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], @doctrine.id) %>">Back</a>
</div>
</div>
</div>
</div>

16
app/views/doctrine/annotations/new.html.erb

@ -1,16 +0,0 @@
<div class="container-fluid mt-2 p-0" id="annotationForm"
data-controller="annotations" data-annotation-id data-doctrine-id="<%= params[:doctrine_id] %>"
data-document-id="<%= params[:document_id] %>" data-jurisprudence-id="<%= params[:jurisprudence_id] %>">
<div class="col-sm-12">
<div class="card-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> New Annotation </h4> </div>
<div class="card-body">
<%= render(AnnotationFormComponent.new(current_user: current_user, annotation: @annotation,
opts: { document_id: params[:document_id] })) %>
</div>
<div class="card-footer d-flex justify-content-end mt-2">
<button type="button" class="btn btn-success me-2" data-action="click->annotations#save">Save</button>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], params[:doctrine_id]) %>">Back</a>
</div>
</div>
</div>
</div>

12
app/views/doctrines/edit.html.erb

@ -1,12 +0,0 @@
<div class="container-fluid mt-2 p-0" data-controller="doctrines" id="doctrineForm">
<div class="col-sm-12">
<div class="card-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> Edit Doctrine </h4> </div>
<div class="card-body">
<%= render(DoctrineFormComponent.new(current_user: current_user, doctrine: @doctrine, jurisprudence_id: params[:jurisprudence_id])) %>
</div>
<div class="card-footer d-flex justify-content-end mt-2">
<button type="button" class="btn btn-success me-2" data-action="click->doctrines#save">Save</button>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], @doctrine) %>">Back</a>
</div>
</div>
</div>

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

@ -1,64 +0,0 @@
<div class="container-fluid mt-2 p-0" data-controller="doctrines" id="doctrineForm">
<div class="col-sm-12">
<div class="card-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> New Doctrine </h4> </div>
<div class="card-body">
<%= render(DoctrineFormComponent.new(current_user: current_user, doctrine: @doctrine, jurisprudence_id: params[:jurisprudence_id])) %>
<% if @doctrine.new_record? %>
<div class="row">
<div class="col-sm-10"> </div>
<div class="col-sm-2 p-2">
<button type="button" class="btn btn-info d-block ms-auto text-white" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case List </button>
</div>
</div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document">
<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" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success btn-sm me-2", data: { action: "click->document#searchDoctrineFormCaseLists" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, nil, class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
</div>
</div>
<div class="row tab">
<div class="col-sm-12default-pagination"> </div>
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
</thead>
</table>
</div>
</div>
<div class="row-flex">
<div class="annot-header"> <h5> Annotations </h5> </div>
<div class="" id="doctrineAnnotationsView"> </div>
</div>
<% end %>
</div>
<div class="card-footer d-flex justify-content-end mt-2">
<button type="button" class="btn btn-success me-2" data-action="click->doctrines#save">Save</button>
<% if params[:doctrine_id].present? %>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], params[:doctrine_id]) %>">Back</a>
<% else %>
<a class="btn btn-danger ms-2" href="<%= document_path(params[:document_id]) %>">Back</a>
<% end %>
</div>
</div>
</div>
</div>
<% if @doctrine.new_record? %>
<div class="row">
<%= render partial: "/shared/doctrine_form_annotation_modal_form" %>
</div>
<% end %>

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

@ -1,6 +1,11 @@
<div class="container-fluid mt-1 p-0 doctrine-index-body">
<div class="container-fluid m-2 p-0"> <%= render PaginationComponent.new(data: @search_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: @doctrines, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids], is_index_table: params[:is_index_table] }) %> </div>
<hr class="mt-0"/>
<%= render(DoctrineIndexComponent.new(search_results: @search_results, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %>
<% if params[:is_index_table].to_s.eql?("true") %>
<div class="card-body col-sm-12 tableFixHead p-0 mt-1">
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines, opts: { is_index_table: params[:is_index_table].to_s.eql?("true") })) %>
</div>
<% else %>
<%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { subject_ids: params[:subject_ids] })) %>
<% end %>
</div>

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

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

8
app/views/document/doctrines/_document_search_results_table.html.erb

@ -1,14 +1,14 @@
<% search_results.each do |search_result| %>
<tr>
<td style="width: 25%"> <%= search_result.clean_reference_number %> </td>
<td style="width: 45%"> <%= search_result.short_title || search_result.title %> </td>
<td style="width: 15%"> <%= search_result.doc_date.present? ? search_result.doc_date : search_result.year %> </td>
<td> <%= search_result.clean_reference_number %> </td>
<td> <%= search_result.short_title || search_result.title %> </td>
<td> <%= search_result.doc_date.present? ? search_result.doc_date : search_result.year %> </td>
<% if opts[:is_case_lists].present? && opts[:doctrine_id].present? %>
<td>
<% date_or_year = search_result.doc_date || search_result.year %>
<% title = search_result.short_title || search_result.title %>
<a class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="annotations"
<a class="btn btn-success" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="annotations"
data-doctrine-id="<%= opts[:doctrine_id] %>" data-document-id="<%= search_result.id %>" data-document-title="<%= title %>"
data-document-reference-number="<%= search_result.clean_reference_number %>" data-document-date-or-year="<%= date_or_year %>"
data-document-phil-rep="<%= search_result.phil_rep %>" data-action="click->annotations#renderForm">

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

@ -5,11 +5,7 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<% 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>
<% else %>
<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 %>
</div>
<div class="col-lg-3 text-end">
<b>Date : </b>
@ -47,12 +43,12 @@
<div class="card-body pt-0">
<div class="row">
<div class="d-flex justify-content-end p-2">
<a class="btn btn-warning" href="<%= new_doctrine_path(jurisprudence_id: @document.id, doctrine_id: @doctrine.id ) %>"> Add Doctrine </a>
<a class="btn btn-success" data-controller="doctrines" data-document-id="<%= @document.id %>" data-action="click->doctrines#renderForm" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Add Doctrine </a>
</div>
</div>
<div class="row">
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, opts: { jurisprudence_id: @document.id })) %>
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, document_id: @document.id, subjects: @subjects)) %>
</div>
</div>
</div>

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

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

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

@ -1,8 +1,21 @@
<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 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="card-body col-sm-12 tableFixHead p-0 mt-1">
<%= 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 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>
</div>
</div>

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

@ -11,11 +11,7 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<% 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 %>
<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>
</div>
<div class="col-lg-3 text-end">
<b>Date : </b>
@ -50,64 +46,39 @@
</div>
<div class="card-body p-0">
<ul class="doc-nav-body nav nav-tabs nav-justified" id="menuTab" role="tablist">
<% if @jurisprudence.present? %>
<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>
</li>
<% end %>
<li class="nav-item" role="presentation">
<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>
<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>
</li>
<% if @jurisprudence.present? %>
<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>
</li>
<% end %>
</ul>
<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="row">
<div class="d-flex justify-content-end" style="margin: 10px 0 0 -20px;">
<a class="btn btn-warning" href="<%= new_doctrine_path(document_id: @document.id, jurisprudence_id: @jurisprudence.id) %>"> Add Doctrine </a>
<a class="btn btn-success" data-controller="doctrines" data-document-id="<%= @document.id %>" data-action="click->doctrines#renderForm" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Add Doctrine </a>
</div>
</div>
<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="accordion accordion-flush" id="documentSubjectsAccordion">
<% @jurisprudence.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 class="container-sm row-flex col-sm-12 mt-2">
<%= render(DoctrineModalFormComponent.new(current_user: current_user)) %>
</div>
</div>
<% 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-body pt-1 pb-1 sub-body1">
<%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user)) %>
</div>
</div>
</div>
<% end %>
</div>
</div>
<div class="container-sm row-flex col-sm-12 p-0 doct-body-index">
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { document_id: @document.id })) %>
</div>
</div>
<% end %>
<div class="tab-pane fade <%= @jurisprudence.blank? ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="tab-pane fade <%= params[:is_document_view].to_s.eql?("true") ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="container-sm mt-2">
<%= raw @document.content.html_safe%>
</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="d-flex align-items-baseline">
<div class="col-md-6 mt-3 ps-3"> <h4> Cited In </h4> </div>
@ -125,7 +96,6 @@
</tbody>
</table>
</div>
<% end %>
</div>
</div>
</div>

16
app/views/layouts/application.html.erb

@ -54,28 +54,14 @@
<%= render(DoctrinesOffcanvasComponent.new(current_user: current_user, opts: { is_render: true })) %>
<div class="<%= current_user.present? ? 'row flex-nowrap h-100 w-100 p-0 ms-0' : 'row h-100 justify-content-end align-items-center' %>">
<div class="<%= current_user.present? ? 'd-none' : 'col-sm-7 login-logo' %>">
<%= image_pack_tag 'application/cdasiaonline_logo.png', class:"app-logo" %>
</div>
<div class="text-center" style="margin-top: 100px;position: absolute;">
<div class="spinner-border loading" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<div class="<%= current_user.present? ? 'col-sm-12 py-3 main-content-body mt-5' : 'col-sm-5 login-body-box' %>">
<div class="<%= current_user.present? ? 'col py-3 main-content-body mt-5' : 'col-sm-5 login-body-box' %>">
<div class="content-body">
<%= yield %>
</div>
</div>
</div>
<div class="toast align-items-center text-white border-0" data-bs-autohide="true" role="alert" aria-live="assertive" aria-atomic="true" style="position: absolute;bottom: 20px;right: 10px;">
<div class="d-flex">
<div class="toast-body">
</div>
<button type="button" class="btn-close btn-close-white me-2 m-auto" id="toast-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
</div>
</body>
</html>

4
app/views/reports/index.html.erb

@ -8,7 +8,7 @@
<hr class="simple">
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Subjects </label>
<select class="subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
<select class="form-control subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
</div>
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Date Created (Start) </label>
@ -23,7 +23,7 @@
<hr class="simple">
<div class="mb-3">
<label for="exampleFormControlInput1" class="form-label text-white"> Users </label>
<%= select_tag :user_ids, options_from_collection_for_select(@users, :id, :name, params[:user_ids]), class: "default-selectize p-0", multiple: true %>
<%= select_tag :user_ids, options_from_collection_for_select(@users, :id, :name, params[:user_ids]), class: "form-control default-selectize p-0", multiple: true %>
</div>
<div class="d-flex justify-content-end mt-5">

7
app/views/shared/_annotated_documents_search_results.html.erb

@ -1,6 +1,6 @@
<div class="row" data-controller="annotations">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "annotations.input" } %>
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number", data: { target: "annotations.input" } %>
</div>
<div class="col-sm-1 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->annotations#searchDocuments" } %>
@ -78,15 +78,14 @@
<tbody>
<% documents.each do |document| %>
<% date_or_year = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %>
<tr>
<td> <%= document.clean_reference_number %> </td>
<td> <%= document.short_title || document.title %> </td>
<td> <%= date_or_year %> </td>
<td> <%= document.doc_date.present? ? document.doc_date : document.year %> </td>
<td>
<a class="btn btn-success" data-controller="annotations" data-document-id="<%= document.id %>"
data-document-reference-number="<%= document.clean_reference_number %>"
data-document-date="<%= date_or_year %>"
data-document-date="<%= document.doc_date || document.year %>"
data-document-title="<%= document.short_title || document.title %>"
data-action="click->annotations#addAnnotatedDocument" >
Add

64
app/views/shared/_annotation_form.html.erb

@ -1,64 +0,0 @@
<div class="col-sm-12" data-controller="selectize">
<div class="card-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> New Annotation </h4> </div>
<div class="card-body">
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :annotation_marks %> </strong>
<%= hidden_field_tag :doctrine_id, doctrine_id %>
<%= hidden_field_tag :current_document_id, jurisprudence.id %>
<%= hidden_field_tag :document_id, document.id %>
<%= hidden_field_tag :document_ids, nil %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name),
class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :document_title %> </strong>
<%= text_area_tag :document_title, document.display_text, class: "form-control selected-citing-docs" %>
</div>
</div>
<div id="annotatedDocumentsSearchResults">
<div class="row">
<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: "annotations.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-success" data-action="click->annotations#searchDocuments"> Search </button>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :phil_rep %> </strong>
<%= text_field_tag :phil_rep, document.phil_rep, class: "form-control" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor's Note" %>
</div>
</div>
</div>
<div class="card-footer d-flex justify-content-end mt-2">
<button type="button" class="btn btn-success me-2" data-action="click->doctrines#saveAnnotation">Save</button>
<button type="button" class="btn btn-danger ms-2" href="<%= document_doctrine_path(jurisprudence.id, doctrine_id) %>">Back</button>
</div>
</div>

2
app/views/shared/_annotations_index_view.html.erb

@ -30,7 +30,7 @@
<% if annotation.editor_notes.present? %>
<div class="row">
<div class="col-sm-1 ms-5 p-0" style="width: 105px;">
<span> Editor's Note: </span>
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">

23
app/views/shared/_case_lists_no_results.html.erb

@ -1,23 +0,0 @@
<div class="row" data-controller="document" data-doctrine-id="<%= doctrine_id %>">
<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" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, nil, class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>

52
app/views/shared/_case_lists_search_results.html.erb

@ -1,14 +1,10 @@
<div class="row" data-controller="document" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= opts[:doctrine_id] %>">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title",
<div class="row" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>">
<div class="col-sm-11 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number",
data: { target: "document.input" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success btn-sm", data: { action: "click->document#search" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, opts[:citation_finder], class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
<div class="col-sm-1 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %>
</div>
</div>
@ -26,17 +22,14 @@
<% unless documents.first_page? %>
<span class="page-item first">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>"
data-citation-finder="<%= opts[:citation_finder] %>" data-page="<%= 1 %>"
data-action="click->document#paginate">
data-q="<%= opts[:q] %>" data-page="<%= 1 %>" data-action="click->document#paginate">
<i class="fas fa-angle-double-left"></i>
</a>
</span>
<span class="page-item prev">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>"
data-citation-finder="<%= opts[:citation_finder] %>" data-page="<%= opts[:current_page].to_i - 1 %>"
data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i - 1 %>"
data-action="click->document#paginate">
<i class="fas fa-angle-left"></i>
</a>
@ -50,9 +43,7 @@
<% else %>
<span class="page-item page">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>"
data-citation-finder="<%= opts[:citation_finder] %>" data-page="<%= page + 1 %>"
data-action="click->document#paginate">
data-q="<%= opts[:q] %>" data-page="<%= page + 1 %>" data-action="click->document#paginate">
<%= page + 1 %>
</a>
</span>
@ -62,17 +53,17 @@
<% unless documents.last_page? %>
<span class="page-item next">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->document#paginate">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i + 1 %>"
data-action="click->document#paginate">
<i class="fas fa-angle-right"></i>
</a>
</span>
<span class="page-item last">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= documents.total_pages %>" data-action="click->document#paginate">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= documents.total_pages %>"
data-action="click->document#paginate">
<i class="fas fa-angle-double-right"></i>
</a>
</span>
@ -95,14 +86,17 @@
<tbody>
<% documents.each do |document| %>
<tr>
<td style="width: 25%"> <%= document.clean_reference_number %> </td>
<td style="width: 45%"> <%= document.short_title || document.title %> </td>
<td style="width: 15%"> <%= document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %> </td>
<td> <%= document.clean_reference_number %> </td>
<td> <%= document.short_title || document.title %> </td>
<td> <%= document.doc_date.present? ? document.doc_date : document.year %> </td>
<td>
<% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% date_or_year = document.doc_date || document.year %>
<% title = document.short_title || document.title %>
<a class="btn btn-success btn-sm" href="<%= new_doctrine_annotation_path(opts[:doctrine_id], jurisprudence_id: opts[:jurisprudence_id], document_id: document.id) %>">
Add Annotation
<a class="btn btn-success" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="annotations"
data-doctrine-id="<%= opts[:doctrine_id] %>" data-document-id="<%= document.id %>" data-document-title="<%= title %>"
data-document-reference-number="<%= document.clean_reference_number %>" data-document-date-or-year="<%= date_or_year %>"
data-document-phil-rep="<%= document.phil_rep %>" data-action="click->annotations#renderForm">
Add Annotations
</a>
</td>
</tr>

71
app/views/shared/_doctrine_form_annotation_modal_form.html.erb

@ -1,71 +0,0 @@
<div class="modal fade modal-doctrine-body" id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" data-controller="doctrines">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"> New Annotation </h5>
<button type="button" class="btn-close-x" data-bs-dismiss="modal" aria-label="Close">x</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :annotation_marks %> </strong>
<%= hidden_field_tag :annotaitons_attributes_index, nil %>
<%= hidden_field_tag :document_id, nil %>
<%= hidden_field_tag :document_ids, nil %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all.order(name: :asc), :id, :name),
class: "form-control default-selectize ps-0", multiple: true, prompt: "Please select" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :document_title %> </strong>
<%= rich_text_area_tag :document_title, nil, placeholder: "Document Title" %>
</div>
</div>
<div id="citingDocumentsSearchResults">
<div class="row">
<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: "doctrines.q" } %>
</div>
<div class="col-sm-1 p-2">
<button type="button" class="btn btn-success" data-action="click->doctrines#searchCitingDocuments"> Search </button>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :phil_rep %> </strong>
<%= text_field_tag :phil_rep, nil, class: "form-control" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor's Note" %>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-success" data-action="click->doctrines#saveAnnotation"> Save </button>
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>

38
app/views/shared/_doctrine_form_annotations_view.html.erb

@ -1,38 +0,0 @@
<% annotations.each_with_index do |annotation, index| %>
<div class="row mb-2 pb-0 ms-3">
<div class="col-sm-1 p-0 me-1" style="width: auto;">
<% if annotation[:annomark_ids].present? %>
<% annomarks = Annomark.where(id: annotation[:annomark_ids]) %>
<strong> <%= "#{annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<% end %>
</div>
<div class="col-sm-9 p-0 ms-1">
<% contents = annotation[:content].gsub("<div>", "").gsub("</div>", "").split(" citing ") %>
<% phil_rep = annotation[:phil_rep] %>
<% contents[0] = [contents[0], phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")].join(" ") %>
<%= raw contents.length > 1 ? contents.join(" citing ") : contents[0] %>
</div>
<div class="col-sm-2 d-flex justify-content-end align-items-baseline">
<a class="btn btn-sm btn-secondary me-3" data-bs-toggle="modal" data-bs-target="#annotationModal"
data-controller="doctrines" data-annotations-attributes-index="<%= index %>"
data-action="click->doctrines#editAnnotation"> Edit </a>
<a class="btn btn-sm btn-danger" data-controller="doctrines" data-annotations-attributes-index="<%= index %>"
data-action="click->doctrines#removeAnnotation" > Delete </a>
</div>
</div>
<% if annotation[:editor_notes].present? %>
<div class="row mb-2">
<div class="col-sm-1 ms-5 p-0" style="width: 105px;">
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation[:editor_notes] %>
</div>
</div>
<hr/>
<% end %>
<% end %>

108
app/views/shared/_doctrine_form_case_lists.html.erb

@ -1,108 +0,0 @@
<div class="row" data-controller="document">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title",
data: { target: "document.input" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success btn-sm", data: { action: "click->document#searchDoctrineFormCaseLists" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, opts[:citation_finder], class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
</div>
</div>
<header class="header bg-white b-b clearfix">
<div class="row m-t-sm align-items-end pagination-body">
<div class="<%= documents.present? ? "col-md-6 mb-0 " : "col-md-12 mb-0"%> ">
<h4 style="color: darkred" class="m-0">Search Results</h4>
<small style="color: darkred">
<%= page_entries_info documents, entry_name: 'records' if documents.present? %>
</small>
</div>
<div class="<%= documents.present? ? "col-md-6 position-relative" : "d-none"%>">
<div class="text-center pagination justify-content-end me-3">
<nav class="pagination pagination-sm" role="navigation" aria-label="pager">
<% unless documents.first_page? %>
<span class="page-item first">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= 1 %>"
data-citation-finder="<%= opts[:citation_finder] %>"
data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-double-left"></i>
</a>
</span>
<span class="page-item prev">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= opts[:current_page].to_i - 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-left"></i>
</a>
</span>
<% end %>
<% documents.total_pages.times do |page| -%>
<% if (page + 1) <= (opts[:current_page].to_i + 4) && (page + 1) >= (opts[:current_page].to_i - 4) %>
<% if opts[:current_page].to_i.eql?(page + 1) %>
<span class="page-item page current page-link"> <%= page + 1 %> </span>
<% else %>
<span class="page-item page">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= page + 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<%= page + 1 %>
</a>
</span>
<% end %>
<% end %>
<% end -%>
<% unless documents.last_page? %>
<span class="page-item next">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-right"></i>
</a>
</span>
<span class="page-item last">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-page="<%= documents.total_pages %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-double-right"></i>
</a>
</span>
<% end %>
</nav>
</div>
</div>
</div>
</header>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
<tbody>
<% documents.each do |document| %>
<tr>
<td style="width: 25%"> <%= document.clean_reference_number %> </td>
<td style="width: 45%"> <%= document.short_title || document.title %> </td>
<td style="width: 15%"> <%= document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %> </td>
<td>
<% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% title = document.short_title || document.title %>
<a class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="doctrines"
data-document-id="<%= document.id %>" data-document-title="<%= title %>" data-document-reference-number="<%= document.clean_reference_number %>"
data-document-date-or-year="<%= date_or_year %>" data-document-phil-rep="<%= document.phil_rep %>"
data-action="click->doctrines#newAnnotation">
Add Annotation
</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

101
app/views/shared/_doctrine_form_citing_documents_search_results.html.erb

@ -1,101 +0,0 @@
<div class="row" data-controller="doctrines">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "doctrines.q" } %>
</div>
<div class="col-sm-1 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->doctrines#searchCitingDocuments" } %>
</div>
</div>
<% if documents.present? %>
<header class="header bg-white b-b clearfix">
<div class="row m-t-sm align-items-end pagination-body">
<div class="<%= documents.present? ? "col-md-6 mb-0 " : "col-md-12 mb-0"%> ">
<h4 style="color: darkred" class="m-0">Search Results</h4>
<small style="color: darkred">
<%= page_entries_info documents, entry_name: 'records' if documents.present? %>
</small>
</div>
<div class="<%= documents.present? ? "col-md-6 position-relative" : "d-none"%>">
<div class="text-center pagination justify-content-end me-3">
<nav class="pagination pagination-sm" role="navigation" aria-label="pager">
<% unless documents.first_page? %>
<span class="page-item first">
<a class="page-link" data-controller="doctrines" data-q="<%= opts[:q] %>" data-page="<%= 1 %>" data-action="click->doctrines#paginateCitingDocuments">
<i class="fas fa-angle-double-left"></i>
</a>
</span>
<span class="page-item prev">
<a class="page-link" data-controller="doctrines" data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i - 1 %>" data-action="click->doctrines#paginateCitingDocuments">
<i class="fas fa-angle-left"></i>
</a>
</span>
<% end %>
<% documents.total_pages.times do |page| -%>
<% if (page + 1) <= (opts[:current_page].to_i + 4) && (page + 1) >= (opts[:current_page].to_i - 4) %>
<% if opts[:current_page].to_i.eql?(page + 1) %>
<span class="page-item page current page-link"> <%= page + 1 %> </span>
<% else %>
<span class="page-item page <%= 'current' if opts[:current_page].to_i.eql?(page + 1) %>">
<a class="page-link <%= 'current' if opts[:current_page].to_i.eql?(page + 1) %>"
data-controller="doctrines" data-q="<%= opts[:q] %>" data-page="<%= page + 1 %>"
data-action="click->doctrines#paginateCitingDocuments"> <%= page + 1 %> </a>
</span>
<% end %>
<% end %>
<% end -%>
<% unless documents.last_page? %>
<span class="page-item next">
<a class="page-link" data-controller="doctrines" data-q="<%= opts[:q] %>"
data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->doctrines#paginateCitingDocuments">
<i class="fas fa-angle-right"></i>
</a>
</span>
<span class="page-item last">
<a class="page-link" data-controller="doctrines" data-q="<%= opts[:q] %>"
data-page="<%= documents.total_pages %>" data-action="click->doctrines#paginateCitingDocuments">
<i class="fas fa-angle-double-right"></i>
</a>
</span>
<% end %>
</nav>
</div>
</div>
</div>
</header>
<% end %>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
<tbody>
<% documents.each do |document| %>
<% date_or_year = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year %>
<tr>
<td> <%= document.clean_reference_number %> </td>
<td> <%= document.short_title || document.title %> </td>
<td> <%= date_or_year %> </td>
<td>
<a class="btn btn-success" data-controller="doctrines" data-document-id="<%= document.id %>"
data-document-reference-number="<%= document.clean_reference_number %>"
data-document-date="<%= date_or_year %>"
data-document-title="<%= document.short_title || document.title %>"
data-action="click->doctrines#addCitingDocument" >
Add
</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>

23
app/views/shared/_doctrine_form_default_case_lists.html.erb

@ -1,23 +0,0 @@
<div class="row" data-controller="document">
<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" } %>
</div>
<div class="col-sm-2 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#searchDoctrineFormCaseLists" } %>
<button class="btn btn-warning btn-sm text-white ms-3" data-bs-toggle="collapse" href="#citation_finder_collapse" role="button" aria-expanded="false" aria-controls="collapseExample" > Citation finder</button>
</div>
<div class="collapse col-sm-10 p-2" id="citation_finder_collapse">
<%= text_field_tag :citation_finder, nil, class: "form-control", placeholder: "Citation Finder", data: { target: "document.citation_finder" } %>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0" style="width: 98%; margin: 0 auto;">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> </th>
</thead>
</table>
</div>

59
app/views/shared/_doctrines_pagination.html.erb

@ -1,59 +0,0 @@
<header class="header bg-white b-b clearfix m-2">
<div class="row m-t-sm align-items-end pagination-body">
<div class="<%= doctrines.present? ? "col-md-6 mb-0 " : "col-md-12 mb-0"%> ">
<small style="color: darkred">
<%= page_entries_info doctrines, entry_name: 'records' if doctrines.present? %>
</small>
</div>
<div class="<%= doctrines.present? ? "col-md-6 position-relative" : "d-none"%>">
<div class="text-center pagination justify-content-end me-3">
<nav class="pagination pagination-sm" role="navigation" aria-label="pager">
<% unless doctrines.first_page? %>
<span class="page-item first">
<a class="page-link" data-controller="doctrines" data-document-id="<%= opts[:document_id] %>"
data-page="<%= 1 %>" data-action="click->doctrines#paginate">
<i class="fas fa-angle-double-left"></i>
</a>
</span>
<span class="page-item prev">
<a class="page-link" data-controller="doctrines" data-document-id="<%= opts[:document_id] %>"
data-page="<%= opts[:current_page].to_i - 1 %>" data-action="click->doctrines#paginate">
<i class="fas fa-angle-left"></i>
</a>
</span>
<% end %>
<% doctrines.total_pages.times do |page| -%>
<% if (page + 1) <= (opts[:current_page].to_i + 4) && (page + 1) >= (opts[:current_page].to_i - 4) %>
<% if opts[:current_page].to_i.eql?(page + 1) %>
<span class="page-item page current page-link"> <%= page + 1 %> </span>
<% else %>
<span class="page-item page">
<a class="page-link" data-controller="doctrines" data-document-id="<%= opts[:document_id] %>"
data-page="<%= page + 1 %>" data-action="click->doctrines#paginate"> <%= page + 1 %> </a>
</span>
<% end %>
<% end %>
<% end -%>
<% unless doctrines.last_page? %>
<span class="page-item next">
<a class="page-link" data-controller="doctrines" data-document-id="<%= opts[:document_id] %>"
data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->doctrines#paginate">
<i class="fas fa-angle-right"></i>
</a>
</span>
<span class="page-item last">
<a class="page-link" data-controller="doctrines" data-document-id="<%= opts[:document_id] %>"
data-page="<%= doctrines.total_pages %>" data-action="click->doctrines#paginate">
<i class="fas fa-angle-double-right"></i>
</a>
</span>
<% end %>
</nav>
</div>
</div>
</div>
</header>

4
app/views/shared/_document_doctrines_index.html.erb

@ -1,4 +0,0 @@
<div class="container-sm row-flex col-sm-12 p-0 doct-body-index" id="documentDoctrinesIndex">
<%= render(partial: "/shared/doctrines_pagination", locals: { doctrines: doctrines, opts: opts }) %>
<%= render(DocumentDoctrineIndexComponent.with_collection(doctrines, current_user: current_user, opts: { document_id: opts[:document_id] })) %>
</div>

6
app/views/subject_indexes/index.html.erb

@ -11,13 +11,11 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsAccordion">
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %>
<% end %>
</div>

12
app/views/subject_indexes/show.html.erb

@ -36,9 +36,9 @@
<div class="card-body">
<div>
<div class="" style="border-bottom: 1px solid #b2b2b2;">
<div class="d-flex">
<div > <h5 class="mb-0"> Sub Levels </h5> </div>
<div class="sub-icon-add"> <a class="p-1 btn-sm ps-3 pe-3 mb-1" href="<%= new_subject_index_path(parent_id: @subject_index) %>"><i class="fas fa-plus-circle"></i></a> </div>
<div class="row">
<div class="col-sm-11"> <h5 class="mb-0"> Sub Levels </h5> </div>
<div class="col-sm-1 d-flex justify-content-end align-items-end"> <a class="btn btn-success p-1 btn-sm ps-3 pe-3 mb-1" href="<%= new_subject_index_path(parent_id: @subject_index) %>"> Add </a> </div>
</div>
</div>
<div class="card-body subject-body-index" style="position: relative;">
@ -51,13 +51,11 @@
data-controller="subjects" data-subject-parent-id="<%= root.id %>"
data-accordion-target="#<%= ['subjectsAccordionBody', root.id].join %>"
data-action="click->subjects#loadSubjectsAccordion">
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 me-5" %>
</div>
<% else %>
<%= link_to root.name, "#", class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link",
data: { controller: "application", href: subject_index_path(root.id), action: "click->application#openLink" } %>
<%= link_to root.name, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= link_to '<i class="fas fa-folder-plus"></i>'.html_safe, new_subject_index_path(parent_id: root.id), class: "text-decoration-none d-block sub1 clickable-link position-absolute end-0 accordion-action-button-margin non-toggle" %>
<% end %>
</div>

23
config/application.rb

@ -18,28 +18,5 @@ module CdaoPjet
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
# Mailer
if Rails.env.production?
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_options = {
from: ENV["MAILER_FROM"],
reply_to: ENV["REPLY_TO"],
subject: ENV["MAILER_SUBJECT"],
}
config.action_mailer.smtp_settings = {
address: ENV["MAILER_ADDRESS"],
port: ENV["MAILER_PORT"],
domain: ENV["MAILER_DOMAIN"],
user_name: ENV["MAILER_USERNAME"],
password: ENV["MAILER_PASSWORD"],
authentication: :plain,
enable_starttls_auto: "true",
}
config.action_mailer.default_url_options = {
host: ENV["MAILER_URL_HOST"] || ENV["URL_HOST"],
only_path: !(Figaro.env.mailer_url_host? || Figaro.env.url_host?),
}
end
end
end

14
config/application.yml

@ -12,17 +12,3 @@ SENTRY_JS_ENABLED: "<%= Rails.application.credentials.SENTRY_JS_ENABLED || true
RECAPTCHA_ENABLED: '<%= Rails.application.credentials.RECAPTCHA_ENABLED %>'
RAILS_SERVE_STATIC_FILES: '<%= Rails.application.credentials.RAILS_SERVE_STATIC_FILES || true %>'
HEALTHCHECK_AUTH: '<%= Rails.application.credentials.HEALTHCHECK_AUTH || true %>'
HEALTHCHECK_SSL: '<%= Rails.application.credentials.HEALTHCHECK_SSL || false %>'
MAILER_ADDRESS: '<%= Rails.application.credentials.MAILER_ADDRESS %>'
MAILER_PORT: '<%= Rails.application.credentials.MAILER_PORT %>'
MAILER_DOMAIN: '<%= Rails.application.credentials.MAILER_DOMAIN %>'
MAILER_USERNAME: '<%= Rails.application.credentials.MAILER_USERNAME %>'
MAILER_PASSWORD: '<%= Rails.application.credentials.MAILER_PASSWORD %>'
MAILER_AUTHENTICATION: '<%= Rails.application.credentials.MAILER_AUTHENTICATION %>'
MAILER_ENABLE_STARTTLS_AUTO: '<%= Rails.application.credentials.MAILER_ENABLE_STARTTLS_AUTO %>'
MAILER_URL_HOST: '<%= Rails.application.credentials.MAILER_URL_HOST %>'
URL_HOST: '<%= Rails.application.credentials.URL_HOST %>'

2
config/credentials/development.yml.enc

@ -1 +1 @@
rSe24G2PIIIJBVHvF3YOt9xPwScHs9eXI/+ZuulsNx/ggA8bI6x3evvHXPMcZ67eQuRCeJiphsn2bgmlNdKibFMPb/7V0QNb7EIjxRzNJ7UHGCJShq9XNMe0HdztasfevI16gwdXqXs1L8WmmgctqW6EvaZkp9P5yRg31/5zRPDe5j8yj+FQe0YXK/uwjUgwZD4uBj+Fnn0xMLBmMaZjpnkwpi5rLlhTkMRD+Qzh+9CQO1BPFrPYGniX49ms6Pb1Z/aOsxzmaiPfLCdy9dTSDmGzpKecURzfWVH15IKKdMXrRA1izbPFF6n7fP15lrzktZZjnPWC3XiazgtRwhAeu/UPhi5h6saRkBLjKOLOvBn/bHohyVsSDDmUWDYlP/ldnVUiDnbVKH7dn6XFRauCJni3415ThekM/9lUe/DyfG6dsFE1xiJRqM8JcFiG0ZICp3rJ3jxti+m/5RNzHkj7Lt9mpDJaFmTZARDNLj6ffvMcr5LSS7Uhg9OiVcdhRXidxID4aXyKObeEMqcz1MQAB1Evf7m3Z89QIYNG1uUEhqJSYpPiaS5UBNTnk//K0uwXgXfQfjC8RuyD5XmMIqrBt21L6OizG6ZRYdglJcO1n5nYG0uGIToJpRANMI9y3yY5BCKtGiz2hxckLlyBDaRI5WR5ZvdQJ2B5PWlw73I5kW/wSUwj/axkBCMnj6A/CbsS/CbCOyn1F1y04HS7yVelvh0SSNmtL39jo7N3U9ZTwdMTfIjsZ+JUwXS7zfT4uoQeqO4G6QFhwrhPVe23sKtgSQrJzRToMEFrKpkd/C6bBOD6uPl54xaL5UrTbARQ6K65GqeIQplRZWjexFTc4HhJ956v3ifvRBmS1IlthtAhaw9ccOYYX7+PODna8wAoW1EzeMr5kg==--gHSpJ3qaiDI5tRLX--UaqBiXtW4JcCM+Sti4rIRA==
k26YtTX/JTSRwZz4u5qF6/i2U7Sts2QZp62c9HNja9jaCA9H+ES/PkvCguJ/aavieJqpKNdQ8C/eiBZPTHfkQrPNCbv6ztALK9tg8VBifCwo5OAutAr/tYQ7HiykQWkU0syXWehafxx5e8IJ12WpP130V9J5XvxCA58pijVjU+810ATvBgTwTl+cfjs1GpovQFeLhEXNaKzaxRcfuRNOPLq4WJ0TQ5bAeZuSo40Sx8FL3Tx/j7TPMGD47YjePIyi4I9XEzxELTkBdoRv2nfWpZ1Ade0nLtaX7U96KpKR46LkGyIwaNDqIykT8h36sMUJUrmJSzCY9iTlIT+wXt1PVDGuun1sK5NuA3dFZ66xm1n/GR0WXS7O0Nj8zmPBud6kZpA21iYSJDV2EslSm+09vth1kG3CvzXoP3nQnmq2EYpR2KykrxRNZciL9qkDWcYtMM3MgQgH5Md/2eo+afIGgMnTHpbLWZKW+KlQ5n9HEtCDTMwHIu/hrRa0IRFJFuPP0WrZqmZyAYoDLFrC2ct61wLXNjw0ty6kC9/VbKDruPuEZQZKxcLwM7q8j61b/67f3PCCdc3LQ62c0Cj6ee7vgGKqzV0Bv/Tgz1o3J8Tg7O952Z44wWQ2eyZHzmz7wG5+xk3yYf5p1c9PHa5G3+6XfQP9Q1eMQPfTEQsb6GQeG7G2t0OJs9rYEwhI9PtfIF3EUAmORsfBznbXNWsuchG2zOViDsq3iEBmW+3foewpWQZ11gnz+DV9BTyrbpBsZk8LEMgiRho2YKK0F8zREaJ96VubX0rxDRdI5YPFP0mcXiBs83CoKW8CgHhb--ObRYoWt2iH3wY4Yl--wJJvsuj3UudObCM5DwFbQw==

2
config/credentials/production.yml.enc

@ -1 +1 @@
zImnRtI3YnVwgwiE5muJfsatJ9O3/H4KCNEdgGxGdZX89La8jz739m82wgCyAhcENEZsfeD6k8wEYLZNvj5cHZv2p0u1F5ja3XV719t9/m+LOSGIa5eqgDQYVpnb5GqvbrIZoKjRdODjex7NTzderUU1g5fzAMsfFZ8HpCLKNlUI/3pTxzTY+FOZkDRvFDDCi+50YmgxTylByqVosos4seUL1D84kLUoifdsT8nDC+GJt38OvtVOSgowt2dYdCUbMoB7xhNpE3uxL7NgQL3x97Wfu/6LyzVYPRfTykYzXFJvxpyyKr7zys9aqaJMO04gdtN0vG/Yam7BnwV16RW53Lst78nn71sYSrI3zb3RnyBltw2Ydhs+C7bNsnnGJTdQGUeMGERellHo0OwaJ/taW3AnniKrqodiLZW76vH3shoowq8EgaxwxbH9Z+M47D0ICkzx8UkCvSFc+Rv9xE4eoeX9/5OQ/r6yo2WN0Yz2OLLiHqHOaIMh+5ycZlTghQetmE89g/kSyQ/Niu6i49LYE4jvSORbK31c7cbco/ZBnk7fmIkSNAlYjpvNkstQHtRqkSqA+QEyywKpca9dsEhiwRZeCkgCaaODiKJst97e/+oprxrDbJ+R/XYvHlFmkNTg2ENb30OwALa9KAxdUl1cEgaP/49OhETNel6zYpZgXBobhdVfAfax8FnPXgEmIC8oUNJXzEKObInUdHexmoVWUpphcrGlN1X/UI4t55jy4Fg/eSrEZAMpAYPCljuNbMLVUh9MperpxnENJS04eWoKAHdZZTB+K+4SA+L/gAoC/rshYL/YGueWqWvzXkGZzRCaZocDspyP5e0zzc6dTGSNhUg8xtYy3TsmmKVckP4ALM04yNTlh7f/Isp7YS0kLmUqmrCC+1eKm0ZmUcU64H35fLj/WTcK0bW2rhBf96XwNLs3drIOoYELhT28+/k4s+Ifz0ABhHsl2QGUUxntSapKSsgDfQmhCwZb1rt8qnqn35vrIHsHLlRf8KwPoc4iDK76IVr/0EYGG6qEZ5sbzjCqRKxdK4fgrVZqSqjdOvALc8DF0PvQRR5mb/zJgo2pYFVDH2sPKyDStyT0704j0EF7ckrx5GqIs0jQNTYVhyI9FMcggfQA+/jixNqVAdYylFB3ILRjU6WI/wmVJFeiDMXyK0pzVZ0ojxpbnMu65hz52gyE0UBnfausQJxiHCKMDRBeFoYjIVcnbBh+/Dz7MLsrTTODFBJRk19GROiODD7iFZR21aXCdgyhMyRHPAkTeFu5w1VYQg4w0aU0xyAwsn6w/bpeU1/gzHia8PihiORQxLKltcr/AfOmX245n47mXcyRNuzLaYaYnA9AGdJOA/bb354XiLzNoHROzXL/Pz9ve4FouE5V3DnGVJZLDJWt6vva5VTMFE0D5cipOwT6mWcHWBFROPLqnxeQOlUog0DoEViX9tgxNWFFH8QwfVn14ygPjaBpSr4AoFx0hMD/OAX+8lHsBXszI5k/ptJeW9YI9IOGDmBLoLXvQxMhvfOCb5OpjV21Qxu1iAawuhnRwseW6YHQv5+LC++4HCULnlhW+Jl6418+PbXAPLF8gxS0KdvitdKQ75hEQy80vXKzHiRKEoU9FPVuqdhJgC43gtpfMRXCaszUOC40XSxO7J8Z0fT1HkWyXgRmVwdwFC6MdNa4rtvL09fHY5glcDlqZVaILPXeXx7XVtXl8Vc8q3LLWGhvZbIktT7bGY/RuWPzUfKmDpN6qLE49JzwcG1+c25O8ZFmeUhE/RaqFVpn0ApUb5/dZZ5bjTyz--tFy5q4uSQTgBSzh2--zlOPC4U+D5yNvNoFj/m7iQ==
RHVE24irVZERt12NIvtMlOeD5gI2i1lkMewJJxBlAgGsXD8Ms55jNTcqKV0jUHk30xxq1wiDIfEfeCK//XwzSQtdhPkHUETFRMtKlmw0rqVTws9wVklbrmime5iDvuOf38vInbZVAcFU21s+zUf+Du42KMIGlVb3/dlIS2u2e1xw5KNJQOCIfKoe++H9bPOtFerhhDYUmRYJe+tMOQLyTUu0K+2ffg+a49ff35FKJqTpCPL5Vu3uD38pGtDhKhxCiUPwKFqpHP3i7gEi34QpzkaD3Vktu9pRtbiPxeqM8snxWBQsxgsRsdKJwOuEUoj2qw5oxHKhYI/jVaitBRvwYPZTtbrvSEym9D9roaI+DR8SHE39MAh1xU73sRTgrDz2o5FWPJoijdczI63j+AOza3ZbqfuDEagjqGdCDbXCfr3gi8d9GcM60gGBDkWhr1h0CxWV6jzLcU7yA8dTuSL8nFdd17zsN5C9ZgxxvUZ3ilnbOYPwdcZP0/9ekprq2cIQ58CaLsu69sixd2UnUwtyC4zx90FGhiA3kVFyJeahTbUOKL14RK6BhaMUuz15tz98HtCO+Is9uraWryPNVX2l6m/Q3wQfrOWai/8v8HKevqdmzMJvivAy5fPtsR2kJkvECPK0Io1a5IHv434gw5f7PcGzlGOEk3XArA7XxeyNmLK7wzGW74Topvi+Zqtk25JqE7Z4Nkkv4y4o4ctkvBRj2ExzZg21wQD9giLaANcb8Hj+sk0HNOgRbZ13aOepHiJX2lMGsS7x2PBpk56B3qMogxrEbdNgQdxXXBtW1HNeyc+z9kZRgsHyRxDDG+9glj9FdUmDBobbdxigvLaWAFIBCDIlKIH3Rtv/MAz/0lnE9PSPqn13QfC8KMyI3RzpNcR6NrKxZiLWMEy6Oex220hQOFfbepHLNkLIUm9IKqysdYwa32anKvyg34YQ6vE7XEEui1L4aKWNq2Vb7CSF1JreJSB21zW8FC5uSh3QD/AKPWAyF7reVIBIjW7VsApEL6R8s2ou0RBkIMyhtXyDDUOzez6GEu4caUeSNOCjp4vsSZwXEzBSOz0rzCVyJPMBGiIsaMGDZ02vbBwSVDVV/rhzCuVpBKEiMcjzDFc9QHwhD7gCy1mtvP6gQmWLUiDP9Y+8A6okKcxB6gDAKHzdJXGAJGYnktqGdHMYpQ0feE0N+umG7wyEaBW0YJAIQYR6KR8OSMy+6Rg43iQRXXiOgBcU0uIQa7JyVQdysQX4fhW1UZII4Syu65tfi75NETpqWbDxnp6xvw7LpQ==--a6ISTZpt8qbI/E2O--VsALKCGxTmuK5s0bBfOhog==

1
config/deploy/production.rb

@ -62,4 +62,3 @@ server "003-app.cdasiaonline.com", user: "deploy", roles: %w[web app db worker]
set :rails_env, "production"
set :docker_compose_file, -> { "docker-compose.production.yml" }
set :docker_compose_up_services, "--force-recreate --scale web=3 --scale worker_solr=3 --scale worker=1 --scale load_balancer=1"

1
config/deploy/staging.rb

@ -62,4 +62,3 @@ server "003-app.cdasiaonline.com", user: "deploy", roles: %w[web app db worker]
set :rails_env, "production"
set :docker_compose_file, -> { "docker-compose.production.yml" }
set :docker_compose_up_services, "--force-recreate --scale web=3 --scale worker_solr=3 --scale worker=1 --scale load_balancer=1"

14
config/initializers/okcomputer.rb

@ -1,14 +0,0 @@
OkComputer.mount_at = "health"
OkComputer.require_authentication(*ENV["HEALTHCHECK_AUTH"].to_s.split(":")) if ENV["HEALTHCHECK_AUTH"].present?
OkComputer::OkComputerController.class_eval do
force_ssl except: :index if ENV["HEALTHCHECK_SSL"] == true
end
OkComputer::Registry.register "solr", OkComputer::SolrCheck.new(ENV["SOLR_URL"])
OkComputer::Registry.register "redis", OkComputer::RedisCheck.new(url: ENV["REDIS_URL"])
if ActionMailer::Base.smtp_settings[:address].present?
OkComputer::Registry.register "mailer", OkComputer::ActionMailerCheck.new(ActionMailer::Base)
OkComputer.make_optional %w(mailer)
end

13
config/routes.rb

@ -1,12 +1,12 @@
Rails.application.routes.draw do
devise_for :users
root to: "documents#index"
root to: "home#index"
resources :doctrines, only: %i[index show new edit] do
resources :doctrines, only: %i[index show] do
get :search, on: :collection
scope module: :doctrine do
resources :annotations, only: %i[new edit create update destroy]
resources :annotations, only: %i[create update destroy]
end
end
@ -27,13 +27,8 @@ Rails.application.routes.draw do
resources :reports, only: %i[index]
namespace :api, defaults: { format: :html } do
resources :doctrines, only: %i[new edit]
end
namespace :api, defaults: { format: :json } do
resources :doctrines do
get :suggested_contents, on: :collection
scope module: :doctrine do
resources :annotations do
get :search, on: :collection
@ -56,8 +51,6 @@ Rails.application.routes.draw do
end
end
authenticate :user do
require "sidekiq/web"
mount Sidekiq::Web => "/sidekiq"
end
end

11
data/csvs/labor_new.csv

@ -1,11 +0,0 @@
"Termination of Employment","Dismissal from employment has two facets: first, the legality of the act of dismissal, which constitutes substantive due process; and second, the legality of the manner of dismissal, which constitutes procedural due process. The burden of proof rests upon the employer to show that the disciplinary action was made for lawful cause or that the termination of employment was valid. In administrative and quasi-judicial proceedings, the quantum of evidence required is substantial evidence or ""such relevant evidence as a reasonable mind might accept as adequate to support a conclusion."" Thus, unsubstantiated suspicions, accusations, and conclusions of the employer do not provide legal justification for dismissing the employee.","Cited","Maula v. Ximex Delivery Express, Inc., G.R. No. 207838, January 25, 2017, 804 Phil. 365, 378 citing NDC Tagum Foundation, Inc. v. Sumakote, G.R. No. 190644, June 13, 2016, 787 Phil. 67",,"https://wpd.cdasiaonline.com/jurisprudences/62487?s_params=hHdxqiEsRdBofyXmpFVw citing https://wpd.cdasiaonline.com/jurisprudences/61610?s_params=TiTLuZdyRLyDFB9CSPtz","Mariano v. G.V. Florida Transport","G.R. No. 240882 September 16, 2020","https://wpd.cdasiaonline.com/jurisprudences/70282?s_params=4beJ1VNtoSdW1VdNygC9"
"Termination of Employment","In cases where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the rule is that the burden of economic loss is not rightfully shifted to the employer; each party must bear his own loss.","Cited","Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128",,"https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=68o_JQF14-gaz_rzKskz","Toledo v. New Mega Concrete Product Construction Supplies","G.R. No. 235806 February 19, 2020","https://wpd.cdasiaonline.com/jurisprudences/69209?s_params=4A_BqAv9Gk_8sbxAR5wq"
"Termination of Employment","Moreover, the Court has held that where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the burden of economic loss is not rightfully shifted to the employer. Each party must bear his own loss.","Cited","Exodus International Construction Corp. v. Biscocho, G.R. No. 166109, February 23, 2011, 659 Phil. 142, 159, citing Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128",,"https://wpd.cdasiaonline.com/jurisprudences/54258?s_params=c3g1chnyo9MhSVrzt4KH citing https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=TyaSDxtZwX7H3YBNH2j1","Rodriguez v. Sintron Systems, Inc.","G.R. No. 240254 July 24, 2019","https://wpd.cdasiaonline.com/jurisprudences/67637?s_params=cs5QsxXP7GYobXPunpvm"
"Termination of Employment","In Dee Jay's Inn and Café v. Raneses, the Court ruled that ""[i]n a case where the employee was neither found to have been dismissed nor to have abandoned his/her work, the general course of action is for the Court to dismiss the complaint, direct the employee to return to work, and order the employer to accept the employee.""","Illustrative ","Dee Jay's Inn and Café v. Raneses, G.R. No. 191823, October 5, 2016",,"https://wpd.cdasiaonline.com/jurisprudences/62157?s_params=XsJpujp58cZdKeue851X","Symex Security Services, Inc. v. Rivera, Jr.","G.R. No. 202613 November 08, 2017","https://wpd.cdasiaonline.com/jurisprudences/63601?s_params=XAmPQttsCXshK-uax2Jy"
"Termination of Employment","Damages are recoverable in cases where the plaintiff suffers loss due to a breach of duty committed by the defendant. The plaintiff must prove two (2) things: first, that he or she suffered a loss; and second, that the defendant caused the loss by breaching a legal duty he or she owed to the plaintiff. Absent one (1) of these elements, the plaintiff is not considered to have been injured in contemplation of the law.",,,,,"De Peralta v. Philippine Commercial International Bank","G.R. No. 184440 July 03, 2017","https://wpd.cdasiaonline.com/jurisprudences/63050?s_params=p6gkWWzaxmGyXYZjRTdK"
"Termination of Employment","In the exercise of the right to terminate a contract without cause, one party need only to give the other prior written notice as provided in the contract.","Cited","Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389",,"https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other.","Cited","Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389",,"https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other.","Cited","Petrophil Corporation v. Court of Appeals, G.R. No. 122796, December 10, 2001, 423 Phil. 182",,"https://wpd.cdasiaonline.com/jurisprudences/2895?s_params=YFwWazSacL5UfvhXg66r","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that ""[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee."" This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed.","Illustrative ","Gutierrez v. Singer Sewing Machine Co., G.R. No. 140982, September 23, 2003, 458 Phil. 401, 413",,"https://wpd.cdasiaonline.com/jurisprudences/7830?s_params=WG68QECZuNxgkGr4MtY1","Cavite Apparel, Inc. v. Marquez","G.R. No. 172044 February 06, 2013","https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA"
"Termination of Employment","In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that ""[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee."" This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed.","Illustrative ","Caltex Refinery Employees Association v. National Labor Relations Commission, G.R. No. 102993, July 14, 1995, 316 Phil. 335, 343-344",,"https://wpd.cdasiaonline.com/jurisprudences/15276?s_params=dGs8Vpnrdwac6phzMDCx","Cavite Apparel, Inc. v. Marquez","G.R. No. 172044 February 06, 2013","https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA"
"Termination of Employment","Withholding of payment by the employer does not mean that the employer may renege on its obligation to pay employees their wages, termination payments, and due benefits. The employees' benefits are also not being reduced. It is only subjected to the condition that the employees return properties properly belonging to the employer. This is only consistent with the equitable principle that ""no one shall be unjustly enriched or benefited at the expense of another.""",,"Civil Code, Art. 2142",,"https://wpd.cdasiaonline.com/laws/2602?s_params=K4rmHmXNgmyPAUvZsyar","Milan v. National Labor Relations Commission","G.R. No. 202961 February 04, 2015","https://wpd.cdasiaonline.com/jurisprudences/59484?s_params=UnRs4_ZqJ-ykTVyzWbxj"
1 Termination of Employment Dismissal from employment has two facets: first, the legality of the act of dismissal, which constitutes substantive due process; and second, the legality of the manner of dismissal, which constitutes procedural due process. The burden of proof rests upon the employer to show that the disciplinary action was made for lawful cause or that the termination of employment was valid. In administrative and quasi-judicial proceedings, the quantum of evidence required is substantial evidence or "such relevant evidence as a reasonable mind might accept as adequate to support a conclusion." Thus, unsubstantiated suspicions, accusations, and conclusions of the employer do not provide legal justification for dismissing the employee. Cited Maula v. Ximex Delivery Express, Inc., G.R. No. 207838, January 25, 2017, 804 Phil. 365, 378 citing NDC Tagum Foundation, Inc. v. Sumakote, G.R. No. 190644, June 13, 2016, 787 Phil. 67 https://wpd.cdasiaonline.com/jurisprudences/62487?s_params=hHdxqiEsRdBofyXmpFVw citing https://wpd.cdasiaonline.com/jurisprudences/61610?s_params=TiTLuZdyRLyDFB9CSPtz Mariano v. G.V. Florida Transport G.R. No. 240882 September 16, 2020 https://wpd.cdasiaonline.com/jurisprudences/70282?s_params=4beJ1VNtoSdW1VdNygC9
2 Termination of Employment In cases where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the rule is that the burden of economic loss is not rightfully shifted to the employer; each party must bear his own loss. Cited Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128 https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=68o_JQF14-gaz_rzKskz Toledo v. New Mega Concrete Product Construction Supplies G.R. No. 235806 February 19, 2020 https://wpd.cdasiaonline.com/jurisprudences/69209?s_params=4A_BqAv9Gk_8sbxAR5wq
3 Termination of Employment Moreover, the Court has held that where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the burden of economic loss is not rightfully shifted to the employer. Each party must bear his own loss. Cited Exodus International Construction Corp. v. Biscocho, G.R. No. 166109, February 23, 2011, 659 Phil. 142, 159, citing Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128 https://wpd.cdasiaonline.com/jurisprudences/54258?s_params=c3g1chnyo9MhSVrzt4KH citing https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=TyaSDxtZwX7H3YBNH2j1 Rodriguez v. Sintron Systems, Inc. G.R. No. 240254 July 24, 2019 https://wpd.cdasiaonline.com/jurisprudences/67637?s_params=cs5QsxXP7GYobXPunpvm
4 Termination of Employment In Dee Jay's Inn and Café v. Raneses, the Court ruled that "[i]n a case where the employee was neither found to have been dismissed nor to have abandoned his/her work, the general course of action is for the Court to dismiss the complaint, direct the employee to return to work, and order the employer to accept the employee." Illustrative Dee Jay's Inn and Café v. Raneses, G.R. No. 191823, October 5, 2016 https://wpd.cdasiaonline.com/jurisprudences/62157?s_params=XsJpujp58cZdKeue851X Symex Security Services, Inc. v. Rivera, Jr. G.R. No. 202613 November 08, 2017 https://wpd.cdasiaonline.com/jurisprudences/63601?s_params=XAmPQttsCXshK-uax2Jy
5 Termination of Employment Damages are recoverable in cases where the plaintiff suffers loss due to a breach of duty committed by the defendant. The plaintiff must prove two (2) things: first, that he or she suffered a loss; and second, that the defendant caused the loss by breaching a legal duty he or she owed to the plaintiff. Absent one (1) of these elements, the plaintiff is not considered to have been injured in contemplation of the law. De Peralta v. Philippine Commercial International Bank G.R. No. 184440 July 03, 2017 https://wpd.cdasiaonline.com/jurisprudences/63050?s_params=p6gkWWzaxmGyXYZjRTdK
6 Termination of Employment In the exercise of the right to terminate a contract without cause, one party need only to give the other prior written notice as provided in the contract. Cited Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389 https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
7 Termination of Employment The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other. Cited Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389 https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
8 Termination of Employment The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other. Cited Petrophil Corporation v. Court of Appeals, G.R. No. 122796, December 10, 2001, 423 Phil. 182 https://wpd.cdasiaonline.com/jurisprudences/2895?s_params=YFwWazSacL5UfvhXg66r GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
9 Termination of Employment In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that "[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee." This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed. Illustrative Gutierrez v. Singer Sewing Machine Co., G.R. No. 140982, September 23, 2003, 458 Phil. 401, 413 https://wpd.cdasiaonline.com/jurisprudences/7830?s_params=WG68QECZuNxgkGr4MtY1 Cavite Apparel, Inc. v. Marquez G.R. No. 172044 February 06, 2013 https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA
10 Termination of Employment In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that "[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee." This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed. Illustrative Caltex Refinery Employees Association v. National Labor Relations Commission, G.R. No. 102993, July 14, 1995, 316 Phil. 335, 343-344 https://wpd.cdasiaonline.com/jurisprudences/15276?s_params=dGs8Vpnrdwac6phzMDCx Cavite Apparel, Inc. v. Marquez G.R. No. 172044 February 06, 2013 https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA
11 Termination of Employment Withholding of payment by the employer does not mean that the employer may renege on its obligation to pay employees their wages, termination payments, and due benefits. The employees' benefits are also not being reduced. It is only subjected to the condition that the employees return properties properly belonging to the employer. This is only consistent with the equitable principle that "no one shall be unjustly enriched or benefited at the expense of another." Civil Code, Art. 2142 https://wpd.cdasiaonline.com/laws/2602?s_params=K4rmHmXNgmyPAUvZsyar Milan v. National Labor Relations Commission G.R. No. 202961 February 04, 2015 https://wpd.cdasiaonline.com/jurisprudences/59484?s_params=UnRs4_ZqJ-ykTVyzWbxj

5
db/migrate/20220307043427_add_content_in_annotation.rb

@ -1,5 +0,0 @@
class AddContentInAnnotation < ActiveRecord::Migration[6.1]
def change
add_column :annotations, :content, :text, default: "", null: false
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save