Browse Source

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

Improve UI for `subject_indexes#show` and `doctrines#search`
pull/83/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
4e00821e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 46
      app/components/doctrine_index_component.rb
  2. 45
      app/components/doctrine_index_component/doctrine_index_component.html.erb
  3. 4
      app/views/doctrines/search.html.erb
  4. 1
      app/views/subject_indexes/show.html.erb

46
app/components/doctrine_index_component.rb

@ -0,0 +1,46 @@
class DoctrineIndexComponent < BaseComponent
with_collection_parameter :doctrine
attr_reader :doctrine, :opts
def initialize(doctrine:, current_user:, opts: {})
@doctrine = doctrine
@opts = opts
end
delegate :id, to: :doctrine
delegate :subject_ids, to: :doctrine
delegate :content, to: :doctrine
delegate :annotations, to: :doctrine
delegate :subjects, to: :doctrine
delegate :doctrine_jurisprudences, to: :doctrine
def annotation_form_url
doctrine_annotations_path(doctrine_id: id)
end
def subject_names
"(No Subjects Provided)"
end
def jurisprudence
return nil if doctrine_jurisprudences.blank?
doctrine_jurisprudences.first.jurisprudence
end
def document_title(annotation)
return annotation.document.short_title if annotation.document.short_title.present?
annotation.document.title
end
def date_or_year(annotation)
return annotation.document.docdate.to_date.strftime("%B %d, %Y") if annotation.document.docdate.present?
annotation.document.year
end
def render?
doctrine.present? && doctrine.persisted?
end
end

45
app/components/doctrine_index_component/doctrine_index_component.html.erb

@ -0,0 +1,45 @@
<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, section_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="container-sm <%= opts[:is_subjects_index].present? ? 'm-0 ps-0' : '' %>">
<p class="mb-0"> <%= raw content.html_safe %> </p>
<div class="container-fluid p-0">
<% document_title = jurisprudence.short_title || jurisprudence.title %>
<% date_or_year = jurisprudence.docdate.present? ? jurisprudence.docdate.to_date.strftime("%B %d, %Y") : jurisprudence.year %>
<h5 style="color: darkred;"> <%= [document_title, jurisprudence.reference_number, date_or_year].join(", ") %> </h5>
<% annotations.each do |annotation| %>
<p class="mb-0 ms-3">
<% annotated_documents_title = [] %>
<% annotation.documents.each do |annotated_document| %>
<% ad_title = annotated_document.short_title || annotated_document.title %>
<% ad_date_or_year = annotated_document.docdate.present? ? annotated_document.docdate.strftime("%B %d, %Y") : annotated_document.year %>
<% annotated_documents_title << [" citing #{ad_title}", annotated_document.reference_number, ad_date_or_year].join(", ") %>
<% end %>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [document_title(annotation), annotation.document.reference_number, date_or_year(annotation), annotation.phil_rep, annotated_documents_title].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>
<div class="row ms-5">
<div class="col-sm-2 p-0" style="width: 105px;">
<span> Editors Note: </span>
</div>
<div class="col-sm-10 ps-0">
<%= raw annotation.editor_notes %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<hr/>
</div>

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

@ -3,9 +3,9 @@
<hr class="mt-0"/> <hr class="mt-0"/>
<% if params[:is_index_table].to_s.eql?("true") %> <% if params[:is_index_table].to_s.eql?("true") %>
<div class="card-body col-sm-12 tableFixHead p-0 mt-1"> <div class="card-body col-sm-12 tableFixHead p-0 mt-1">
<%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines)) %> <%= render(DoctrineIndexTableComponent.new(current_user: current_user, search_results: @doctrines, opts: { is_index_table: params[:is_index_table].to_s.eql?("true") })) %>
</div> </div>
<% else %> <% else %>
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_doctrines_index: true, subject_ids: params[:subject_ids] })) %> <%= render(DoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { subject_ids: params[:subject_ids] })) %>
<% end %> <% end %>
</div> </div>

1
app/views/subject_indexes/show.html.erb

@ -24,6 +24,7 @@
</div> </div>
<div class="col-sm-2 d-flex justify-content-end align-items-center pe-0"> <div class="col-sm-2 d-flex justify-content-end align-items-center pe-0">
<a class="me-3" href="<%= subject_indexes_path %>"> <i class="fas fa-angle-double-left" style="font-size: 20px;color: darkred;" data-bs-toggle="tooltip" data-bs-placement="right" title="Back to index"></i> </a>
<a class="btn btn-secondary me-3 btn-sm mb-1" href="<%= edit_subject_index_path(@subject_index) %>"> Edit </a> <a class="btn btn-secondary me-3 btn-sm mb-1" href="<%= edit_subject_index_path(@subject_index) %>"> Edit </a>
<% if !@subject_index.has_children? %> <% if !@subject_index.has_children? %>

Loading…
Cancel
Save