9 changed files with 167 additions and 1 deletions
@ -0,0 +1,17 @@
|
||||
class DocumentIndexTableComponent < BaseComponent |
||||
with_collection_parameter :search_result |
||||
attr_reader :search_result, :opts |
||||
|
||||
def initialize(search_result:, current_user:) |
||||
@search_result = search_result |
||||
end |
||||
|
||||
delegate :reference_number, to: :search_result |
||||
delegate :title, to: :search_result |
||||
|
||||
def date_or_year |
||||
return search_result.docdate.strftime("%m/%d/%Y") if search_result.docdate.present? |
||||
|
||||
search_result.year |
||||
end |
||||
end |
||||
@ -0,0 +1,6 @@
|
||||
<tr href="<%= document_path(search_result) %>" class="clickable-tr"> |
||||
<td> <%= reference_number %> </td> |
||||
<td> <%= title %> </td> |
||||
<td> <%= date_or_year %> </td> |
||||
<td></td> |
||||
</tr> |
||||
@ -0,0 +1,35 @@
|
||||
class DocumentsController < ApplicationController |
||||
load_and_authorize_resource :document, class: "Cdao::Jurisprudence" |
||||
def index |
||||
attrs = %i[id reference_number title docdate ponente edited short_title year].freeze |
||||
|
||||
fulltext_fields = %i[reference_number title short_title].freeze |
||||
|
||||
search = Cdao::Jurisprudence.search do |
||||
fulltext search_params[:q], fields: fulltext_fields if search_params[:q].present? |
||||
|
||||
fulltext_fields.each do |field| |
||||
fulltext search_params[field], fields: [field] if search_params[field].present? |
||||
end |
||||
|
||||
order_by :doc_date |
||||
order_by :year |
||||
|
||||
paginate page: params[:page] || 1, per_page: params[:per_page] || 20 |
||||
end |
||||
|
||||
@jurisprudences = search.results |
||||
|
||||
|
||||
respond_to do |format| |
||||
format.html |
||||
end |
||||
end |
||||
|
||||
def show; end |
||||
|
||||
private |
||||
def search_params |
||||
params.permit(:reference_number, :title, :short_title, :q, :page, :per_page) |
||||
end |
||||
end |
||||
@ -1,2 +1,18 @@
|
||||
@import "~bootstrap/scss/bootstrap"; |
||||
@import "./application/sidenav"; |
||||
|
||||
.tableFixHead { |
||||
overflow: auto; |
||||
height: 680px; |
||||
width: 240px; |
||||
} |
||||
|
||||
.tableFixHead thead th { |
||||
position: sticky; |
||||
top: 0; |
||||
} |
||||
|
||||
.tableFixHead tbody th { |
||||
position: sticky; |
||||
left: 0; |
||||
} |
||||
|
||||
@ -0,0 +1,32 @@
|
||||
<div class="card mt-2 g-3"> |
||||
<div class="card-header mt-1 col-sm-12"> |
||||
<%= form_tag(documents_path, method: :get) do %> |
||||
<div class="row"> |
||||
<div class="col-sm-8 p-2"> |
||||
<div class="form-floating"> |
||||
<%= text_field_tag :q, params[:q], class: "form-control" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="col-sm-4 p-2"> |
||||
<%= submit_tag "Search", class: "btn btn-primary text-dark" %> |
||||
<button class="btn btn-info"> Advanced Search </button> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
|
||||
<div class="card-body col-sm-12 tableFixHead p-0 mt-1"> |
||||
<table class="table table-striped table-hover mb-0"> |
||||
<thead> |
||||
<th class="bg-light"> Reference No. </th> |
||||
<th class="bg-light"> Title </th> |
||||
<th class="bg-light"> Date </th> |
||||
<th class="bg-light"> Subject </th> |
||||
</thead> |
||||
<tbody> |
||||
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user)) %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,52 @@
|
||||
<div class="card mt-1 g-3"> |
||||
<div class="card-header mt-1 mb-2 col-sm-12"> |
||||
<table class="table table-borderless"> |
||||
<tbody> |
||||
<tr> |
||||
<td class="text-start" style="width: 160px;"> Reference Number: </td> |
||||
<td class="text-start"> <strong> <%= @document.reference_number %> </strong> </td> |
||||
<td class="text-end" style="width: 50px;" > Date: </td> |
||||
<td class="text-end" style="width: 160px;"> <strong> <%= @document.docdate.present? ? @document.docdate.strftime("%m/%d/%Y") : @document.year %> </strong> </td> |
||||
</tr> |
||||
|
||||
<tr> |
||||
<td style="width: 160px;" class="text-start"> Title: </td> |
||||
<td colspan="3" class="text-start"> <strong> <%= @document.title %> </strong> </td> |
||||
</tr> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
|
||||
|
||||
<div class="card-body"> |
||||
<ul class="nav nav-tabs" id="menuTab" role="tablist"> |
||||
<li class="nav-item" role="presentation"> |
||||
<button class="nav-link active" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#analysisTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Analysis</button> |
||||
</li> |
||||
<li class="nav-item" role="presentation"> |
||||
<button class="nav-link" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button> |
||||
</li> |
||||
<li class="nav-item" role="presentation"> |
||||
<button class="nav-link" id="analysisMenuTab" data-bs-toggle="tab" data-bs-target="#ciatatonTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Citator</button> |
||||
</li> |
||||
</ul> |
||||
|
||||
<div class="tab-content" id="menuTabContent"> |
||||
<div class="tab-pane fade show active" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab"> |
||||
<div class="container-fluid"> |
||||
<div class="justify-content-end"> |
||||
<a> <i class="fas fa-plus-circle"></i> </a> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="tab-pane fade" id="documentTabContent" role="tabpanel"> |
||||
<span> Full Text </span> |
||||
</div> |
||||
|
||||
<div class="tab-pane fade" id="ciatatonTabContent" role="tabpanel"> |
||||
<span> Citator </span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
Loading…
Reference in new issue