Browse Source

Fix component for `doctrines#index`

pull/91/head
alexdbondoc17 4 years ago committed by Angel Aviel Domaoan
parent
commit
1948e49392
  1. 6
      app/components/doctrine_index_component.rb
  2. 10
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  3. 4
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  4. 4
      app/views/doctrines/search.html.erb

6
app/components/doctrine_index_component.rb

@ -40,6 +40,12 @@ class DoctrineIndexComponent < BaseComponent
annotation.document.year
end
def show_url
return document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) if jurisprudence.present?
doctrine_path(id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?))
end
def render?
doctrine.present? && doctrine.persisted?
end

10
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -1,10 +1,4 @@
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= jurisprudence.present? ? document_doctrine_path(jurisprudence.id, id, is_index_table: false, subject_ids: opts[:subject_ids].reject(&:blank?)) : doctrine_path(id, is_index_table: false)%>">
<% if opts[:subject_ids].reject(&:blank?).present? %>
<h5 style="color: darkred;"> <%= subjects.where(id: opts[:subject_ids].map(&:to_i)).map(&:lineage_name).join("") %> </h5>
<% else %>
<h5> (No Subjects Provided) </h5>
<% end %>
<div class="row-flex m-3 mt-0 doctrine-content-body clickable-link" href="<%= show_url %>">
<div class="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
@ -27,7 +21,7 @@
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>

4
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -24,7 +24,7 @@
<% end %>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-3">
<p class="mb-0 ms-3 mb-2">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
@ -37,7 +37,7 @@
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="row ms-5 mb-2">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>

4
app/views/doctrines/search.html.erb

@ -3,9 +3,9 @@
<hr class="mt-0"/>
<% 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, opts: { is_index_table: params[:is_index_table].to_s.eql?("true") })) %>
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines, opts: { is_index_table: true, subject_ids: params[:subject_ids].map(&:to_i) })) %>
</div>
<% else %>
<%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { subject_ids: params[:subject_ids] })) %>
<%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_index_table: false, subject_ids: params[:subject_ids].map(&:to_i) })) %>
<% end %>
</div>

Loading…
Cancel
Save