Browse Source

Major Updates for the Main UI

pull/16/head
alexdbondoc17 4 years ago
parent
commit
9a7c78e417
  1. 3
      app/channels/application_cable/connection.rb
  2. 5
      app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb
  3. 2
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  4. 8
      app/components/document_index_table_body_component.rb
  5. 53
      app/components/document_index_table_body_component/document_index_table_body_component.html.erb
  6. 4
      app/components/subjects_sidenav_sub_menu_component.rb
  7. 9
      app/controllers/doctrines_controller.rb
  8. 4
      app/controllers/subject_indexes_controller.rb
  9. 2
      app/javascript/packs/application.js
  10. 8
      app/javascript/src/application.scss
  11. 5
      app/reflexes/document_reflex.rb
  12. 4
      app/views/doctrines/index.html.erb
  13. 4
      app/views/doctrines/search.html.erb
  14. 6
      app/views/subject_indexes/doctrines.html.erb
  15. 6
      app/views/subject_indexes/show.html.erb
  16. 5
      config/routes.rb

3
app/channels/application_cable/connection.rb

@ -8,7 +8,8 @@ module ApplicationCable
private
def find_verified_user
if verified_user = User.find_by(id: cookies.encrypted[:user_id])
user_id = cookies.encrypted[:_cdao_pjet_session]["warden.user.user.key"].first.pop
if verified_user = User.find_by(id: user_id)
verified_user
else
reject_unauthorized_connection

5
app/components/document_doctrine_index_component/document_doctrine_index_component.html.erb

@ -17,9 +17,8 @@
<% annotations.each do |annotation| %>
<div class="container-sm ms-5">
<p class="mb-0">
<strong>
<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")} #{[annotation.document.title, annotation.document.reference_number, annotation.document.docdate.strftime("%B %d, %Y"), annotation.phil_rep].join(', ')}" %>
</strong>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [annotation.document.title, annotation.document.reference_number, annotation.document.docdate.strftime("%B %d, %Y"), annotation.phil_rep].reject(&:blank?).join(', ') %>
</p>
<% if annotation.editor_notes.present? %>

2
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -71,7 +71,7 @@
<div class="col-sm-10">
<p>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> </strong>
<%= raw [annotation.document.title, annotation.document.reference_number, annotation.document.docdate.strftime("%B %d, %Y"), annotation.phil_rep].join(', ').html_safe %>
<%= raw [annotation.document.title, annotation.document.reference_number, annotation.document.docdate.strftime("%B %d, %Y"), annotation.phil_rep].reject(&:blank?).join(', ').html_safe %>
</p>
</div>

8
app/components/document_index_table_body_component.rb

@ -6,6 +6,10 @@ class DocumentIndexTableBodyComponent < BaseComponent
@search_result = search_result
@opts = opts
end
def document_id
search_result["id"]
end
def reference_number
search_result["reference_number"]
@ -24,8 +28,4 @@ class DocumentIndexTableBodyComponent < BaseComponent
def form_url
doctrine_annotations_path(doctrine_id: opts[:doctrine_id])
end
def render?
search_result.present?
end
end

53
app/components/document_index_table_body_component/document_index_table_body_component.html.erb

@ -2,4 +2,57 @@
<td> <%= reference_number %> </td>
<td> <%= title %> </td>
<td> <%= date_or_year %> </td>
<% if opts[:is_case_lists].present? %>
<td>
<a class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#annotationModal<%= document_id %>"> Add </a>
<div class="modal fade" id="annotationModal<%= document_id %>" tabindex="-1" aria-labelledby="annotationModal" aria-hidden="true">
<%= form_tag(opts[:form_url], method: :post) do %>
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">New Annotation Marks</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-12 p-2">
<%= label_tag :annotation_marks %>
<%= hidden_field_tag :document_id, document_id %>
<%= select_tag "annomark_ids[]", options_from_collection_for_select(Annomark.all, :id, :name, params[:annomark_ids]), class: "form-select i-chosen", 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, [title, reference_number, date_or_year].join(", "), class: "form-control" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<%= label_tag :phil_rep %>
<%= text_field_tag :phil_rep, params[:phil_rep], class: "form-control" %>
</div>
</div>
<div class="row">
<div class="col-sm-12 p-2">
<%= label_tag :editor_notes %>
<trix-editor id="editor_notes" placeholder="Doctrine Content"> <%= params[:editor_notes] %> </trix-editor>
</div>
</div>
</div>
<div class="modal-footer">
<%= submit_tag "Save", class: "btn btn-primary" %>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
<% end %>
</div>
</td>
<% end %>
</tr>

4
app/components/subjects_sidenav_sub_menu_component.rb

@ -6,8 +6,8 @@ class SubjectsSidenavSubMenuComponent < BaseComponent
end
def index_url(subject_id)
return doctrines_path(subject_ids: [subject_id]) if opts[:is_doctrines_index].present?
return search_doctrines_path(subject_ids: [subject_id]) if opts[:is_doctrines_index].present?
subject_index_path(subject_id)
doctrines_subject_index_path(subject_id)
end
end

9
app/controllers/doctrines_controller.rb

@ -10,6 +10,15 @@ class DoctrinesController < ApplicationController
end
end
def search
@search = search_doctrines(search_params)
@doctrines = @search.results
respond_to do |format|
format.html
end
end
def show; end
private

4
app/controllers/subject_indexes_controller.rb

@ -9,6 +9,10 @@ class SubjectIndexesController < ApplicationController
def edit; end
def doctrines
@doctrines = @subject_index.doctrines
end
def show
@doctrines = @subject_index.doctrines
end

2
app/javascript/packs/application.js

@ -28,7 +28,7 @@ Rails.start()
Turbolinks.start()
ActiveStorage.start()
$(document).ready(function () {
$(document).on("ready turbolinks:load", function () {
$('#toggleSideNav').on('click', function () {
$('#sidenav').toggleClass('active');
});

8
app/javascript/src/application.scss

@ -17,3 +17,11 @@
position: sticky;
left: 0;
}
.clickable-link, .clickable-tr {
cursor: pointer;
}
.current {
background-color: #535353;
}

5
app/reflexes/document_reflex.rb

@ -4,8 +4,7 @@ class DocumentReflex < ApplicationReflex
include JurisprudenceSearch
def render_index_table(results)
@results = results
morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(@results, current_user: current_user, opts: { is_case_lists: true }))
morph "tbody#documentIndexTable", render(DocumentIndexTableBodyComponent.with_collection(results, current_user: current_user, opts: { is_case_lists: true }))
end
def render_years(results)
@ -13,6 +12,6 @@ class DocumentReflex < ApplicationReflex
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 }))
morph "tbody#modalDocumentSearchTable", render(DocumentIndexTableBodyComponent.with_collection(results, current_user: current_user, opts: { is_case_lists: true }))
end
end

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

@ -1,4 +0,0 @@
<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>

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

@ -0,0 +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_doctrines_index: true, subject_ids: params[:subject_ids] })) %>
</div>

6
app/views/subject_indexes/doctrines.html.erb

@ -0,0 +1,6 @@
<div class="card container-sm mt-1 p-0">
<h5 class="card-header"> <%= @subject_index.lineage_name %> </h5>
<div class="card-body">
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_subjects_index: true })) %>
</div>
</div>

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

@ -1,6 +0,0 @@
<div class="card container-sm mt-1 p-0">
<h5 class="card-header"> <%= @subject_index.lineage_name %> </h5>
<div class="card-body">
<%= render(DocumentDoctrineIndexComponent.with_collection(@doctrines, current_user: current_user, opts: { is_subjects_index: true, is_disable_clickable_link: true })) %>
</div>
</div>

5
config/routes.rb

@ -4,6 +4,7 @@ Rails.application.routes.draw do
root to: "home#index"
resources :doctrines, only: %i[index] do
get :search, on: :collection
scope module: :doctrine do
resources :annotations, only: %i[create update destroy]
end
@ -25,7 +26,9 @@ Rails.application.routes.draw do
resources :decisions, only: %i[index]
resources :subject_indexes do
get :search, on: :collection
member do
get :doctrines
end
end
namespace :api, defaults: { format: :json } do

Loading…
Cancel
Save