Browse Source

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

Implement UI for `decisions` and `Cited Ins`
pull/16/head
Angel Aviel Domaoan 4 years ago committed by GitHub
parent
commit
9ff2383d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/components/annotation_marks_modal_form_component.rb
  2. 29
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  3. 1
      app/components/document_index_table_component.rb
  4. 4
      app/components/document_index_table_component/document_index_table_component.html.erb
  5. 12
      app/components/documents_years_component.rb
  6. 13
      app/components/documents_years_component/documents_years_component.html.erb
  7. 4
      app/controllers/decisions_controller.rb
  8. 2
      app/controllers/documents_controller.rb
  9. 20
      app/javascript/controllers/document_controller.js
  10. 1
      app/reflexes/application_reflex.rb
  11. 12
      app/reflexes/document_reflex.rb
  12. 6
      app/views/decisions/index.html.erb
  13. 1
      app/views/doctrines/index.html.erb
  14. 2
      app/views/documents/index.html.erb
  15. 4
      app/views/documents/search.html.erb
  16. 26
      app/views/documents/show.html.erb

2
app/components/annotation_marks_modal_form_component.rb

@ -14,7 +14,7 @@ class AnnotationMarksModalFormComponent < BaseComponent
end
def document_title
[document.title, document.reference_number, document_date_or_year].join(", ")
[document.title, document.reference_number, document_date_or_year].reject(&:blank?).join(", ")
end
def render?

29
app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb

@ -10,14 +10,39 @@
<div class="row">
<div class="col-sm-12 p-2" data-controller="select2">
<%= label_tag :annotation_marks %>
<%= hidden_field_tag :document_id, opts[:document_id] %>
<%= hidden_field_tag :document_id, document.id %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all, :id, :name, annotation.annomark_ids), class: "form-select annomark-ids-select2", multiple: true, prompt: "Please select" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<%= label_tag :document_title %>
<%= text_area_tag :document_title, document_date_or_year, class: "form-control" %>
<%= text_area_tag :document_title, document_title, class: "form-control" %>
</div>
</div>
<div class="row">
<div class="row" data-controller="document">
<div class="col-sm-10 p-2">
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number", data: { target: "document.input" } %>
</div>
<div class="col-sm-1 p-2">
<%= button_tag "Search", class: "btn btn-primary", data: { action: "click->document#modalDocumentSearch" } %>
</div>
</div>
<div class="row tab">
<table class="table table-striped table-hover mb-0">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Date </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> </th>
</thead>
<tbody id="modalDocumentSearchTable"> </tbody>
</table>
</div>
</div>

1
app/components/document_index_table_component.rb

@ -9,6 +9,7 @@ class DocumentIndexTableComponent < BaseComponent
delegate :reference_number, to: :search_result
delegate :title, to: :search_result
delegate :short_title, to: :search_result
def date_or_year
return search_result.docdate.strftime("%m/%d/%Y") if search_result.docdate.present?

4
app/components/document_index_table_component/document_index_table_component.html.erb

@ -1,5 +1,5 @@
<tr href="<%= document_path(search_result.id) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>">
<tr href="<%= document_path(search_result.id) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>" target="_blank">
<td> <%= reference_number %> </td>
<td> <%= title %> </td>
<td> <%= short_title || title %> </td>
<td> <%= date_or_year %> </td>
</tr>

12
app/components/documents_years_component.rb

@ -0,0 +1,12 @@
class DocumentsYearsComponent < BaseComponent
attr_reader :years, :opts
def initialize(current_user:, years:, opts: {})
@years = years
@opts = opts
end
def render?
years.reject(&:blank?).present?
end
end

13
app/components/documents_years_component/documents_years_component.html.erb

@ -0,0 +1,13 @@
<table class="table table-borderless mb-0">
<tr>
<% years.each_slice(10).to_a.each do |year_arr| %>
<td>
<div class="container-sm p-0">
<% year_arr.each do |year| %>
<strong> <%= link_to year, documents_path(year: year.to_i), class: "text-decoration-none text-dark d-block" %> </strong>
<% end %>
</div>
</td>
<% end %>
</tr>
</table>

4
app/controllers/decisions_controller.rb

@ -10,6 +10,10 @@ class DecisionsController < ApplicationController
@jurisprudences = search.results
@years = (1901..Time.zone.today.year).entries.reverse
respond_to do |format|
format.html
end
end
private

2
app/controllers/documents_controller.rb

@ -33,6 +33,6 @@ class DocumentsController < ApplicationController
private
def search_params
params.permit(:reference_number, :title, :short_title, :q, :page, :per_page,
:subject_ids)
:subject_ids, :year)
end
end

20
app/javascript/controllers/document_controller.js

@ -2,16 +2,34 @@ import { end } from '@popperjs/core'
import ApplicationController from './application_controller'
export default class extends ApplicationController {
static targets = ["input"]
connect () {
super.connect()
}
search () {
const $this = this
var $this = this
$.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) {
if (status === "success") {
$this.stimulate("DocumentReflex#render_index_table", data)
}
});
}
modalDocumentSearch () {
var $this = this
$.get("/api/jurisprudences/", { q: this.inputTarget.value }, function (data, status) {
if (status === "success") {
$this.stimulate("DocumentReflex#render_moda_document_search_table", data)
}
});
}
loadYears () {
$.get("/api/jurisprudences/years", {}, function (data, status) {
if (status === "success") {
$this.stimulate("DocumentReflex#render_years", data)
}
});
}
}

1
app/reflexes/application_reflex.rb

@ -1,6 +1,7 @@
# frozen_string_literal: true
class ApplicationReflex < StimulusReflex::Reflex
delegate :current_user, to: :connection
# Put application-wide Reflex behavior and callbacks in this file.
#
# Example:

12
app/reflexes/document_reflex.rb

@ -5,8 +5,14 @@ class DocumentReflex < ApplicationReflex
def render_index_table(results)
@results = results
morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: User.first, opts: { is_case_lists: true }))
# render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true }))
# "<tr> <td> 1 </td> <td> 2 </td> <td> 3</td> </tr>"
morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true }))
end
def render_years(results)
morph "tbody#yearsIndex", render(DocumentsYearsComponent.new(current_user: current_user, years: results))
end
def render_moda_document_search_table(results)
morph "tbody#modalDocumentSearchTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true }))
end
end

6
app/views/decisions/index.html.erb

@ -0,0 +1,6 @@
<div class="card container-sm mt-1 p-0">
<h4 class="card-header"> Select Year </h4>
<div class="card-body table-responsive p-0">
<%= render(DocumentsYearsComponent.new(current_user: current_user, years: @years)) %>
</div>
<div>

1
app/views/doctrines/index.html.erb

@ -1,3 +1,4 @@
<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_disable_clickable_link: true, is_doctrines_index: true, subject_ids: params[:subject_ids] })) %>
</div>

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

@ -15,7 +15,7 @@
</div>
<div class="card-body col-sm-12 tableFixHead p-0 mt-1">
<div class="row"> <%= render PaginationComponent.new(data: @jurisprudences) %> </div>
<div class="container m-2"> <%= render PaginationComponent.new(data: @jurisprudences) %> </div>
<table class="table table-striped table-hover mb-0">
<thead>
<th class="bg-light"> Reference No. </th>

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

@ -3,8 +3,10 @@
<div class="card-header mt-1 col-sm-12">
<%= subject.path.map(&:name).join(' > ') %>
</div>
<% end %>
<% end if %>
<div class="card-body col-sm-12 tableFixHead p-0 mt-1">
<div class="container m-2"> <%= render PaginationComponent.new(data: @jurisprudences) %> </div>
<table class="table table-striped table-hover mb-0">
<thead>
<th class="bg-light"> Reference No. </th>

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

@ -33,19 +33,14 @@
<div class="tab-content">
<div class="tab-pane fade show active" id="analysisTabContent" role="tabpanel" aria-labelledby="home-tab">
<div class="row">
<div class="col-sm-11"> </div>
<div class="col-sm-1 p-3 end-0">
<a class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#doctrineModal">
<i class="fas fa-plus-circle" data-toggle="tooltip" data-placement="bottom" title="New Doctrine"></i>
</a>
</div>
<div class="d-flex justify-content-end p-3">
<a class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#doctrineModal"> Add Doctrine </a>
</div>
<div class="container-sm row-flex col-sm-12 mt-2">
<%= render(DoctrineModalFormComponent.new(current_user: current_user, doctrine: @document.doctrines.new, subjects: @subjects, opts: { form_url: jurisprudence_doctrines_path(jurisprudence_id: @document.id), form_method: :post })) %>
</div>
</div>
<div class="container-sm row-flex col-sm-12 mt-2">
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user)) %>
@ -53,13 +48,24 @@
</div>
<div class="tab-pane fade" id="documentTabContent" role="tabpanel">
<div class="container">
<div class="container-sm mt-2">
<%= raw @document.content.html_safe%>
</div>
</div>
<div class="tab-pane fade" id="ciatatonTabContent" role="tabpanel">
<span> Citator </span>
<div class="card card-header mt-1"> <h4> Cited Ins Documents </h4> </div>
<table class="table table-striped table-hover mb-0">
<thead>
<th class="bg-light"> Reference No. </th>
<th class="bg-light"> Title </th>
<th class="bg-light"> Date </th>
</thead>
<tbody>
<%= render(DocumentIndexTableComponent.with_collection(@cited_in_documents, current_user: current_user)) %>
</tbody>
</table>
</div>
</div>
</div>

Loading…
Cancel
Save