Browse Source

Enhance `doctrine#form`

pull/123/head
alexdbondoc17 4 years ago
parent
commit
81c27a3806
  1. 22
      app/components/doctrine_form_component/doctrine_form_component.html.erb
  2. 61
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  3. 2
      app/controllers/api/doctrine/annotations_controller.rb
  4. 153
      app/javascript/controllers/doctrines_controller.js
  5. 12
      app/javascript/controllers/document_controller.js
  6. 20
      app/reflexes/doctrines_reflex.rb
  7. 7
      app/reflexes/document_reflex.rb
  8. 6
      app/views/doctrines/edit.html.erb
  9. 47
      app/views/doctrines/new.html.erb
  10. 5
      app/views/shared/_annotated_documents_search_results.html.erb
  11. 72
      app/views/shared/_annotation_modal_form.html.erb
  12. 71
      app/views/shared/_doctrine_form_annotation_modal_form.html.erb
  13. 38
      app/views/shared/_doctrine_form_annotations_view.html.erb
  14. 107
      app/views/shared/_doctrine_form_case_lists.html.erb
  15. 101
      app/views/shared/_doctrine_form_citing_documents_search_results.html.erb
  16. 23
      app/views/shared/_doctrine_form_default_case_lists.html.erb

22
app/components/doctrine_form_component/doctrine_form_component.html.erb

@ -3,22 +3,28 @@
<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, 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>
<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>
<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>
<% 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>
</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, nil, class: "form-control", placeholder: "Head note", required: true, data: { target: "doctrines.headnote" } %>
<%= 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>
@ -26,7 +32,7 @@
<div class="row">
<div class="col-sm-12">
<label for="subject-name" class="col-form-label">Content</label>
<%= rich_text_area_tag :content, nil, placeholder: "Doctrine Content", required: true, data: { target: "doctrines.content" } %>
<%= 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>

61
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -1,40 +1,33 @@
<div class="row-flex m-3 mt-0 doctrine-content-body">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<span> <b> <i> <%= headnote %> </i> </b> </span>
<p class="mb-0 clickable-link" href="<%= show_url %>"> <%= raw content.html_safe %> </p>
<p class="mb-0 clickable-link" href="<%= show_url %>"> <%= 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 %>
<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 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>
<% annotations.each do |annotation| %>
<p class="mb-2 ms-3 clickable-link" href="<%= show_url %>">
<% 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 %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= 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(', ') %>
</p>
<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>
<% annotations.each do |annotation| %>
<p class="mb-2 ms-3">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.clean_reference_number, ad_date_or_year].join(", ") %>
<% end %>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2 clickable-link" href="<%= show_url %>">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= 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(', ') %>
</p>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<% if annotation.editor_notes.present? %>
<div class="row ms-5 mb-2 clickable-link" href="<%= show_url %>">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<hr/>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>

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

@ -42,6 +42,7 @@ module Api
if @annotation.save
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
@annotation.index!
respond_with @annotation
else
render errors: @annotation.errors, status: 422
@ -66,6 +67,7 @@ module Api
@documents.each { |document| @annotation.add_document(document) } if @documents.present?
@annotation.index!
respond_with @annotation
else
render errors: @annotation.errors, status: 422

153
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()
@ -84,24 +85,31 @@ export default class extends ApplicationController {
}
})
} else {
$.post("/api/doctrines", $.extend({ jurisprudence_ids: [document_id] }, params), function(data, status) {
$.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>Submitted Successfully</b></span>" );
const contrim_alert = confirm("Do you want to create an Annotation?")
if (contrim_alert) {
$this.stimulate("DoctrinesReflex#render_annotation_form", document_id, data.id)
$('.toast').fadeOut(5000)
} else {
$(".btn-close-x").trigger("click")
location.pathname = "/documents/" + document_id + "/doctrines/" + data.id
$( ".toast-body" ).html( "<span><b>Doctrine was successfully save</b></span>" );
$('.toast').fadeOut(5000);
if (annotations_attributes.length > 0) {
$.each(annotations_attributes, function(index, annotation) {
$.post("/api/doctrines/" + doctrine.id + "/annotations", annotation, function(annotation, status) {
if(status === 'success') {
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Case Lists was successfully save</b></span>" );
$('.toast').fadeOut(5000);
if ((index + 1) === annotations_attributes.length) {
location.pathname = "/documents/" + document_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>" );
$('.toast').fadeOut(5000);
}
})
}
@ -120,41 +128,114 @@ export default class extends ApplicationController {
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);
}
})
}
}
saveAnnotation () {
var $form = $("#doctrineForm")
const params = { doctrine_id: $form.find("#doctrine_id").val(), document_id: $form.find("#document_id").val(),
document_ids: $form.find("#document_ids").val().split(","), content: $form.find("#document_title").val(),
phil_rep: $form.find("#phil_rep").val(), editor_notes: $form.find("#editor_notes").val(),
annomark_ids: $form.find("select[name='annomark_ids[]']").val() }
$.post("/api/doctrines/" + params.doctrine_id + "/annotations", params, function (result, status) {
if(status === "success") {
$(".btn-close-x").trigger("click");
$('.toast').addClass('bg-success').show();
$( ".toast-body" ).html( "<span><b>Submitted Successfully</b></span>" );
location.pathname = "/documents/" + $form.find("#current_document_id").val() + "/doctrines/" + params.doctrine_id
} else {
$(".btn-close-x").trigger("click")
$('.toast').addClass('bg-danger').show()
$( ".toast-body" ).html( "<span><b>Unexpected Error Problem Occurred</b></span>" )
}
})
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)
}
}
closeDoctrineAnnotationModalForm () {
var $current_document_id = $("#doctrineModal").find("#current_document_id").val()
var $doctrine_id = $("#doctrineModal").find("#doctrine_id").val()
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) {
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");
location.pathname = "/documents/" + $current_document_id + "/doctrines/" + $doctrine_id
$('.toast').addClass('bg-success').show();
$('.toast').fadeOut(5000);
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[]']").val(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").val(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)
}
}

12
app/javascript/controllers/document_controller.js

@ -12,6 +12,18 @@ export default class extends ApplicationController {
this.element.dataset["doctrineId"], this.element.dataset["currentDocumentId"])
}
searchDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.inputTarget.value, citation_finder: this.citation_finderTarget.value, page: 1 },
this.element.dataset["jurisprudenceId"])
}
paginateDoctrineFormCaseLists () {
this.stimulate("DocumentReflex#render_doctrine_form_case_lists",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"],
page: this.element.dataset["page"] }, this.element.dataset["jurisprudenceId"])
}
paginate () {
this.stimulate("DocumentReflex#render_case_lists_search_results",
{ q: this.element.dataset["q"], citation_finder: this.element.dataset["citation_finder"],

20
app/reflexes/doctrines_reflex.rb

@ -2,6 +2,7 @@
class DoctrinesReflex < ApplicationReflex
include DoctrineSearch
include DocumentSearch
def render_document_doctrines_index(search_params)
search = doctrine_search(search_params)
@ -19,4 +20,23 @@ class DoctrinesReflex < ApplicationReflex
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

7
app/reflexes/document_reflex.rb

@ -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, jurisprudence_id)
search = document_search(search_params.merge(sort_by: %i[reference_number_texts title_texts short_title_texts]))
@documents = search.results
opts = { jurisprudence_id: jurisprudence_id, 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

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

@ -1,12 +1,12 @@
<div class="container-fluid mt-2 p-0">
<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-header" style="border-bottom: 1px solid darkred;"> <h4 class="mb-0"> Edit Doctrine </h4> </div>
<div class="card-body" id="doctrineForm">
<%= render(DoctrineFormComponent.new(current_user: current_user, doctrine: @doctrine)) %>
<%= 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>
<button type="button" class="btn btn-danger ms-2" data-bs-dismiss="modal">Back</button>
<a class="btn btn-danger ms-2" href="<%= document_doctrine_path(params[:jurisprudence_id], @doctrine) %>">Back</a>
</div>
</div>
</div>

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

@ -3,7 +3,48 @@
<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" data-jurisprudence-id="<%= params[:jurisprudence_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 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? %>
@ -15,3 +56,9 @@
</div>
</div>
</div>
<% if @doctrine.new_record? %>
<div class="row">
<%= render partial: "/shared/doctrine_form_annotation_modal_form", locals: { jurisprudence_id: params[:jurisprudence_id] } %>
</div>
<% end %>

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

@ -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.strftime("%B %d, %Y") : 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.present? ? document.doc_date.strftime("%B %d, %Y") || document.year %>"
data-document-date="<%= date_or_year %>"
data-document-title="<%= document.short_title || document.title %>"
data-action="click->annotations#addAnnotatedDocument" >
Add

72
app/views/shared/_annotation_modal_form.html.erb

@ -1,72 +0,0 @@
<div class="modal-dialog modal-lg modal-dialog-scrollable" data-controller="doctrines selectize">
<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 :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_notes %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes" %>
</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-document-id="<%= document.id %>" data-doctrine-id="<%= doctrine_id %>"
data-action="click->doctrines#closeDoctrineAnnotationModalForm">Close</button>
</div>
</div>
</div>

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_notes %> </strong>
<%= rich_text_area_tag :editor_notes, nil, placeholder: "Editor Notes" %>
</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> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation[:editor_notes] %>
</div>
</div>
<hr/>
<% end %>
<% end %>

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

@ -0,0 +1,107 @@
<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-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-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-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-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-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-jurisprudence-id="<%= opts[:jurisprudence_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->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>
Loading…
Cancel
Save