Browse Source

Merge pull request #71 from lexintegritastech/improve-main-ui

Fix UI for `documents`
pull/72/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
3c3fb7453f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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. 11
      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>

11
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>
@ -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