15 changed files with 93 additions and 39 deletions
@ -0,0 +1,24 @@
|
||||
class DoctrineIndexTableComponent < BaseComponent |
||||
attr_reader :search_results, :opts |
||||
|
||||
def initialize(current_user:, search_results:, opts: {}) |
||||
@search_results = search_results |
||||
@opts = opts |
||||
end |
||||
|
||||
def document_reference_number(document) |
||||
document.reference_number |
||||
end |
||||
|
||||
def document_title(document) |
||||
return document.short_title if document.short_title.present? |
||||
|
||||
document.title |
||||
end |
||||
|
||||
def date_or_year(document) |
||||
return document.docdate.strftime("%m/%d/%Y") if document.docdate.present? |
||||
|
||||
document.year |
||||
end |
||||
end |
||||
@ -0,0 +1,19 @@
|
||||
<table class="table table-striped table-hover mb-0"> |
||||
<thead> |
||||
<th class="bg-light"> Reference Number </th> |
||||
<th class="bg-light"> Title </th> |
||||
<th class="bg-light"> Date </th> |
||||
<th class="bg-light"> PhilRep </th> |
||||
</thead> |
||||
|
||||
<tbody> |
||||
<% search_results.each do |search_result| %> |
||||
<tr href="<%= document_path(search_result.document_id) %>" class="clickable-tr"> |
||||
<td> <%= document_reference_number(search_result.document) %> </td> |
||||
<td> <%= document_title(search_result.document) %> </td> |
||||
<td> <%= date_or_year(search_result.document) %> </td> |
||||
<td> <%= search_result.annotations.map(&:phil_rep).join(", ") %> </td> |
||||
</tr> |
||||
<% end %> |
||||
</tbody> |
||||
</table> |
||||
@ -1,4 +1,11 @@
|
||||
<div class="card container-sm mt-1 p-0"> |
||||
<div class="container m-2"> <%= render PaginationComponent.new(data: @doctrines) %> </div> |
||||
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_doctrines_index: true, subject_ids: params[:subject_ids] })) %> |
||||
|
||||
<% if params[:is_index_table].to_s.eql?("true") %> |
||||
<div class="card-body col-sm-12 tableFixHead p-0 mt-1"> |
||||
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines)) %> |
||||
</div> |
||||
<% else %> |
||||
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_doctrines_index: true, subject_ids: params[:subject_ids] })) %> |
||||
<% end %> |
||||
</div> |
||||
|
||||
Loading…
Reference in new issue