Browse Source

Fix UI for `documents`

pull/71/head
alexdbondoc17 4 years ago
parent
commit
7e19d84e84
  1. 5
      app/components/document_index_table_component.rb
  2. 2
      app/components/document_index_table_component/document_index_table_component.html.erb
  3. 2
      app/views/documents/index.html.erb
  4. 2
      app/views/documents/search.html.erb
  5. 13
      app/views/documents/show.html.erb

5
app/components/document_index_table_component.rb

@ -20,4 +20,9 @@ class DocumentIndexTableComponent < BaseComponent
def doctrine_annotations_path(doctrine_id)
doctrine_annotations_path(doctrine_id: doctrine_id)
end
def show_url
return document_path(search_result.id, is_citator_tab: true) if opts[:is_citator_tab].present?
document_path(search_result.id, opts[:search_params])
end
end

2
app/components/document_index_table_component/document_index_table_component.html.erb

@ -1,4 +1,4 @@
<tr href="<%= document_path(search_result.id, is_citator_tab: true) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-link' : ''%>" target="_blank">
<tr href="<%= show_url %>" class="<%= opts[:is_citator_tab].present? ? 'clickable-tr' : 'clickable-link' %>" target="_blank">
<td> <%= clean_reference_number %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>

2
app/views/documents/index.html.erb

@ -20,7 +20,7 @@
</thead>
<tbody>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: {})) %>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %>
</tbody>
</table>
</div>

2
app/views/documents/search.html.erb

@ -14,7 +14,7 @@
<th class="bg-light"> Date </th>
</thead>
<tbody>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user)) %>
<%= render(DocumentIndexTableComponent.with_collection(@jurisprudences, current_user: current_user, opts: { search_params: @search_params.to_unsafe_h })) %>
</tbody>
</table>
</div>

13
app/views/documents/show.html.erb

@ -11,6 +11,9 @@
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<% if params[:is_document_view].blank? && params[:is_citator_tab].blank? %>
<a class="btn btn-danger" href="<%= documents_path(params.reject { |k, v| %i[action controller id].include?(k.to_sym) }.to_unsafe_h) %>"> Back </a>
<% end %>
</div>
<div class="col-lg-3 text-end">
<b>Date : </b>
@ -49,7 +52,7 @@
<button class="nav-link <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? '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<%= params[:is_document_view].to_s.eql?("true") ? 'active' : '' %>" id="documentMenuTab" data-bs-toggle="tab" data-bs-target="#documentTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Full Text</button>
<button class="nav-link <%= params[:is_document_view].to_s.eql?("true") ? 'active' : '' %>" id="documentMenuTab" 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 <%= params[:is_citator_tab].to_s.eql?("true") ? 'active' : '' %>" id="citatorMenuTab" data-bs-toggle="tab" data-bs-target="#citatonTabContent" type="button" role="tab" aria-controls="analysisTab" aria-selected="true">Citator</button>
@ -57,7 +60,7 @@
</ul>
<div class="tab-content" style="height: 550px;overflow: auto;">
<div class="tab-pane fade show active" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab">
<div class="tab-pane fade show <%= params[:is_document_view].blank? && params[:is_citator_tab].blank? ? 'active show' : '' %>" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab">
<div class="row">
<div class="d-flex justify-content-end" style="margin: 10px 0 0 -20px;">
<a class="btn btn-success" data-controller="doctrines" data-document-id="<%= @document.id %>" data-action="click->doctrines#renderForm" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Add Doctrine </a>
@ -72,13 +75,13 @@
</div>
</div>
<div class="tab-pane fade" id="documentTabContent" role="tabpanel">
<div class="tab-pane fade <%= params[:is_document_view].to_s.eql?("true") ? 'active show' : '' %>" id="documentTabContent" role="tabpanel">
<div class="container-sm mt-2">
<%= raw @document.content.html_safe%>
</div>
</div>
<div class="tab-pane fade cited-table-body" id="citatonTabContent" role="tabpanel">
<div class="tab-pane fade cited-table-body <%= params[:is_citator_tab].to_s.eql?("true") ? 'active show' : '' %>" id="citatonTabContent" role="tabpanel">
<div class="d-flex align-items-baseline">
<div class="col-md-6 mt-3 ps-3"> <h4> Cited In </h4> </div>
<div class="col-md-6"> <%= render PaginationComponent.new(data: @cited_in_documents, opts: { is_cited_in_doc: true}) %> </div>
@ -91,7 +94,7 @@
</thead>
<tbody>
<%= render(DocumentIndexTableComponent.with_collection(Cdao::Jurisprudence.all, current_user: current_user)) %>
<%= render(DocumentIndexTableComponent.with_collection(@cited_in_documents, current_user: current_user, opts: { search_params: params.reject { |k, v| %i[action controller id].include?(k.to_sym) }, is_document_view: false, is_citator_tab: true })) %>
</tbody>
</table>
</div>

Loading…
Cancel
Save