11 changed files with 206 additions and 2 deletions
@ -0,0 +1,47 @@
|
||||
class ReportsSearchResultsComponent < BaseComponent |
||||
with_collection_parameter :search_result |
||||
attr_reader :search_result, :opts |
||||
|
||||
def initialize(search_result:, current_user:, opts: {}) |
||||
@search_result = search_result |
||||
@opts = opts |
||||
end |
||||
|
||||
delegate :id, to: :search_result |
||||
delegate :headnote, to: :search_result |
||||
delegate :subject_ids, to: :search_result |
||||
delegate :content, to: :search_result |
||||
delegate :annotations, to: :search_result |
||||
delegate :subjects, to: :search_result |
||||
delegate :doctrine_jurisprudences, to: :search_result |
||||
|
||||
def annotation_form_url |
||||
doctrine_annotations_path(doctrine_id: id) |
||||
end |
||||
|
||||
def subject_names |
||||
"(No Subjects Provided)" |
||||
end |
||||
|
||||
def jurisprudence |
||||
return nil if doctrine_jurisprudences.blank? |
||||
|
||||
doctrine_jurisprudences.first.jurisprudence |
||||
end |
||||
|
||||
def document_title(annotation) |
||||
return annotation.document.short_title if annotation.document.short_title.present? |
||||
|
||||
annotation.document.title |
||||
end |
||||
|
||||
def date_or_year(annotation) |
||||
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present? |
||||
|
||||
annotation.document.year |
||||
end |
||||
|
||||
def render? |
||||
opts[:is_render].present? |
||||
end |
||||
end |
||||
@ -0,0 +1,40 @@
|
||||
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id) : doctrine_path(id)%>"> |
||||
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>"> |
||||
<p class="mb-0"> <%= raw content.html_safe %> </p> |
||||
|
||||
|
||||
<div class="container-fluid p-0"> |
||||
<% annotations.each do |annotation| %> |
||||
<% document_title = annotation.document.short_title || annotation.document.title %> |
||||
<% date_or_year = annotation.document.docdate.present? ? annotation.document.docdate : annotation.document.year %> |
||||
<h5 style="color: darkred;"> <%= [document_title, annotation.document.reference_number, date_or_year].join(", ") %> </h5> |
||||
|
||||
<p class="mb-0 ms-5"> |
||||
<% annotated_documents_title = [] %> |
||||
<% annotation.documents.each do |annotated_document| %> |
||||
<% ad_title = annotated_document.short_title || annotated_document.title %> |
||||
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %> |
||||
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %> |
||||
<% end %> |
||||
|
||||
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong> |
||||
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %> |
||||
</p> |
||||
|
||||
<% if annotation.editor_notes.present? %> |
||||
<div class="row ms-5"> |
||||
<div class="col-sm-2 p-0" style="width: 105px;"> |
||||
<span> Editors Note: </span> |
||||
</div> |
||||
|
||||
<div class="col-sm-10 ps-0"> |
||||
<%= raw annotation.editor_notes %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
|
||||
<hr/> |
||||
</div> |
||||
@ -0,0 +1,17 @@
|
||||
class ReportsController < ApplicationController |
||||
include DoctrineSearch |
||||
|
||||
def index |
||||
authorize! :display, Doctrine |
||||
|
||||
search = doctrine_search(search_params) |
||||
@results = search.results |
||||
@users = User.all |
||||
end |
||||
|
||||
private |
||||
|
||||
def search_params |
||||
params.permit(:created_at, :q, :page, :per_page, exclude_ids: [], subject_ids: [], user_ids: []) |
||||
end |
||||
end |
||||
@ -0,0 +1,17 @@
|
||||
import ApplicationController from './application_controller' |
||||
export default class extends ApplicationController { |
||||
static targets = ["q", "headnote", "date_created"] |
||||
|
||||
connect () { |
||||
super.connect() |
||||
} |
||||
|
||||
search () { |
||||
var $search_box = $('.advanced-search-box'),
|
||||
search_params = { q: this.qTarget.value, headnote: this.headnoteTarget.value,
|
||||
subject_ids: $search_box.find("select[name='subject_ids[]']").val(), |
||||
user_ids: $search_box.find("select[name='user_ids[]']").val() } |
||||
|
||||
this.stimulate("ReportsReflex#render_search_results", search_params) |
||||
} |
||||
} |
||||
@ -0,0 +1,10 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
class ReportsReflex < ApplicationReflex |
||||
include DoctrineSearch |
||||
|
||||
def render_search_results(search_params) |
||||
search = doctrine_search(search_params.reject { |k, v| v.blank? }) |
||||
morph "div#searchResultsTable", render(partial: "search_results_table", locals: { search: search, current_user: current_user }) |
||||
end |
||||
end |
||||
@ -0,0 +1,12 @@
|
||||
<% if search.results.present? %> |
||||
<%= render(ReportsSearchResultsComponent.with_collection(search.results, current_user: current_user, opts: { is_render: true })) %> |
||||
<% else %> |
||||
<div class="d-flex justify-content-center flex-column no-search-body"> |
||||
<div class="text-center "> |
||||
<%= image_pack_tag 'application/search-icon.png', class: "search-doc-icon"%> |
||||
</div> |
||||
<div class="text-center label-no-search" > |
||||
No Results Found |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
@ -0,0 +1,41 @@
|
||||
<div class="container-fluid row p-0 m-0"> |
||||
<div class="container col-xs-12 col-sm-12 col-md-3 col-lg-3 col-xl-3" > |
||||
<div class="advanced-search-box"> |
||||
<%= form_with(url: reports_path, method: :get) do %> |
||||
<div class="mb-3"> |
||||
<%= text_field_tag :q, params[:q], placeholder: 'Full text search', class: "form-control" %> |
||||
</div> |
||||
<hr class="simple"> |
||||
<div class="mb-3"> |
||||
<label for="exampleFormControlInput1" class="form-label text-white"> Subjects </label> |
||||
<select class="form-control subject-ids-selectize p-0" name="subject_ids[]" id="subject_ids_" multiple="true"> </select> |
||||
</div> |
||||
<hr class="simple"> |
||||
<div class="mb-3"> |
||||
<label for="exampleFormControlInput1" class="form-label text-white"> Users </label> |
||||
<%= select_tag :user_ids, options_from_collection_for_select(@users, :id, :name, params[:user_ids]), class: "form-control default-selectize p-0", multiple: true %> |
||||
</div> |
||||
|
||||
<div class="d-flex justify-content-end mt-5"> |
||||
<button type="button" class="btn btn-success me-2 mb-3">Refresh</button> |
||||
<button type="submit" class="btn btn-danger mb-3">Search</button> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
<div class="container col-xs-12 col-sm-12 col-md-9 col-lg-9 col-xl-9" id="searchResultsTable"> |
||||
<div class="m-2 ps-0"> <%= render PaginationComponent.new(data: @results, opts: { is_subject_breadcrums: true, subject_ids: params[:subject_ids] }) %> </div> |
||||
<% if @results.present? %> |
||||
<%= render(ReportsSearchResultsComponent.with_collection(@results, current_user: current_user, opts: { is_render: true })) %> |
||||
<% else %> |
||||
<div class="d-flex justify-content-center flex-column no-search-body"> |
||||
<div class="text-center "> |
||||
<%= image_pack_tag 'application/search-icon.png', class: "search-doc-icon"%> |
||||
</div> |
||||
<div class="text-center label-no-search" > |
||||
No Results Found |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,15 @@
|
||||
<nav> |
||||
<ul class="pagination"> |
||||
<li class="page-item"><a href="#" class="page-link" data-reflex="click->TabularReflex#paginate" data-page="<%= prev_page %>">←</a></li> |
||||
<% @pagy.series.each do |item| %> |
||||
<% if item == :gap %> |
||||
<li class="page-item disabled"><a class="page-link">...</a></li> |
||||
<% else %> |
||||
<li class="page-item <%= "active" if item.is_a?(String) %>"> |
||||
<a href="#" class="page-link" data-reflex="click->TabularReflex#paginate" data-page="<%= item %>"><%= item %></a> |
||||
</li> |
||||
<% end %> |
||||
<% end %> |
||||
<li class="page-item"><a href="#" class="page-link" data-reflex="click->TabularReflex#paginate" data-page="<%= next_page %>">→</a></li> |
||||
</ul> |
||||
</nav> |
||||
Loading…
Reference in new issue