Compare commits

...

138 Commits

Author SHA1 Message Date
Alexander D. Bondoc 0cb656a60a
Merge pull request #138 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 5b61cf9dba
Remove `is_citator_tab` params 4 years ago
Alexander D. Bondoc 6b4830b22a
Merge pull request #137 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 0e00dd3f0c
Fix `link` in `citator#tab` 4 years ago
Alexander D. Bondoc 63755e8268
Merge pull request #136 from lexintegritastech/fix-ux-for-clickable-links 4 years ago
Alexander D. Bondoc 08480eab46
Fix UX for clickable links 4 years ago
Angel Aviel Domaoan d05d7fa28a Add auto deployment branches 4 years ago
Angel Aviel Domaoan 412c8b58aa Add restart mode for `load_balancer` 4 years ago
Alexander D. Bondoc 0cf7193f13
Merge pull request #135 from lexintegritastech/minor-updates 4 years ago
Alexander D. Bondoc 9bebc0180b
Fix `css` for `footnotes` 4 years ago
Alexander D. Bondoc 2964d47de1
Fix font size for `doctrines#content` 4 years ago
Alexander D. Bondoc 05b0f0f94a
Fix `prompt` message 4 years ago
Alexander D. Bondoc 7aefbbb23f
Change `Editors Note` to `Editor's Note` 4 years ago
Alexander D. Bondoc 2805c86964
Merge pull request #134 from lexintegritastech/fix-sorting-for-documents-search 4 years ago
alexdbondoc17 ce34a3f4c2 Fix `sorting` in `documents#search` 4 years ago
Alexander D. Bondoc 37d6fd421a Merge pull request #133 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7c9b443dfc Enhance `selectize` for `doctrines#suggested_contents` 4 years ago
Alexander D. Bondoc e65c339289
Merge pull request #132 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9f06b3c0cd Fix linking of `document` 4 years ago
Alexander D. Bondoc 7ec5ad0bb9
Merge pull request #131 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 5ea09cf3ad Improve `grouping` for `doctrines#search` 4 years ago
Alexander D. Bondoc 83d340b013
Merge pull request #130 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 e66ea59b44 Fix `doctrines#destroy` 4 years ago
alexdbondoc17 6010d4e096 Fix UI for `doctrines#form` 4 years ago
Alexander D. Bondoc c7c72c5ee7
Merge pull request #129 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 8acbcbdae7 Add delay after saving `doctrines` 4 years ago
Alexander D. Bondoc 79636b0a90
Merge pull request #128 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 411896fc81 Enhance UI for `documents`, `doctrines`, and `annotations#form` 4 years ago
Alexander D. Bondoc c3bc942e19
Merge pull request #127 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ee2595e9d1 Fix `doctrines#edit` 4 years ago
Alexander D. Bondoc 9e1748d357
Merge pull request #126 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 66858ce260 Fix saving of `doctrines` 4 years ago
Alexander D. Bondoc 201674e543
Merge pull request #125 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ea8f1d61e0 Minor updates for `doctrines` and `annotations` 4 years ago
Alexander D. Bondoc 729073bbd6
Merge pull request #124 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9795dd8ca8 Improve UI for `doctrinines#search` 4 years ago
Alexander D. Bondoc 4a27beca8d
Merge pull request #123 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 81c27a3806 Enhance `doctrine#form` 4 years ago
Alexander D. Bondoc c9abc3411b
Merge pull request #122 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 353e53bb43 Fix `doctrine_search` 4 years ago
alexdbondoc17 185030b45d Use SOLR for `annotations` 4 years ago
alexdbondoc17 d92783bdfa Improve searchable in `doctrine` 4 years ago
alexdbondoc17 a446aa3bd5 Removee `searchable` in `doctrine_jurisprudence` 4 years ago
alexdbondoc17 74a094aae8 Add `callback` for `annotation` 4 years ago
Alexander D. Bondoc 28d4a20016
Merge pull request #121 from lexintegritastech/enhance-form-for-doctrines 4 years ago
alexdbondoc17 06de925d8b Fix issue in `doctrines#form` 4 years ago
Alexander D. Bondoc 45bec150ac
Merge pull request #120 from lexintegritastech/enhance-form-for-doctrines 4 years ago
alexdbondoc17 117981d2f5 Enhance `doctrines#form` 4 years ago
Alexander D. Bondoc 32311ab1b9
Merge pull request #119 from lexintegritastech/enhance-ui-for-analysis-tab-in-documents-show 4 years ago
alexdbondoc17 7d79f9d9f4 Enhance UI for `analysis ttab` in `documents#show` 4 years ago
Alexander D. Bondoc 8308ce3934
Merge pull request #118 from lexintegritastech/enhance-searchable-in-annotations 4 years ago
Alexander D. Bondoc 9e9c6c5ea5
Merge pull request #117 from lexintegritastech/enhance-ui-for-doctrines-modal-form 4 years ago
alexdbondoc17 f5e36b7437 Enhance UI for `doctrines#modal_form` 4 years ago
Alexander D. Bondoc 537fb356c5
Merge pull request #116 from lexintegritastech/feature-enhance-ui 4 years ago
alexdbondoc17 d0094c1345 Enhanc`searchable` in `annotations` 4 years ago
janpaulo 1549514e13
Fix selectize issue for all 4 years ago
Alexander D. Bondoc 104c0df415
Merge pull request #115 from lexintegritastech/fix-issue-in-application-layout 4 years ago
alexdbondoc17 01a040958e Fix issue in `application#layout` 4 years ago
Angel Aviel Domaoan cc5e703a8a
Merge pull request #113 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 9c17ee115c Fix temporary sorting for `documents#doctrines` 4 years ago
Angel Aviel Domaoan 98d60dca96
Merge pull request #112 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 0e8da90449 Temporary fix for `sorting` of `doctrines` 4 years ago
alexdbondoc17 1c8bd06a3f Fix `document#date` 4 years ago
alexdbondoc17 58099bba41 Implement sanitation for `phil_rep` 4 years ago
Angel Aviel Domaoan 4920225246
Merge pull request #111 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo ba95906f5c
Fix scroll into a footnotes 4 years ago
janpaulo 1321cca174
Add succes and error message for annotation and doctrines 4 years ago
Alexander D. Bondoc 1fc6ec5694
Merge pull request #110 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7b4d5481ae Enhance UI for `doctrines` and `annotations` 4 years ago
alexdbondoc17 099854f3ad Add `content` in `annotation` 4 years ago
alexdbondoc17 f14998b01c Enhance `searchable` for `jurisprudence`, `doctrine`, and `annotation` 4 years ago
Alexander D. Bondoc 792d7f32c7
Merge pull request #109 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo 3a8e1ce27a
Fix error for citation finder 4 years ago
Angel Aviel Domaoan 2894706a8a
Merge pull request #107 from lexintegritastech/feature-enhance-ui 4 years ago
janpaulo eaa5ab3d32
Change button for citation finder 4 years ago
Angel Aviel Domaoan 4da7152ec1 Implement new parser for doctrines 4 years ago
Alexander D. Bondoc 2be01091b2
Merge pull request #106 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ed3fd52c8f Add `form` validation for `doctrines#modal_form` 4 years ago
alexdbondoc17 4d5a9462ef Suggest `headnote` in `doctrine` modal `form` 4 years ago
Alexander D. Bondoc 2d89915690
Merge pull request #105 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 19c3b09136 Fix validation for `doctrine` 4 years ago
Alexander D. Bondoc ff0662d8bb
Merge pull request #104 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ba521d084d Make `root#index` the `documents#index` 4 years ago
Alexander D. Bondoc f52cb13ce6
Merge pull request #103 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3415a7658b Fix buttons spelling 4 years ago
Alexander D. Bondoc f393481673
Merge pull request #102 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 e6e30144b6 Fix `citation_finder` search for `case_lists` 4 years ago
Alexander D. Bondoc 85cb54a2c9
Merge pull request #101 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3744e9357c Fix bug for `annotations` 4 years ago
Alexander D. Bondoc 45f5a8d791
Merge pull request #100 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 4a3a8108a7 Sanitize `citation_finder` in `jurisprudence_search` 4 years ago
alexdbondoc17 aeb09ff360 Sanitize `citation_finder` in `document_search` 4 years ago
Alexander D. Bondoc 9a8ff8a3ba
Merge pull request #99 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 ab06f59469 Revert changes for `searchable` in `document` 4 years ago
Alexander D. Bondoc 204097ca6f
Merge pull request #98 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 7960921520 Fix `searchable` for `citation_finder` in `document` 4 years ago
alexdbondoc17 eeae268509 Add `order_by` in `annotations#search` 4 years ago
Alexander D. Bondoc ca804bc736
Merge pull request #97 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3f0e16feaa Fix `citation_finder#search` in `document` 4 years ago
Alexander D. Bondoc 9b4ac90af4
Merge pull request #96 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 bf755666ef Fix `sorting` of `annotation` 4 years ago
alexdbondoc17 f4657de4b9 Add `headnote` in `doctrines#index` component 4 years ago
alexdbondoc17 d5135f7f56 Fix cursor of `subjects` and `doctrines` 4 years ago
alexdbondoc17 1bc838ebed Change placeholder for `case lists` search 4 years ago
Alexander D. Bondoc e5e877a8f6
Merge pull request #95 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3318de9600 Fix refresh button in `document#advanced_search` component 4 years ago
Alexander D. Bondoc 5b88ce7262
Merge pull request #94 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 3535030ed8 Fix `delete` of `annotations` 4 years ago
Alexander D. Bondoc 89501bd677
Merge pull request #93 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 84b3957ed6 Fix `morph` of `annotations` 4 years ago
Alexander D. Bondoc 115e7618f0
Merge pull request #92 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 8c8ea407f6 Add `margin-bottom` for `annotations` 4 years ago
Alexander D. Bondoc c775815f49
Merge pull request #91 from lexintegritastech/improve-main-ui 4 years ago
alexdbondoc17 b1fa34dfc2 Fix sorting of `documents` for `case lists` 4 years ago
alexdbondoc17 136a574e79 Fix `pagination` for `doctrines` 4 years ago
alexdbondoc17 3d2e135975 Add `citation_finder` in `case_lists#search` 4 years ago
Angel Aviel Domaoan 8c91ab3186 Configure mailer 4 years ago
Angel Aviel Domaoan 8566e12046 Implement okcomputer for healthchecks 4 years ago
Angel Aviel Domaoan 88d64da031 Require auth for sidekiq routes 4 years ago
alexdbondoc17 71d56cecf1 Fix issue for not displaying of new created doctrine 4 years ago
alexdbondoc17 1948e49392 Fix component for `doctrines#index` 4 years ago
alexdbondoc17 92548141ea Fix UI for `decisions` 4 years ago
alexdbondoc17 25d8a749df Fix back button for `document_doctrines#show` 4 years ago
alexdbondoc17 5f851449da Fix saving of `annotations` 4 years ago
alexdbondoc17 56e26e8344 Implement `documents#search` when clicking to `subjects` Offcanvas 4 years ago
Angel Aviel Domaoan cda8badb1e Fix years 4 years ago
Angel Aviel Domaoan b144e5a23d Fix docker_compose_up_services 4 years ago
Angel Aviel Domaoan dfe25ae762 Fix docker-compose 4 years ago
Angel Aviel Domaoan 777784b20c Fix years 4 years ago
Alexander D. Bondoc 23d8eeea4f
Merge pull request #88 from lexintegritastech/feature-enhance-ui 4 years ago
Angel Aviel Domaoan 33bc8f9a26 Fix years 4 years ago
Angel Aviel Domaoan 57b82ce4be Fix healthcheck for workers 4 years ago
janpaulo 99b8eb565d
Change position add button for sub levels 4 years ago
janpaulo cfa965670f
Add loading snipper per page 4 years ago
Angel Aviel Domaoan 041b7c590a Configure `docker_compose_up_services` for production and staging 4 years ago
janpaulo 6fcfa5af5f Set width table for document show search 4 years ago
Angel Aviel Domaoan 6f2c419131 Fix sort_by and years 4 years ago
Angel Aviel Domaoan 9fd378d494 Implement workers 4 years ago
  1. 2
      .github/workflows/deployment.yml
  2. 1
      Procfile
  3. 1
      Procfile-worker
  4. 51
      app/components/annotation_form_component.rb
  5. 51
      app/components/annotation_form_component/annotation_form_component.html.erb
  6. 7
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  7. 6
      app/components/citation_index_table_component.rb
  8. 4
      app/components/citation_index_table_component/citation_index_table_component.html.erb
  9. 10
      app/components/doctrine_form_component.rb
  10. 38
      app/components/doctrine_form_component/doctrine_form_component.html.erb
  11. 55
      app/components/doctrine_index_component.rb
  12. 87
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  13. 10
      app/components/doctrine_index_table_component/doctrine_index_table_component.html.erb
  14. 19
      app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb
  15. 6
      app/components/doctrines_offcanvas_accordion_component/doctrines_offcanvas_accordion_component.html.erb
  16. 6
      app/components/doctrines_offcanvas_component/doctrines_offcanvas_component.html.erb
  17. 6
      app/components/document_advanced_search_component.rb
  18. 4
      app/components/document_advanced_search_component/document_advanced_search_component.html.erb
  19. 23
      app/components/document_doctrine_index_component.rb
  20. 88
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  21. 32
      app/components/document_doctrine_show_component.rb
  22. 53
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  23. 24
      app/components/document_index_table_component.rb
  24. 5
      app/components/document_index_table_component/document_index_table_component.html.erb
  25. 2
      app/components/documents_years_component/documents_years_component.html.erb
  26. 25
      app/components/jurisprudences_index_table_component.rb
  27. 6
      app/components/jurisprudences_index_table_component/jurisprudences_index_table_component.html.erb
  28. 70
      app/components/reports_search_results_component/reports_search_results_component.html.erb
  29. 9
      app/components/sidenav_component/sidenav_component.html.erb
  30. 12
      app/components/subjects_accordion_component/subjects_accordion_component.html.erb
  31. 2
      app/components/subjects_offcanvas_accordion_component.rb
  32. 6
      app/components/subjects_offcanvas_accordion_component/subjects_offcanvas_accordion_component.html.erb
  33. 6
      app/components/subjects_offcanvas_component/subjects_offcanvas_component.html.erb
  34. 8
      app/controllers/api/doctrine/annotations_controller.rb
  35. 18
      app/controllers/api/doctrines_controller.rb
  36. 2
      app/controllers/api/documents_controller.rb
  37. 4
      app/controllers/api/jurisprudences_controller.rb
  38. 4
      app/controllers/concerns/annotation_search.rb
  39. 21
      app/controllers/concerns/doctrine_search.rb
  40. 52
      app/controllers/concerns/document_search.rb
  41. 54
      app/controllers/concerns/jurisprudence_search.rb
  42. 7
      app/controllers/decisions_controller.rb
  43. 4
      app/controllers/doctrine/annotations_controller.rb
  44. 8
      app/controllers/doctrines_controller.rb
  45. 15
      app/controllers/documents_controller.rb
  46. 47
      app/javascript/controllers/annotations_controller.js
  47. 34
      app/javascript/controllers/application_controller.js
  48. 197
      app/javascript/controllers/doctrines_controller.js
  49. 22
      app/javascript/controllers/document_controller.js
  50. 16
      app/javascript/controllers/selectize_controller.js
  51. 3
      app/javascript/controllers/subjects_controller.js
  52. 8
      app/javascript/packs/application.js
  53. 36
      app/javascript/src/application.scss
  54. 9
      app/javascript/src/application/subject-accordion.scss
  55. 66
      app/jobs/parse_linkable_content_job.rb
  56. 17
      app/models/annotation.rb
  57. 23
      app/models/cdao/document.rb
  58. 7
      app/models/cdao/jurisprudence.rb
  59. 9
      app/models/cdao/subject.rb
  60. 104
      app/models/doctrine.rb
  61. 1
      app/models/doctrine_jurisprudence.rb
  62. 6
      app/reflexes/annotation_reflex.rb
  63. 42
      app/reflexes/doctrines_reflex.rb
  64. 13
      app/reflexes/document_reflex.rb
  65. 3
      app/views/api/doctrines/suggested_contents.json.jbuilder
  66. 15
      app/views/doctrine/annotations/edit.html.erb
  67. 16
      app/views/doctrine/annotations/new.html.erb
  68. 12
      app/views/doctrines/edit.html.erb
  69. 64
      app/views/doctrines/new.html.erb
  70. 13
      app/views/doctrines/search.html.erb
  71. 2
      app/views/doctrines/show.html.erb
  72. 8
      app/views/document/doctrines/_document_search_results_table.html.erb
  73. 10
      app/views/document/doctrines/show.html.erb
  74. 2
      app/views/documents/index.html.erb
  75. 21
      app/views/documents/search.html.erb
  76. 106
      app/views/documents/show.html.erb
  77. 16
      app/views/layouts/application.html.erb
  78. 4
      app/views/reports/index.html.erb
  79. 7
      app/views/shared/_annotated_documents_search_results.html.erb
  80. 64
      app/views/shared/_annotation_form.html.erb
  81. 2
      app/views/shared/_annotations_index_view.html.erb
  82. 23
      app/views/shared/_case_lists_no_results.html.erb
  83. 52
      app/views/shared/_case_lists_search_results.html.erb
  84. 71
      app/views/shared/_doctrine_form_annotation_modal_form.html.erb
  85. 38
      app/views/shared/_doctrine_form_annotations_view.html.erb
  86. 108
      app/views/shared/_doctrine_form_case_lists.html.erb
  87. 101
      app/views/shared/_doctrine_form_citing_documents_search_results.html.erb
  88. 23
      app/views/shared/_doctrine_form_default_case_lists.html.erb
  89. 59
      app/views/shared/_doctrines_pagination.html.erb
  90. 4
      app/views/shared/_document_doctrines_index.html.erb
  91. 6
      app/views/subject_indexes/index.html.erb
  92. 12
      app/views/subject_indexes/show.html.erb
  93. 23
      config/application.rb
  94. 14
      config/application.yml
  95. 2
      config/credentials/development.yml.enc
  96. 2
      config/credentials/production.yml.enc
  97. 1
      config/deploy/production.rb
  98. 1
      config/deploy/staging.rb
  99. 14
      config/initializers/okcomputer.rb
  100. 18
      config/routes.rb
  101. Some files were not shown because too many files have changed in this diff Show More

2
.github/workflows/deployment.yml

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

1
Procfile

@ -1,2 +1,3 @@
web: rails s
webpack: ./bin/webpack-dev-server
worker: bundle exec sidekiq -q default,2 -q mailers,1 -q active_storage_analysis,1 -q active_storage_purge,1 -q sunspot_index,1

1
Procfile-worker

@ -0,0 +1 @@
sidekiq: bundle exec sidekiq $SIDEKIQ_QUEUES

51
app/components/annotation_form_component.rb

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

@ -0,0 +1,51 @@
<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,6 +11,7 @@
<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" } %>
@ -30,7 +31,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", data: { target: "annotations.q" } %>
<%= 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>
@ -58,8 +59,8 @@
<div class="row">
<div class="col-sm-12 p-2">
<strong> <%= label_tag :editor_notes %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes", data: { target: "annotations.editor_notes" } %>
<strong> <%= label_tag "Editor's Note" %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor's Note", data: { target: "annotations.editor_notes" } %>
</div>
</div>
</div>

6
app/components/citation_index_table_component.rb

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

10
app/components/doctrine_form_component.rb

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

@ -0,0 +1,38 @@
<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,19 +1,14 @@
class DoctrineIndexComponent < BaseComponent
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
attr_reader :search_results, :opts
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
include AnnotationSearch
include DoctrineSearch
def initialize(search_results:, current_user:, opts: {})
@search_results = search_results
@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
@ -22,12 +17,6 @@ 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?
@ -40,7 +29,37 @@ 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?
doctrine.present? && doctrine.persisted?
search_results.present?
end
end

87
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -1,45 +1,58 @@
<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 %>
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
<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>
<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>
<% 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.reference_number, ad_date_or_year].join(", ") %>
<% 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>
<% 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>
<% 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| %>
<% 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(", ") %>
<% 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 %>
<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>
<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>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
</div>
<% end %>
</div>
<hr/>
</div>

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

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

19
app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb

@ -7,12 +7,13 @@
</div>
<div class="modal-body">
<div class="mb-3">
<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"> </select>
</div>
<div class="mb-3">
<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>
</div>
<div class="mb-3" id="doctine_content_suggestions_div">
<label for="subject-name" class="col-form-label">Doctine content suggestions</label>
@ -21,12 +22,14 @@
<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", data: { target: "doctrines.headnote" } %>
<%= 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>
</div>
<div class="mb-3">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", data: { target: "doctrines.content" } %>
<%= 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>
</div>
</div>
<div class="modal-footer">

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

@ -5,10 +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#loadDoctrinesOffcanvasAccordion">
<%= 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" %>
<%= 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" } %>
</div>
<% else %>
<%= 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" %>
<%= 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" } %>
<% end %>
</div>

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

@ -15,10 +15,12 @@
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, search_doctrines_path(subject_ids: [root.id], is_index_table: false), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= 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" } %>
</div>
<% else %>
<%= 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" %>
<%= 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" } %>
<% end %>
</div>

6
app/components/document_advanced_search_component.rb

@ -6,6 +6,8 @@ class DocumentAdvancedSearchComponent < BaseComponent
end
def years
(1901..Time.zone.today.year).entries.reverse
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
end
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[:short_title], class: "form-control mb-0" %>
<%= text_field_tag :title, params[: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 type="reset" class="btn btn-success me-2 mb-2"><i class="fas fa-sync"></i> Refresh</button>
<button class="btn btn-success reset-document-advanced-search 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,6 +2,8 @@ class DocumentDoctrineIndexComponent < BaseComponent
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
include AnnotationSearch
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
@opts = opts
@ -10,8 +12,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
@ -40,6 +42,25 @@ 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

88
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -1,55 +1,45 @@
<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' : '' %>">
<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.reference_number, date_or_year].join(", ") %> </h5>
<% end %>
<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="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>
<% 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.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% annotations.each do |annotation| %>
<% 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(", ") %>
<% 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 %>
<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>
<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>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<hr/>
<hr/>
</div>

32
app/components/document_doctrine_show_component.rb

@ -1,12 +1,11 @@
class DocumentDoctrineShowComponent < BaseComponent
attr_reader :current_user, :annotations, :document_id, :doctrine, :subjects
attr_reader :current_user, :doctrine, :opts
def initialize(current_user:, annotations:, doctrine:, document_id:, subjects:, opts: {})
@annotations = annotations
include AnnotationSearch
def initialize(current_user:, doctrine:, opts: {})
@doctrine = doctrine
@document_id = document_id
@current_user = current_user
@subjects = subjects
@opts = opts
end
@ -26,8 +25,8 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title
end
def document
Document.find(document_id)
def jurisprudence
Cdao::Jurisprudence.find(opts[:jurisprudence_id])
end
def date_or_year(annotation)
@ -35,4 +34,23 @@ 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

53
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" 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 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>
</div>
@ -51,17 +51,21 @@
<div class="row">
<div class="col-sm-10"> </div>
<div class="col-sm-2 p-2">
<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>
<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" 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 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>
<div class="col p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %>
<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>
</div>
@ -72,7 +76,6 @@
<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>
@ -82,7 +85,6 @@
<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 %>
@ -90,31 +92,26 @@
<% 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.reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% 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">
<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>
<% 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 class="col-sm-2 d-flex justify-content-end align-items-baseline">
<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>
<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>
</div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row">
<div class="row mb-2">
<div class="col-sm-1 ms-5 p-0" style="width: 105px;">
<span> Editors Note: </span>
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">

24
app/components/document_index_table_component.rb

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

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

@ -1,5 +0,0 @@
<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: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<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>
<% end %>
</div>
</td>

25
app/components/jurisprudences_index_table_component.rb

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

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

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

70
app/components/reports_search_results_component/reports_search_results_component.html.erb

@ -1,40 +1,42 @@
<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>
<div class="container-fluid p-0">
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.strftime : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<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="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0">
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.strftime : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-5">
<% 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.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-5">
<% 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.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<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>
<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">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
<% 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>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
<hr/>
<hr/>
</div>

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

@ -81,20 +81,15 @@
</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" data-bs-toggle="offcanvas" data-bs-target="#subjectsOffCanvas"
data-controller="subjects" data-accordion-target="#subjectsOffCanvasAccordionBody"
data-action="click->subjects#loadSubjectsOffcanvasAccordion">
<a class="nav-link" style="cursor: pointer" data-bs-toggle="offcanvas" data-bs-target="#subjectsOffCanvas">
<i class="fas fa-indent me-2"></i> Subjects
</a>
</li>
<li class="nav-item p-2">
<li class="nav-item p-2" style="cursor: pointer">
<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,12 +5,16 @@
<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"], 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" %>
<%= 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" %>
</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" %>
<%= 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",
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" %>
<% end %>
</div>

2
app/components/subjects_offcanvas_accordion_component.rb

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

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

@ -5,10 +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#loadSubjectsOffcanvasAccordion">
<%= 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" %>
<%= 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" } %>
</div>
<% else %>
<%= 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" %>
<%= 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" } %>
<% end %>
</div>

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

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

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

@ -43,6 +43,7 @@ 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
@ -54,10 +55,10 @@ module Api
document_ids = params[:document_ids].split(",")
if document_ids.present?
@documents = Cdao::Jurisprudence.where(id: document_ids)
@documents = Cdao::Document.where(id: document_ids)
end
attrs[:document] = Cdao::Jurisprudence.find(document_id) if document_id.present?
attrs[:document] = Cdao::Document.find(document_id) if document_id.present?
if @annotation.update(attrs)
@annotation.annotation_documents.each do |annotation_document|
@ -67,6 +68,7 @@ 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
@ -81,7 +83,7 @@ module Api
private
def resource_params
params.permit(:document_id, :phil_rep, :editor_notes, :rank, annomark_ids: [])
params.permit(:document_id, :content, :phil_rep, :editor_notes, :rank, annomark_ids: [])
end
def search_params

18
app/controllers/api/doctrines_controller.rb

@ -28,10 +28,12 @@ module Api
@doctrine.subject_ids = subject_ids if subject_ids.present?
jurisprudence_ids.each do |jurisprudence_id|
@doctrine.doctrine_jurisprudences.create(jurisprudence_id: jurisprudence_id)
doctrine_jurisprudence = @doctrine.doctrine_jurisprudences.create(jurisprudence_id: jurisprudence_id)
doctrine_jurisprudence.jurisprudence.index! if doctrine_jurisprudence.persisted?
end
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
@ -45,6 +47,7 @@ module Api
@doctrine.subject_ids = subject_ids if subject_ids.present?
respond_with @doctrine
@doctrine.index!
else
render errors: @doctrine.errors, status: 422
end
@ -56,6 +59,19 @@ 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: [])
exclude_ids: [], sort_by: %i[search_year reference_number search_doc_date])
end
end
end

4
app/controllers/api/jurisprudences_controller.rb

@ -19,7 +19,9 @@ module Api
def years
authorize! :index, Cdao::Jurisprudence
@years = (1901..Time.zone.today.year).entries.reverse
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
respond_with @years
end

4
app/controllers/concerns/annotation_search.rb

@ -9,6 +9,10 @@ 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,6 +9,12 @@ 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
@ -23,6 +29,21 @@ 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,5 +1,6 @@
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
@ -13,16 +14,57 @@ module DocumentSearch
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:citation_finders_names).any_of(search_params[:citation_finder]) if search_params[:citation_finder].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
with(:is_only_in_premium_libraries, false)
order_by :doc_date, :desc
order_by :year, :desc
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
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

54
app/controllers/concerns/jurisprudence_search.rb

@ -1,5 +1,6 @@
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
@ -19,18 +20,59 @@ 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(search_params[:citation_finder]) if search_params[:citation_finder].present?
with(:citation_finders_names).any_of(sanitize_citer_finder_param(search_params[:citation_finder])) if search_params[:citation_finder].present?
without(:id).any_of(search_params[:exclude_ids]) if search_params[:exclude_ids].present?
with(:is_only_in_premium_libraries, false)
order_by :doc_date, :desc
order_by :year, :desc
if search_params[:sort_by].blank?
order_by :search_year, :desc
order_by :search_doc_date, :desc
order_by :reference_number, :desc
end
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,7 +9,10 @@ class DecisionsController < ApplicationController
search = jurisprudence_search(search_params)
@jurisprudences = search.results
@years = (1901..Time.zone.today.year).entries.reverse
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
respond_to do |format|
format.html
@ -20,6 +23,6 @@ class DecisionsController < ApplicationController
def search_params
params.permit(:reference_number, :title, :short_title, :q, :page, :per_page,
:subject_ids)
:subject_ids, sort_by: %i[search_year reference_number search_doc_date])
end
end

4
app/controllers/doctrine/annotations_controller.rb

@ -2,6 +2,10 @@ 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,6 +4,10 @@ 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
@ -15,7 +19,7 @@ class DoctrinesController < ApplicationController
def search
@search = doctrine_search(search_params)
@doctrines = @search.results
@search_results = @search.results
respond_to do |format|
format.html
@ -70,6 +74,6 @@ class DoctrinesController < ApplicationController
end
def search_params
params.permit(jurisprudence_ids: [], subject_ids: [])
params.permit(:page, :per_page, jurisprudence_ids: [], subject_ids: [])
end
end

15
app/controllers/documents_controller.rb

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

47
app/javascript/controllers/annotations_controller.js

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

34
app/javascript/controllers/application_controller.js

@ -21,25 +21,33 @@ import Selectize from "selectize";
*/
export default class extends Controller {
connect () {
$(".clickable-link").on("click", function (e) {
e.preventDefault();
$(".reset-document-advanced-search").on("click", function (ev) {
ev.preventDefault()
let $href = $(this).attr("href");
if ($href !== undefined) {
window.location.href = $href;
}
});
$(".clickable-tr").on("click", function () {
let $href = $(this).attr("href");
if ($href !== undefined) {
window.open($href);
}
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)
}
openLink ($event) {
$event.preventDefault()
window.location.href = this.element.dataset['href']
}
openLinkToNewTab ($event) {
$event.preventDefault()
window.open(this.element.dataset['href'])
}
/* Application-wide lifecycle methods
*
* Use these methods to handle lifecycle concerns for the entire application.

197
app/javascript/controllers/doctrines_controller.js

@ -1,6 +1,7 @@
import ApplicationController from './application_controller'
var annotations_attributes = []
export default class extends ApplicationController {
static targets = ["input", "document_id", "doctrine_id", "headnote", "content"]
static targets = ["input", "q", "document_id", "doctrine_id", "headnote", "content"]
connect () {
super.connect()
@ -49,25 +50,75 @@ export default class extends ApplicationController {
}
save () {
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 }
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 }
if (doctrine_id !== null && doctrine_id !== undefined && doctrine_id !== "") {
$.ajax({
url: "/api/doctrines/" + doctrine_id,
type: 'PUT',
data: params,
success: function() {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
}
})
} else {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(data, status) {
if(status === 'success') {
location.pathname = "/documents/" + document_id + "/doctrines/" + data.id
}
})
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) {
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);
}
})
}
}
}
@ -81,9 +132,117 @@ 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"]
static targets = ["input", "citation_finder"]
connect () {
super.connect()
@ -8,14 +8,26 @@ export default class extends ApplicationController {
search () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.inputTarget.value, page: 1 },
this.element.dataset["doctrineId"])
{ 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"] })
}
paginate () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.element.dataset["q"], page: this.element.dataset["page"] },
this.element.dataset["doctrineId"])
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citationFinder"],
page: this.element.dataset["page"] },
this.element.dataset["doctrineId"], this.element.dataset["jurisprudenceId"])
}
loadYears () {

16
app/javascript/controllers/selectize_controller.js

@ -18,8 +18,9 @@ export default class extends ApplicationController {
$(".default-selectize").selectize(default_opts);
var $doctrine_content = $("#doctrineModal").find("input[name='content']");
var $trix_content = $("#doctrineModal").find(".trix-content");
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_suggestions_opts = {
onChange: function (value) {
@ -30,6 +31,7 @@ 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);
}
});
@ -47,12 +49,12 @@ export default class extends ApplicationController {
},
onChange: function (value) {
var selectize_options = []
var $selectize = $("#doctrineModal").find("#doctine_content_suggestions").selectize($.extend({ options: selectize_options }, doctrine_content_suggestions_opts));
var $selectize = $("#doctrineForm").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.json", { subject_ids: value }, function(data, status) {
$.get("/api/doctrines/suggested_contents.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 });
@ -88,9 +90,9 @@ export default class extends ApplicationController {
if ($subjects_selectize.length) $subjects_selectize[0].selectize.addOption(result, true);
})
if ($subject_ids_selectize.length) $subject_ids_selectize[0].selectize.refreshOptions();
if ($subjects_selectize.length) $subjects_selectize[0].selectize.refreshOptions();
//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();
}
});

3
app/javascript/controllers/subjects_controller.js

@ -9,7 +9,6 @@ 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 {
@ -29,7 +28,6 @@ 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 {
@ -49,7 +47,6 @@ 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,6 +36,12 @@ $(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);
@ -56,7 +62,7 @@ $(document).on("ready turbolinks:load", function () {
a = $(this), b = $(a.attr('href'))
if(b.length<=0)return
event.preventDefault()
$('html, body, .tab-content').animate({ scrollTop: b.offset().top }, 700, 'linear')
document.getElementById(b[0].id).scrollIntoView( {behavior: "smooth", duration: 700 })
})
});

36
app/javascript/src/application.scss

@ -116,4 +116,38 @@
background-size: cover;
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

@ -26,4 +26,13 @@
.non-toggle {
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

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

17
app/models/annotation.rb

@ -11,6 +11,8 @@ 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
@ -33,6 +35,21 @@ 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,6 +1,8 @@
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
@ -11,6 +13,15 @@ class Cdao::Document < Cdao::Base
def clean_reference_number
(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)
@ -20,6 +31,13 @@ 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])
@ -69,6 +87,11 @@ 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,6 +1,7 @@
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
@ -29,6 +30,10 @@ class Cdao::Jurisprudence < Cdao::Base
Cdao::Citation.where(cited_doc_id: self.id, cited_doc_type: self.class.name.gsub("Cdao::", ""))
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
@ -163,7 +168,5 @@ 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,14 +67,19 @@ 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?
root.descendants.each { |a| a.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] } if root.present?
sub6.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] if sub6.present? && sub6.persisted?
end
end

104
app/models/doctrine.rb

@ -10,7 +10,6 @@ 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)
@ -20,6 +19,14 @@ 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
@ -83,7 +90,7 @@ class Doctrine < ApplicationRecord
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.library_subjects.find_or_create_by(library_id: 27)
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}"
@ -91,19 +98,110 @@ class Doctrine < ApplicationRecord
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.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
end
end
searchable do
text :content
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
join(:phil_rep, :target => Annotation, :type => :string, :join => { :from => :annotation_doctrine_id, :to => :id })
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
date :created_at
string :headnote
string :content
end
end

1
app/models/doctrine_jurisprudence.rb

@ -3,4 +3,5 @@ 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)
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 "#annotatedDocumentsSearchResults", render(partial: "/shared/annotated_documents_search_results", locals: { documents: @documents, opts: opts })
@ -17,4 +17,8 @@ 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

@ -0,0 +1,42 @@
# 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)
search = document_search(search_params)
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]))
@documents = search.results
opts = { doctrine_id: doctrine_id, current_page: search_params[:page], q: search_params[:q] }
opts = { doctrine_id: doctrine_id, jurisprudence_id: jurisprudence_id, current_page: search_params[:page], q: search_params[:q], citation_finder: search_params[:citation_finder] }
morph "#caseListsCollapse", render(partial: "/shared/case_lists_search_results", locals: { documents: @documents, opts: opts })
end
@ -19,4 +19,11 @@ 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

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

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

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

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

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

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

@ -1,11 +1,6 @@
<div class="container-fluid mt-1 p-0 doctrine-index-body">
<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"/>
<% 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 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>
<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) })) %>
</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, annotations: @annotations, doctrine: @doctrine, document_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence, subjects: @subjects)) %>
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, jurisprudence_id: @jurisprudence.present? ? @jurisprudence.id : @jurisprudence)) %>
</div>
</div>
</div>

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

@ -1,14 +1,14 @@
<% search_results.each do |search_result| %>
<tr>
<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>
<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>
<% 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" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="annotations"
<a class="btn btn-success btn-sm" 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">

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

@ -5,7 +5,11 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<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>
<% 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>
@ -43,12 +47,12 @@
<div class="card-body pt-0">
<div class="row">
<div class="d-flex justify-content-end p-2">
<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>
<a class="btn btn-warning" href="<%= new_doctrine_path(jurisprudence_id: @document.id, doctrine_id: @doctrine.id ) %>"> Add Doctrine </a>
</div>
</div>
<div class="row">
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, annotations: @annotations, doctrine: @doctrine, document_id: @document.id, subjects: @subjects)) %>
<%= render(DocumentDoctrineShowComponent.new(current_user: current_user, doctrine: @doctrine, opts: { jurisprudence_id: @document.id })) %>
</div>
</div>
</div>

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

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

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

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

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

@ -11,10 +11,14 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<a class="<%= params[:is_index_table].present? || params[:is_citator_tab] === "true"? "d-none": '' %>" href="<%= documents_path %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% if params[:is_index_table].present? %>
<a href="<%= search_documents_path(is_index_table: true, subject_ids: params[:subject_ids].join(",")) %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% else %>
<a class="<%= params[:is_citator_tab] === "true"? "d-none": '' %>" href="<%= documents_path %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<% end %>
</div>
<div class="col-lg-3 text-end">
<b>Date : </b>
<b>Date : </b>
</div>
<div class="col-lg-3 text-end">
<b><%= @document.docdate.present? ? @document.docdate.strftime("%m/%d/%Y") : @document.year %> </b>
@ -38,7 +42,7 @@
Title :
</div>
<div class="col-lg-9">
<strong> <%= @document.short_title || @document.title %> </strong>
<strong> <%= @document.short_title || @document.title %> </strong>
</div>
</div>
</div>
@ -46,56 +50,82 @@
</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 <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active' : '' %>" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#analysisTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Analysis</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link <%= params[:is_document_view].to_s.eql?("true") ? 'active' : '' %>" id="documentMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link <%= params[:is_citator_tab].to_s.eql?("true") ? 'active' : '' %>" id="citatorMenuTab" data-bs-toggle="tab" data-bs-target="#citatonTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Citator</button>
<button class="nav-link <%= @jurisprudence.blank? ? 'active' : '' %>" id="documentMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button>
</li>
<% 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;">
<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-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>
<% 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>
</div>
</div>
<div class="container-sm row-flex col-sm-12 mt-2">
<%= render(DoctrineModalFormComponent.new(current_user: current_user)) %>
</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 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>
</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>
</div>
</div>
<% end %>
<div class="tab-pane fade <%= params[:is_document_view].to_s.eql?("true") ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="tab-pane fade <%= @jurisprudence.blank? ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="container-sm mt-2">
<%= raw @document.content.html_safe%>
</div>
</div>
<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>
<div class="col-md-6"> <%= render PaginationComponent.new(data: @paginated_cited_in_documents, opts: { is_cited_in_doc: true}) %> </div>
</div>
<table class="table table-hover mb-0 table-width">
<thead style="position: sticky;top: 0">
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
</thead>
<% 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>
<div class="col-md-6"> <%= render PaginationComponent.new(data: @paginated_cited_in_documents, opts: { is_cited_in_doc: true}) %> </div>
</div>
<table class="table table-hover mb-0 table-width">
<thead style="position: sticky;top: 0">
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
</thead>
<tbody>
<%= render(CitationIndexTableComponent.with_collection(@cited_in_documents, current_user: current_user)) %>
</tbody>
</table>
</div>
<tbody>
<%= render(CitationIndexTableComponent.with_collection(@cited_in_documents, current_user: current_user)) %>
</tbody>
</table>
</div>
<% end %>
</div>
</div>
</div>

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

@ -54,14 +54,28 @@
<%= 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="<%= current_user.present? ? 'col py-3 main-content-body mt-5' : 'col-sm-5 login-body-box' %>">
<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="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="form-control subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select>
<select class="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: "form-control default-selectize p-0", multiple: true %>
<%= select_tag :user_ids, options_from_collection_for_select(@users, :id, :name, params[:user_ids]), class: "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", data: { target: "annotations.input" } %>
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title", 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,14 +78,15 @@
<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> <%= document.doc_date.present? ? document.doc_date : document.year %> </td>
<td> <%= date_or_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="<%= document.doc_date || document.year %>"
data-document-date="<%= date_or_year %>"
data-document-title="<%= document.short_title || document.title %>"
data-action="click->annotations#addAnnotatedDocument" >
Add

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

@ -0,0 +1,64 @@
<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> Editors Note: </span>
<span> Editor's Note: </span>
</div>
<div class="col-sm-10 ps-0">

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

@ -0,0 +1,23 @@
<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,10 +1,14 @@
<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",
<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",
data: { target: "document.input" } %>
</div>
<div class="col-sm-1 p-2">
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %>
<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>
</div>
@ -22,14 +26,17 @@
<% unless documents.first_page? %>
<span class="page-item first">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-q="<%= opts[:q] %>" data-page="<%= 1 %>" data-action="click->document#paginate">
data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-q="<%= opts[:q] %>"
data-citation-finder="<%= opts[:citation_finder] %>" 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-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i - 1 %>"
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-action="click->document#paginate">
<i class="fas fa-angle-left"></i>
</a>
@ -43,7 +50,9 @@
<% else %>
<span class="page-item page">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>"
data-q="<%= opts[:q] %>" data-page="<%= page + 1 %>" data-action="click->document#paginate">
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">
<%= page + 1 %>
</a>
</span>
@ -53,17 +62,17 @@
<% unless documents.last_page? %>
<span class="page-item next">
<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">
<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">
<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-controller="document" data-q="<%= opts[:q] %>" data-page="<%= documents.total_pages %>"
data-action="click->document#paginate">
<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">
<i class="fas fa-angle-double-right"></i>
</a>
</span>
@ -86,17 +95,14 @@
<tbody>
<% documents.each do |document| %>
<tr>
<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 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 || document.year %>
<% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% title = document.short_title || document.title %>
<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 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>
</td>
</tr>

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

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

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

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

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

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

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

@ -0,0 +1,4 @@
<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,11 +11,13 @@
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, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= 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 '<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, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= 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 '<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="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 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>
</div>
<div class="card-body subject-body-index" style="position: relative;">
@ -51,11 +51,13 @@
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, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= 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 '<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, subject_index_path(root.id), class: "accordion-link text-decoration-none text-dark d-block sub1 clickable-link" %>
<%= 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 '<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,5 +18,28 @@ 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,3 +12,17 @@ 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 @@
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==
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==

2
config/credentials/production.yml.enc

@ -1 +1 @@
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==
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==

1
config/deploy/production.rb

@ -62,3 +62,4 @@ 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,3 +62,4 @@ 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

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

18
config/routes.rb

@ -1,12 +1,12 @@
Rails.application.routes.draw do
devise_for :users
root to: "home#index"
root to: "documents#index"
resources :doctrines, only: %i[index show] do
resources :doctrines, only: %i[index show new edit] do
get :search, on: :collection
scope module: :doctrine do
resources :annotations, only: %i[create update destroy]
resources :annotations, only: %i[new edit create update destroy]
end
end
@ -19,7 +19,7 @@ Rails.application.routes.draw do
end
resources :decisions, only: %i[index]
resources :subject_indexes do
resources :subject_indexes do
member do
get :doctrines
end
@ -27,8 +27,13 @@ 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
@ -50,4 +55,9 @@ Rails.application.routes.draw do
end
end
end
authenticate :user do
require "sidekiq/web"
mount Sidekiq::Web => "/sidekiq"
end
end

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

Loading…
Cancel
Save