17 changed files with 346 additions and 9 deletions
@ -0,0 +1,12 @@
|
||||
class AnalysisFormComponent < BaseComponent |
||||
attr_reader :doctrine, :opts |
||||
|
||||
def initialize(current_user:, doctrine:, opts:) |
||||
@doctrine = doctrine |
||||
@opts = opts |
||||
end |
||||
|
||||
def render? |
||||
doctrine.present? && opts[:form_url].present? && opts[:form_method].present? |
||||
end |
||||
end |
||||
@ -0,0 +1,54 @@
|
||||
<div class="card"> |
||||
<div class="card-body pd-0"> |
||||
<div class="row"> |
||||
<%= form_for(doctrine, url: opts[:form_url], method: opts[:form_method]) do |doctrine_form| %> |
||||
<%= fields_for :annotation, doctrine.annotations.build do |annotation_form| %> |
||||
<div class="row"> |
||||
<div class="col-sm-11 p-2"> |
||||
<%= doctrine_form.select :subject_ids, options_from_collection_for_select(Cdao::Subject.all, :id, :lineage_name), {}, class: "form-select i-chosen", multiple: true, prompt: "Please select" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-11 p-2"> |
||||
<%= doctrine_form.text_area :content, class: "i-ckeditor form-control", placeholder: "Doctrine" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-11 p-2"> |
||||
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="collapse" id="caseListsCollapse"> |
||||
<div class="row"> |
||||
<div class="col-sm-10 p-2"> |
||||
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number" %> |
||||
</div> |
||||
|
||||
<div class="col-sm-1 p-2"> |
||||
<%= button_tag "search", class: "btn btn-primary" %> |
||||
</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> |
||||
<%= render(DocumentIndexTableComponent.with_collection(Cdao::Jurisprudence.first(5), current_user: current_user, opts: { is_case_lists: true, form: annotation_form })) %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,25 @@
|
||||
class DoctrineIndexComponent < BaseComponent |
||||
with_collection_parameter :doctrine |
||||
attr_reader :doctrine |
||||
|
||||
def initialize(doctrine:, current_user:) |
||||
@doctrine = doctrine |
||||
end |
||||
|
||||
delegate :id, to: :doctrine |
||||
delegate :subject_ids, to: :doctrine |
||||
delegate :content, to: :doctrine |
||||
delegate :document_id, to: :doctrine |
||||
|
||||
def doctrine_form_url |
||||
jurisprudence_doctrines_path(jurisprudence_id: document_id) |
||||
end |
||||
|
||||
def annotation_form_url |
||||
doctrine_annotations_path(doctrine_id: id) |
||||
end |
||||
|
||||
def doctrine_subjects |
||||
doctrine_subjects.group(:subject_id) |
||||
end |
||||
end |
||||
@ -0,0 +1,62 @@
|
||||
<div class="card"> |
||||
<div class="card-header"> </div> |
||||
<div class="card-body"> |
||||
<%= form_tag(doctrine_form_url, method: :patch) do %> |
||||
<div class="row"> |
||||
<%= label_tag :subject_indexes %> |
||||
<%= select_tag "subject_ids[]", options_from_collection_for_select(Cdao::Subject.all, :id, :lineage_name, subject_ids), class: "form-select i-chosen", multiple: true, prompt: "Please select" %> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :content %> |
||||
<%= text_area_tag :content, content, class: "i-ckeditor form-control", placeholder: "Doctrine" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="collapse" id="caseListsCollapse"> |
||||
<div class="row"> |
||||
<div class="col-sm-10 p-2"> |
||||
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number" %> |
||||
</div> |
||||
|
||||
<div class="col-sm-1 p-2"> |
||||
<%= button_tag "search", class: "btn btn-primary" %> |
||||
</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> |
||||
<%= render(DocumentIndexTableComponent.with_collection(Cdao::Jurisprudence.first(5), current_user: current_user, opts: { is_case_lists: true, form_url: annotation_form_url, document_id: document_id })) %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
|
||||
<% doctrine.annotations.each do |annotation| %> |
||||
<div class="row"> |
||||
<div class="card col-sm-12"> |
||||
<div class="card-header p-1"> |
||||
<h6> <%= "#{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(', ')}" %> </h6> |
||||
<span class="m-3"> Editors Note: <%= annotation.editor_notes %> </span> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,11 @@
|
||||
class DoctrineModalFormComponent < BaseComponent |
||||
attr_reader :opts |
||||
|
||||
def initialize(current_user:, opts:) |
||||
@opts = opts |
||||
end |
||||
|
||||
def render? |
||||
opts[:form_url].present? && opts[:form_method].present? |
||||
end |
||||
end |
||||
@ -0,0 +1,30 @@
|
||||
<div class="modal fade" id="doctrineModal" tabindex="-1" aria-labelledby="doctrineModal" aria-hidden="true"> |
||||
<div class="modal-dialog w-100"> |
||||
<div class="modal-content w-100"> |
||||
<%= form_tag(opts[:form_url], method: opts[:form_method]) do %> |
||||
<div class="modal-header"> |
||||
<h4> Add New Doctrine </h4> |
||||
</div> |
||||
|
||||
<div class="modal-body"> |
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= select_tag "subject_ids[]", options_from_collection_for_select(Cdao::Subject.all, :id, :lineage_name, params[:subject_ids]), class: "form-select i-chosen", multiple: true, prompt: "Please select" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= text_area_tag :content, params[:content], class: "i-ckeditor form-control", placeholder: "Doctrine" %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="modal-footer"> |
||||
<button type="submit" class="btn btn-primary">Save</button> |
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> |
||||
</div> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
@ -0,0 +1,9 @@
|
||||
class DoctrineShowComponent < BaseComponent |
||||
with_collection_parameter :search_result |
||||
attr_reader :doctrine, :current_user |
||||
|
||||
def initialize(doctrine:, current_user:) |
||||
@doctrine = doctrine |
||||
@current_user = current_user |
||||
end |
||||
end |
||||
@ -0,0 +1,64 @@
|
||||
<div class="card"> |
||||
<div class="card-body"> |
||||
<%= form_tag(doctrine_form_url, method: :patch) do %> |
||||
<div class="row"> |
||||
<%= label_tag :subject_indexes %> |
||||
<%= select_tag "subject_ids[]", options_from_collection_for_select(Cdao::Subject.all, :id, :lineage_name, subject_ids), class: "form-select i-chosen", multiple: true, prompt: "Please select" %> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :content %> |
||||
<%= text_area_tag :content, content, class: "i-ckeditor form-control", placeholder: "Doctrine" %> |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= submit_tag "Update Doctrine", class: "btn btn-primary" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
||||
|
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button |
||||
</div> |
||||
</div> |
||||
|
||||
<div class="collapse" id="caseListsCollapse"> |
||||
<div class="row"> |
||||
<div class="col-sm-10 p-2"> |
||||
<%= text_field_tag :q, nil, class: "form-control", placeholder: "Search GR Number" %> |
||||
</div> |
||||
|
||||
<div class="col-sm-1 p-2"> |
||||
<%= button_tag "search", class: "btn btn-primary" %> |
||||
</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> |
||||
<%= render(DocumentIndexTableComponent.with_collection(Cdao::Jurisprudence.first(5), current_user: current_user, opts: { is_case_lists: true, form_url: annotation_form_url, document_id: document_id })) %> |
||||
</tbody> |
||||
</table> |
||||
</div> |
||||
</div> |
||||
|
||||
<%= form_tag(annotation_form_url, method: :patch) do %> |
||||
<div class="row"> |
||||
<%= label_tag :annotation %> |
||||
<%%= hidden_tag :document_id, doctrine > |
||||
<%= text_area_tag :content, content, class: "i-ckeditor form-control", placeholder: "Doctrine" %> |
||||
</div> |
||||
<%end%> |
||||
</div> |
||||
</div> |
||||
@ -1,6 +1,56 @@
|
||||
<tr href="<%= document_path(search_result) %>" class="clickable-tr"> |
||||
<tr href="<%= document_path(search_result) %>" class="<%= opts.reject{ |k, v| v.blank? }.blank? ? 'clickable-tr' : ''%>"> |
||||
<td> <%= reference_number %> </td> |
||||
<td> <%= title %> </td> |
||||
<td> <%= date_or_year %> </td> |
||||
<td></td> |
||||
<% if opts[:is_case_lists].present? && opts[:form_url].present? && opts[:document_id].present? %> |
||||
<td> |
||||
<a class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#annotationModal"> |
||||
<i class="fas fa-plus-circle" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Add"></i> |
||||
</a> |
||||
|
||||
<div class="modal fade" id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" aria-hidden="true"> |
||||
<div class="modal-dialog modal-dialog-scrollable w-50"> |
||||
<div class="modal-header"> Create Annotations </div> |
||||
<div class="modal-content"> |
||||
<%= form_tag(opts[:form_url], method: :post) do%> |
||||
<div class="modal-body"> |
||||
<div class="row"> |
||||
<div class="col-sm-12 p-2"> |
||||
<%= label_tag :annotation_marks %> |
||||
<%= hidden_field_tag :document_id, opts[: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 %> |
||||
<%= text_area_tag :editor_notes, params[:editors_note], class: "form-control i-ckeditor" %> |
||||
</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> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
<% end %> |
||||
</tr> |
||||
|
||||
Loading…
Reference in new issue