25 changed files with 477 additions and 52 deletions
@ -0,0 +1,17 @@
|
||||
module AnnotationSearch |
||||
def annotation_search(search_params) |
||||
fulltext_fields = %i[phil_rep].freeze |
||||
|
||||
search = ::Annotation.search do |
||||
fulltext search_params[:q], fields: fulltext_fields if search_params[:q].present? |
||||
|
||||
%i[doctrine_id document_id].each do |field| |
||||
with field, search_params[field] if search_params[field].present? |
||||
end |
||||
|
||||
paginate page: search_params[:page] || 1, per_page: search_params[:per_page] || 20 |
||||
end |
||||
|
||||
search |
||||
end |
||||
end |
||||
@ -1,7 +1,12 @@
|
||||
class Document::DoctrinesController < ApplicationController |
||||
include AnnotationSearch |
||||
|
||||
load_and_authorize_resource :document, class: "Cdao::Jurisprudence" |
||||
load_and_authorize_resource :doctrine, class: "Doctrine", through: :document |
||||
|
||||
|
||||
def show; end |
||||
def show |
||||
search = annotation_search(params.permit(:page, :per_page)) |
||||
@annotations = search.results |
||||
end |
||||
end |
||||
|
||||
@ -0,0 +1,2 @@
|
||||
json.(@annotation, *%i[id doctrine_id document_id phil_rep editor_notes annomark_ids citing_document_ids]) |
||||
json.doctrine_jurisprudence @annotation.doctrine.doctrine_jurisprudences.first.jurisprudence |
||||
@ -0,0 +1,2 @@
|
||||
json.(@annotation, *%i[id doctrine_id document_id phil_rep editor_notes annomark_ids citing_document_ids]) |
||||
json.doctrine_jurisprudence @annotation.doctrine.doctrine_jurisprudences.first.jurisprudence |
||||
@ -0,0 +1,2 @@
|
||||
json.(@annotation, *%i[id doctrine_id document_id phil_rep editor_notes annomark_ids citing_document_ids]) |
||||
json.doctrine_jurisprudence @annotation.doctrine.doctrine_jurisprudences.first.jurisprudence |
||||
@ -0,0 +1,3 @@
|
||||
json.array!(@annotations) do |annotation| |
||||
json.extract! annotation, *%i[id doctrine_id document_id phil_rep editor_notes annomark_ids created_at updated_at] |
||||
end |
||||
@ -0,0 +1,3 @@
|
||||
json.array!(@annotations) do |annotation| |
||||
json.extract! annotation, *%i[id doctrine_id document_id phil_rep editor_notes annomark_ids created_at updated_at] |
||||
end |
||||
@ -0,0 +1,96 @@
|
||||
<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" } %> |
||||
</div> |
||||
<div class="col-sm-1 p-2"> |
||||
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->annotations#searchDocuments" } %> |
||||
</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="annotations" data-q="<%= opts[:q] %>" data-page="<%= 1 %>" data-action="click->annotations#paginateDocuments"> |
||||
<i class="fas fa-angle-double-left"></i> |
||||
</a> |
||||
</span> |
||||
|
||||
<span class="page-item prev"> |
||||
<a class="page-link" data-controller="annotations" data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i - 1 %>" data-action="click->annotations#paginateDocuments"> |
||||
<i class="fas fa-angle-left"></i> |
||||
</a> |
||||
</span> |
||||
<% end %> |
||||
|
||||
<% documents.total_pages.times do |page| -%> |
||||
<% 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="annotations" data-q="<%= opts[:q] %>" data-page="<%= page + 1 %>" |
||||
data-action="click->annotations#paginateDocuments"> <%= page + 1 %> </a> |
||||
</span> |
||||
<% end %> |
||||
<% end -%> |
||||
|
||||
<% unless documents.last_page? %> |
||||
<span class="page-item next"> |
||||
<a class="page-link" data-controller="annotations" data-q="<%= opts[:q] %>" |
||||
data-page="<%= opts[:current_page].to_i + 1 %>" data-action="click->annotations#paginateDocuments"> |
||||
<i class="fas fa-angle-right"></i> |
||||
</a> |
||||
</span> |
||||
|
||||
<span class="page-item last"> |
||||
<a class="page-link" data-controller="annotations" data-q="<%= opts[:q] %>" |
||||
data-page="<%= documents.total_pages %>" data-action="click->annotations#paginateDocuments"> |
||||
<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> <%= document.clean_reference_number %> </td> |
||||
<td> <%= document.short_title || document.title %> </td> |
||||
<td> <%= document.doc_date.present? ? document.doc_date : document.year %> </td> |
||||
<td> |
||||
<a class="btn btn-success" data-controller="annotations" data-document-id="<%= document.id %>" |
||||
data-document-reference-number="<%= document.clean_reference_number %>" |
||||
data-document-date="<%= document.doc_date || document.year %>" |
||||
data-document-title="<%= document.short_title || document.title %>" |
||||
data-action="click->annotations#addAnnotatedDocument" > |
||||
Add |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
@ -0,0 +1,42 @@
|
||||
<%= render(partial: "/shared/annotations_pagination", locals: { annotations: annotations, opts: opts }) %> |
||||
<% 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 %> |
||||
<% 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 %> |
||||
<% 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> |
||||
|
||||
<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="<%= annotation.doctrine_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="<%= annotation.doctrine_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="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 %> |
||||
@ -0,0 +1,58 @@
|
||||
<header class="header bg-white b-b clearfix m-2"> |
||||
<div class="row m-t-sm align-items-end pagination-body"> |
||||
<div class="<%= annotations.present? ? "col-md-6 mb-0 " : "col-md-12 mb-0"%> "> |
||||
<small style="color: darkred"> |
||||
<%= page_entries_info annotations, entry_name: 'records' if annotations.present? %> |
||||
</small> |
||||
</div> |
||||
<div class="<%= annotations.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 annotations.first_page? %> |
||||
<span class="page-item first"> |
||||
<a class="page-link" data-controller="annotations" data-page="<%= 1 %>" data-action="click->annotations#paginate"> |
||||
<i class="fas fa-angle-double-left"></i> |
||||
</a> |
||||
</span> |
||||
|
||||
<span class="page-item prev"> |
||||
<a class="page-link" data-controller="annotations" data-page="<%= opts[:current_page].to_i - 1 %>" |
||||
data-action="click->annotations#paginate"> |
||||
<i class="fas fa-angle-left"></i> |
||||
</a> |
||||
</span> |
||||
<% end %> |
||||
|
||||
<% annotations.total_pages.times do |page| -%> |
||||
<% 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="annotations" data-page="<%= page + 1 %>" |
||||
data-action="click->annotations#paginate"> <%= page + 1 %> </a> |
||||
</span> |
||||
<% end %> |
||||
<% end -%> |
||||
|
||||
<% unless annotations.last_page? %> |
||||
<span class="page-item next"> |
||||
<a class="page-link" data-controller="annotations" |
||||
data-page="<%= opts[:current_page].to_i + 1 %>" |
||||
data-action="click->annotations#paginate"> |
||||
<i class="fas fa-angle-right"></i> |
||||
</a> |
||||
</span> |
||||
|
||||
<span class="page-item last"> |
||||
<a class="page-link" data-controller="annotations" |
||||
data-page="<%= annotations.total_pages %>" |
||||
data-action="click->annotations#paginate"> |
||||
<i class="fas fa-angle-double-right"></i> |
||||
</a> |
||||
</span> |
||||
<% end %> |
||||
</nav> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</header> |
||||
@ -0,0 +1,104 @@
|
||||
<div class="row" data-controller="document"> |
||||
<div class="col-sm-11 p-2"> |
||||
<%= text_field_tag :q, opts[:q], class: "form-control", placeholder: "Search GR Number", |
||||
data: { target: "document.input" } %> |
||||
</div> |
||||
<div class="col-sm-1 p-2"> |
||||
<%= button_tag "Search", class: "btn btn-success", data: { action: "click->document#search" } %> |
||||
</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-doctrine-id="<%= opts[:doctrine_id] %>" |
||||
data-q="<%= opts[:q] %>" data-page="<%= 1 %>" data-action="click->document#paginate"> |
||||
<i class="fas fa-angle-double-left"></i> |
||||
</a> |
||||
</span> |
||||
|
||||
<span class="page-item prev"> |
||||
<a class="page-link" data-controller="document" data-doctrine-id="<%= opts[:doctrine_id] %>" |
||||
data-q="<%= opts[:q] %>" data-page="<%= opts[:current_page].to_i - 1 %>" |
||||
data-action="click->document#paginate"> |
||||
<i class="fas fa-angle-left"></i> |
||||
</a> |
||||
</span> |
||||
<% end %> |
||||
|
||||
<% documents.total_pages.times do |page| -%> |
||||
<% 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-doctrine-id="<%= opts[:doctrine_id] %>" |
||||
data-q="<%= opts[:q] %>" data-page="<%= page + 1 %>" data-action="click->document#paginate"> |
||||
<%= page + 1 %> |
||||
</a> |
||||
</span> |
||||
<% end %> |
||||
<% end -%> |
||||
|
||||
<% 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"> |
||||
<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"> |
||||
<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> <%= document.clean_reference_number %> </td> |
||||
<td> <%= document.short_title || document.title %> </td> |
||||
<td> <%= document.doc_date.present? ? document.doc_date : document.year %> </td> |
||||
<td> |
||||
<% date_or_year = document.doc_date || 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> |
||||
</td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
Loading…
Reference in new issue