Browse Source

Minor updates for `doctrines` and `annotations`

pull/125/head
alexdbondoc17 4 years ago
parent
commit
ea8f1d61e0
  1. 30
      app/components/annotation_form_component.rb
  2. 51
      app/components/annotation_form_component/annotation_form_component.html.erb
  3. 8
      app/components/doctrine_index_component.rb
  4. 23
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  5. 8
      app/components/document_doctrine_index_component.rb
  6. 23
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  7. 14
      app/components/document_doctrine_show_component.rb
  8. 31
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  9. 4
      app/controllers/api/doctrine/annotations_controller.rb
  10. 4
      app/controllers/doctrine/annotations_controller.rb
  11. 47
      app/javascript/controllers/annotations_controller.js
  12. 16
      app/javascript/controllers/doctrines_controller.js
  13. 14
      app/javascript/controllers/document_controller.js
  14. 10
      app/javascript/controllers/selectize_controller.js
  15. 14
      app/models/annotation.rb
  16. 8
      app/reflexes/document_reflex.rb
  17. 15
      app/views/doctrine/annotations/edit.html.erb
  18. 16
      app/views/doctrine/annotations/new.html.erb
  19. 2
      app/views/doctrines/show.html.erb
  20. 2
      app/views/document/doctrines/show.html.erb
  21. 33
      app/views/shared/_case_lists_search_results.html.erb
  22. 15
      app/views/shared/_doctrine_form_case_lists.html.erb
  23. 2
      config/routes.rb

30
app/components/annotation_form_component.rb

@ -0,0 +1,30 @@
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 display_text
return annotation.content if annotation.persisted?
title = document.short_title || document.title
year_or_date = document.doc_date.present? ? document.doc_date.strftime("%B %d, %Y") : document.year
[title, document.clean_reference_number, year_or_date].join(", ")
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_notes %> </strong>
<%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor Notes", data: { target: "annotations.editor_notes" } %>
</div>
</div>

8
app/components/doctrine_index_component.rb

@ -60,6 +60,14 @@ class DoctrineIndexComponent < BaseComponent
search.results search.results
end 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? def render?
doctrine.present? && doctrine.persisted? doctrine.present? && doctrine.persisted?
end end

23
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -4,19 +4,20 @@
<% document_title = jurisprudence.short_title || jurisprudence.title %> <% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 class="clickable-link" style="color: darkred;" href="<%= document_path(jurisprudence, is_index_table: false, subject_ids: params[:subject_ids]) %>"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5> <h5 class="clickable-link" style="color: darkred;" href="<%= document_path(jurisprudence, is_index_table: false, subject_ids: params[:subject_ids]) %>"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5>
<% annotations.each do |annotation| %> <% annotations.each do |annotation| %>
<p class="mb-2 ms-3"> <% annotated_documents_title = [] %>
<% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %>
<% annotation.documents.each do |annotated_document| %> <% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %> <% end %>
<% end %> <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> <div class="row mb-2 pb-0 ms-3">
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %> <div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
</p> <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? %> <% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2 clickable-link" href="<%= show_url %>"> <div class="row ms-5 mb-2 clickable-link" href="<%= show_url %>">

8
app/components/document_doctrine_index_component.rb

@ -53,6 +53,14 @@ class DocumentDoctrineIndexComponent < BaseComponent
search.results search.results
end 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? def render?
doctrine.present? && doctrine.persisted? doctrine.present? && doctrine.persisted?
end end

23
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -7,21 +7,22 @@
<% if opts[:is_doctrines_index].present? %> <% if opts[:is_doctrines_index].present? %>
<% document_title = jurisprudence.short_title || jurisprudence.title %> <% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %> <% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5> <h5 style="color: darkred;"> <%= [document_title, jurisprudence.clean_reference_number, date_or_year].join(", ") %> </h5>
<% end %> <% end %>
<% annotations.each do |annotation| %> <% annotations.each do |annotation| %>
<p class="mb-2 ms-3"> <% annotated_documents_title = [] %>
<% annotated_documents_title = [] %> <% annotation.documents.each do |annotated_document| %>
<% annotation.documents.each do |annotated_document| %> <% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> <% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %> <% end %>
<% 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> <div class="row mb-2 pb-0 ms-3">
<%= raw annotation.content.present? ? annotation.content : [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ') %> <div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
</p> <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? %> <% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2"> <div class="row ms-5 mb-2">

14
app/components/document_doctrine_show_component.rb

@ -1,10 +1,10 @@
class DocumentDoctrineShowComponent < BaseComponent class DocumentDoctrineShowComponent < BaseComponent
attr_reader :current_user, :annotations, :document_id, :doctrine, :subjects attr_reader :current_user, :annotations, :jurisprudence_id, :doctrine, :subjects
def initialize(current_user:, annotations:, doctrine:, document_id:, subjects:, opts: {}) def initialize(current_user:, annotations:, doctrine:, jurisprudence_id:, subjects:, opts: {})
@annotations = annotations @annotations = annotations
@doctrine = doctrine @doctrine = doctrine
@document_id = document_id @jurisprudence_id = jurisprudence_id
@current_user = current_user @current_user = current_user
@subjects = subjects @subjects = subjects
@opts = opts @opts = opts
@ -41,4 +41,12 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil") annotation.phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
end 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
end end

31
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -5,8 +5,8 @@
<h5> <b>Doctrine Details</b> </h5> <h5> <b>Doctrine Details</b> </h5>
</div> </div>
<div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>" > <div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>" >
<a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: document_id) %>"> Edit </a> <a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: jurisprudence_id) %>"> Edit </a>
<a class="btn btn-danger " data-action="click->doctrines#delete" > Delete </a> <a class="btn btn-danger " data-action="click->doctrines#delete" > Delete </a>
</div> </div>
</div> </div>
@ -56,7 +56,7 @@
</div> </div>
<div class="collapse mb-3 mt-2" id="caseListsCollapse"> <div class="collapse mb-3 mt-2" id="caseListsCollapse">
<div class="row" data-controller="document" data-current-document-id="<%= document_id %>" data-doctrine-id="<%= id %>"> <div class="row" data-controller="document" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>">
<div class="col-sm-10 p-2"> <div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %> <%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number, Title or Short Title", data: { target: "document.input" } %>
</div> </div>
@ -92,24 +92,19 @@
<% annotation.documents.each do |annotated_document| %> <% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %> <% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> <% ad_date_or_year = annotated_document.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 %> <% end %>
<% citing_document_title = [document_title, annotation.document.reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %> <% citing_document_title = [document_title, annotation.document.clean_reference_number, date_or_year, clean_phil_rep(annotation), annotated_documents_title].reject(&:blank?).join(', ').html_safe %>
<div class="row mb-2"> <div class="row mb-2 pb-0 ms-3">
<div class="col-sm-10"> <div class="col-sm-1 p-0 me-1" style="width: auto;"> <strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> </div>
<p class="pb-0 ms-3"> <div class="col-sm-9 p-0 ms-1"> <%= raw annotation.content.present? ? content_diplay_text(annotation) : citing_document_title %> </div>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw annotation.content.present? ? annotation.content : citing_document_title %>
</p>
</div>
<div class="col-sm-2 d-flex justify-content-end align-items-baseline"> <div class="col-sm-2 d-flex justify-content-end align-items-baseline">
<a class="btn btn-secondary me-3" data-bs-toggle="modal" data-bs-target="#annotationModal" <a class="btn btn-secondary btn-sm me-1" href="<%= edit_doctrine_annotation_path(annotation.doctrine_id, annotation.id, jurisprudence_id: jurisprudence_id, document_id: annotation.document_id) %>">
data-controller="annotations" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" Edit
data-current-document-id="<%= document_id %>" data-document-title="<%= annotation.content.present? ? annotation.content : citing_document_title %>" </a>
data-action="click->annotations#renderForm"> Edit </a> <a class="btn btn-danger btn-sm ms-1" data-controller="annotations" data-jurisprudence-id="<%= jurisprudence_id %>" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a>
<a class="btn btn-danger" data-controller="annotations" data-current-document-id="<%= document_id %>" data-doctrine-id="<%= id %>" data-annotation-id="<%= annotation.id %>" data-action="click->annotations#delete" > Delete </a>
</div> </div>
</div> </div>

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

@ -42,8 +42,8 @@ module Api
if @annotation.save if @annotation.save
@documents.each { |document| @annotation.add_document(document) } if @documents.present? @documents.each { |document| @annotation.add_document(document) } if @documents.present?
@annotation.index!
respond_with @annotation respond_with @annotation
@annotation.index!
else else
render errors: @annotation.errors, status: 422 render errors: @annotation.errors, status: 422
end end
@ -67,8 +67,8 @@ module Api
@documents.each { |document| @annotation.add_document(document) } if @documents.present? @documents.each { |document| @annotation.add_document(document) } if @documents.present?
@annotation.index!
respond_with @annotation respond_with @annotation
@annotation.index!
else else
render errors: @annotation.errors, status: 422 render errors: @annotation.errors, status: 422
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 :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def new; end
def edit; end
def create def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys attrs = resource_params.to_unsafe_h.deep_symbolize_keys
document_id = attrs.delete(:document_id) document_id = attrs.delete(:document_id)

47
app/javascript/controllers/annotations_controller.js

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

16
app/javascript/controllers/doctrines_controller.js

@ -76,11 +76,13 @@ export default class extends ApplicationController {
$(".btn-close-x").trigger("click"); $(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show(); $('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" ); $( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine_id
}, },
error: function() { error: function() {
$(".btn-close-x").trigger("click"); $(".btn-close-x").trigger("click");
$('.toast').addClass('bg-danger').show(); $('.toast').addClass('bg-danger').show();
$('.toast').fadeOut(5000);
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" ); $( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" );
} }
}) })
@ -99,7 +101,7 @@ export default class extends ApplicationController {
$( ".toast-body" ).html( "<span><b>Case Lists was successfully save</b></span>" ); $( ".toast-body" ).html( "<span><b>Case Lists was successfully save</b></span>" );
$('.toast').fadeOut(5000); $('.toast').fadeOut(5000);
if ((index + 1) === annotations_attributes.length) { if (index === annotations_attributes.length - 1) {
location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id location.pathname = "/documents/" + document_id + "/doctrines/" + doctrine.id
} }
} }
@ -117,7 +119,7 @@ export default class extends ApplicationController {
} }
delete(ev) { delete(ev) {
var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"] var doctrine_id = this.element.dataset["doctrineId"], jurisprudence_id = this.element.dataset["jurisprudenceId"]
ev.preventDefault(); ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?") const contrim_alert = confirm("Are you sure to delete this record?")
@ -129,7 +131,7 @@ export default class extends ApplicationController {
$('.toast').addClass('bg-danger').show(); $('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" ); $( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
$('.toast').fadeOut(5000); $('.toast').fadeOut(5000);
location.pathname = "/documents/" + document_id location.pathname = "/documents/" + jurisprudence_id
}, },
error: function () { error: function () {
$('.toast').addClass('bg-danger').show(); $('.toast').addClass('bg-danger').show();
@ -190,7 +192,8 @@ export default class extends ApplicationController {
content: $modal.find("input[name='document_title']").val(), phil_rep: $modal.find("#phil_rep").val(), 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() } editor_notes: $modal.find("input[name='editor_notes']").val(), annomark_ids: $modal.find("select[name='annomark_ids[]']").val() }
if (annotaitons_attributes_index.length) { console.log(annotaitons_attributes_index.length)
if (annotaitons_attributes_index.length > 0) {
annotations_attributes.splice(annotaitons_attributes_index, 1, params) annotations_attributes.splice(annotaitons_attributes_index, 1, params)
$( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" ); $( ".toast-body" ).html( "<span><b>Case List is successfully updated.</b></span>" );
} else { } else {
@ -201,6 +204,7 @@ export default class extends ApplicationController {
$(".btn-close-x").trigger("click"); $(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show(); $('.toast').addClass('bg-success').show();
$('.toast').fadeOut(5000); $('.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_doctrine_form_annotations_view", annotations_attributes)
this.stimulate("DoctrinesReflex#render_default_citing_documents") this.stimulate("DoctrinesReflex#render_default_citing_documents")
this.stimulate("DoctrinesReflex#render_default_case_lists") this.stimulate("DoctrinesReflex#render_default_case_lists")
@ -227,10 +231,10 @@ export default class extends ApplicationController {
$modal.find(".modal-title").text("Edit Annotation") $modal.find(".modal-title").text("Edit Annotation")
$modal.find("select[name='annomark_ids[]']").val(annotation.annomark_ids) $modal.find("select[name='annomark_ids[]']")[0].selectize.setValue(annotation.annomark_ids)
$modal.find("trix-editor[placeholder='Document Title']").val(annotation.content) $modal.find("trix-editor[placeholder='Document Title']").val(annotation.content)
$modal.find("#document_id").val(annotation.document_id) $modal.find("#document_id").val(annotation.document_id)
$modal.find("#annotaitons_attributes_index").val(annotations_attributes_index) $modal.find("#annotaitons_attributes_index")[0].selectize.setValue(annotations_attributes_index)
if (annotation.document_ids.length) { if (annotation.document_ids.length) {
$modal.find("#document_ids").val(annotation.document_ids.join(",")) $modal.find("#document_ids").val(annotation.document_ids.join(","))

14
app/javascript/controllers/document_controller.js

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

10
app/javascript/controllers/selectize_controller.js

@ -18,9 +18,9 @@ export default class extends ApplicationController {
$(".default-selectize").selectize(default_opts); $(".default-selectize").selectize(default_opts);
var $doctrine_modal = $("#doctrineModal") var $doctrine_form = $("#doctrineForm")
var $doctrine_content = $doctrine_modal.find("input[name='content']"); var $doctrine_content = $doctrine_form.find("input[name='content']");
var $trix_content = $doctrine_modal.find(".trix-content"); var $trix_content = $doctrine_form.find("trix-editor[placeholder='Doctrine Content']");
var doctrine_content_suggestions_opts = { var doctrine_content_suggestions_opts = {
onChange: function (value) { onChange: function (value) {
@ -31,7 +31,7 @@ export default class extends ApplicationController {
$.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) { $.get("/api/doctrines/" + value + ".json", {}, function (doctrine, status) {
if (status === "success") { if (status === "success") {
$doctrine_content.val(doctrine.content); $doctrine_content.val(doctrine.content);
$doctrine_modal.find("input[name='headnote']").val(doctrine.headnote) $doctrine_form.find("input[name='headnote']").val(doctrine.headnote)
$trix_content.val(doctrine.content); $trix_content.val(doctrine.content);
} }
}); });
@ -49,7 +49,7 @@ export default class extends ApplicationController {
}, },
onChange: function (value) { onChange: function (value) {
var selectize_options = [] 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 (value.length === 0) {
if ($selectize.length) $selectize[0].selectize.clearOptions(); if ($selectize.length) $selectize[0].selectize.clearOptions();

14
app/models/annotation.rb

@ -13,8 +13,6 @@ class Annotation < ApplicationRecord
validates :content, presence: true validates :content, presence: true
before_save :parse_content
def documents def documents
annotation_documents.collect(&:document) annotation_documents.collect(&:document)
end end
@ -33,18 +31,6 @@ class Annotation < ApplicationRecord
documents.map(&:id) documents.map(&:id)
end end
def parse_content
pr = phil_rep.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
pr = pr.gsub(/(PhilRep|Phil)\.?,?/i, "Phil")
annotated_doc_title = document.short_title || document.title
annotated_doc_date = document.doc_date.present? ? document.doc_date.try(:strftime, "%B %d, %Y") : document.year
contents = content.split(" citing ")
contents[0] = [annotated_doc_title, document.clean_reference_number, annotated_doc_date, pr].join(", ")
self.content = contents.join(" citing ")
end
searchable do searchable do
integer :document_id integer :document_id
integer :doctrine_id integer :doctrine_id

8
app/reflexes/document_reflex.rb

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

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

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

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

@ -52,7 +52,7 @@
</div> </div>
<div class="row"> <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, annotations: @annotations, doctrine: @doctrine, jurisprudence_id: @document.id, subjects: @subjects)) %>
</div> </div>
</div> </div>
</div> </div>

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

@ -1,4 +1,4 @@
<div class="row" data-controller="document" data-current-document-id="<%= opts[:current_document_id] %>" data-doctrine-id="<%= opts[:doctrine_id] %>"> <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"> <div class="col-sm-10 p-2">
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title", <%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number, Title or Short Title",
data: { target: "document.input" } %> data: { target: "document.input" } %>
@ -26,14 +26,17 @@
<% unless documents.first_page? %> <% unless documents.first_page? %>
<span class="page-item first"> <span class="page-item first">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>" <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> <i class="fas fa-angle-double-left"></i>
</a> </a>
</span> </span>
<span class="page-item prev"> <span class="page-item prev">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>" <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"> data-action="click->document#paginate">
<i class="fas fa-angle-left"></i> <i class="fas fa-angle-left"></i>
</a> </a>
@ -47,7 +50,9 @@
<% else %> <% else %>
<span class="page-item page"> <span class="page-item page">
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>" <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 %> <%= page + 1 %>
</a> </a>
</span> </span>
@ -57,17 +62,17 @@
<% unless documents.last_page? %> <% unless documents.last_page? %>
<span class="page-item next"> <span class="page-item next">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" <a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i + 1 %>" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-action="click->document#paginate"> data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->document#paginate">
<i class="fas fa-angle-right"></i> <i class="fas fa-angle-right"></i>
</a> </a>
</span> </span>
<span class="page-item last"> <span class="page-item last">
<a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" <a class="page-link" data-doctrine-id="<%= opts[:doctrine_id] %>" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>"
data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= documents.total_pages %>" data-controller="document" data-q="<%= opts[:q] %>" data-citation-finder="<%= opts[:citation_finder] %>"
data-action="click->document#paginate"> data-page="<%= documents.total_pages %>" data-action="click->document#paginate">
<i class="fas fa-angle-double-right"></i> <i class="fas fa-angle-double-right"></i>
</a> </a>
</span> </span>
@ -96,12 +101,8 @@
<td> <td>
<% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %> <% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% title = document.short_title || document.title %> <% title = document.short_title || document.title %>
<a class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="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) %>">
data-current-document-id="<%= opts[:current_document_id] %>" data-doctrine-id="<%= opts[:doctrine_id] %>" Add Annotation
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 Annotation
</a> </a>
</td> </td>
</tr> </tr>

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

@ -26,13 +26,14 @@
<% unless documents.first_page? %> <% unless documents.first_page? %>
<span class="page-item first"> <span class="page-item first">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" data-page="<%= 1 %>" <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"> data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-double-left"></i> <i class="fas fa-angle-double-left"></i>
</a> </a>
</span> </span>
<span class="page-item prev"> <span class="page-item prev">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" <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"> data-page="<%= opts[:current_page].to_i - 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-left"></i> <i class="fas fa-angle-left"></i>
</a> </a>
@ -45,7 +46,7 @@
<span class="page-item page current page-link"> <%= page + 1 %> </span> <span class="page-item page current page-link"> <%= page + 1 %> </span>
<% else %> <% else %>
<span class="page-item page"> <span class="page-item page">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" <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"> data-page="<%= page + 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<%= page + 1 %> <%= page + 1 %>
</a> </a>
@ -56,14 +57,14 @@
<% unless documents.last_page? %> <% unless documents.last_page? %>
<span class="page-item next"> <span class="page-item next">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" <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"> data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-right"></i> <i class="fas fa-angle-right"></i>
</a> </a>
</span> </span>
<span class="page-item last"> <span class="page-item last">
<a class="page-link" data-controller="document" data-q="<%= opts[:q] %>" <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"> data-page="<%= documents.total_pages %>" data-action="click->document#paginateDoctrineFormCaseLists">
<i class="fas fa-angle-double-right"></i> <i class="fas fa-angle-double-right"></i>
</a> </a>
@ -94,9 +95,9 @@
<% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %> <% date_or_year = document.doc_date.strftime("%B %d, %Y") || document.year %>
<% title = document.short_title || document.title %> <% title = document.short_title || document.title %>
<a class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="doctrines" <a class="btn btn-success btn-sm" data-bs-toggle="modal" data-bs-target="#annotationModal" data-controller="doctrines"
data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-document-id="<%= document.id %>" data-document-title="<%= title %>" data-document-id="<%= document.id %>" data-document-title="<%= title %>" data-document-reference-number="<%= document.clean_reference_number %>"
data-document-reference-number="<%= document.clean_reference_number %>" data-document-date-or-year="<%= date_or_year %>" data-document-date-or-year="<%= date_or_year %>" data-document-phil-rep="<%= document.phil_rep %>"
data-document-phil-rep="<%= document.phil_rep %>" data-action="click->doctrines#newAnnotation"> data-action="click->doctrines#newAnnotation">
Add Annotation Add Annotation
</a> </a>
</td> </td>

2
config/routes.rb

@ -6,7 +6,7 @@ Rails.application.routes.draw do
resources :doctrines, only: %i[index show new edit] do resources :doctrines, only: %i[index show new edit] do
get :search, on: :collection get :search, on: :collection
scope module: :doctrine do scope module: :doctrine do
resources :annotations, only: %i[create update destroy] resources :annotations, only: %i[new edit create update destroy]
end end
end end

Loading…
Cancel
Save