Browse Source

Fix trix-editor

pull/17/head
Angel Aviel Domaoan 4 years ago committed by Angel Aviel Domaoan
parent
commit
439e59b7b4
  1. 4
      app/components/analysis_form_component/analysis_form_component.html.erb
  2. 2
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  3. 2
      app/components/base_component.rb
  4. 2
      app/components/doctrine_modal_form_component.rb
  5. 2
      app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb
  6. 8
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  7. 2
      app/components/document_index_table_body_component/document_index_table_body_component.html.erb
  8. 56
      app/controllers/api/doctrine/annotations_controller.rb

4
app/components/analysis_form_component/analysis_form_component.html.erb

@ -11,7 +11,7 @@
<div class="row"> <div class="row">
<div class="col-sm-11 p-2"> <div class="col-sm-11 p-2">
<trix-editor id="content" placeholder="Doctrine Content"> </trix-editor> <%= doctrine_form.rich_text_area :content, placeholder: "Doctrine Content" %>
</div> </div>
</div> </div>
@ -51,4 +51,4 @@
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>

2
app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb

@ -56,7 +56,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12 p-2"> <div class="col-sm-12 p-2">
<%= label_tag :editor_notes %> <%= label_tag :editor_notes %>
<trix-editor id="editor_notes" placeholder="Editor Notes"> <%= annotation.editor_notes %> </trix-editor> <%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor Notes" %>
</div> </div>
</div> </div>
</div> </div>

2
app/components/base_component.rb

@ -1,4 +1,6 @@
class BaseComponent < ViewComponent::Base class BaseComponent < ViewComponent::Base
delegate :rich_text_area_tag, to: :helpers
attr_reader :ability, :current_user attr_reader :ability, :current_user
def initialize(current_user:) def initialize(current_user:)

2
app/components/doctrine_modal_form_component.rb

@ -10,4 +10,4 @@ class DoctrineModalFormComponent < BaseComponent
def render? def render?
opts[:form_url].present? && opts[:form_method].present? opts[:form_url].present? && opts[:form_method].present?
end end
end end

2
app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb

@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12 p-2"> <div class="col-sm-12 p-2">
<strong> <%= label_tag :content %> </strong> <strong> <%= label_tag :content %> </strong>
<trix-editor id="content" placeholder="Doctrine Content"> <%= doctrine.content %> </trix-editor> <%= rich_text_area_tag :content, doctrine.content, placeholder: "Doctrine Content" %>
</div> </div>
</div> </div>
</div> </div>

8
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -26,7 +26,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12 p-2"> <div class="col-sm-12 p-2">
<strong> <%= label_tag :content %> </strong> <strong> <%= label_tag :content %> </strong>
<trix-editor id="content" placeholder="Doctrine Content"> <%= content %> </trix-editor> <%= rich_text_area_tag :content, content, placeholder: "Doctrine Content" %>
</div> </div>
</div> </div>
<% end %> <% end %>
@ -37,7 +37,7 @@
<button type="button" class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#caseListsCollapse" aria-expanded="false" aria-controls="collapseExample"> Case Lists </button> <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> </div>
<div class="collapse mb-3" id="caseListsCollapse"> <div class="collapse mb-3" id="caseListsCollapse">
<div class="row" data-controller="document" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>"> <div class="row" data-controller="document" data-document-id="<%= document_id %>" data-doctrine-id="<%= id %>">
<div class="col-sm-10 p-2"> <div class="col-sm-10 p-2">
@ -69,9 +69,9 @@
<div class="container-sm ms-1"> <div class="container-sm ms-1">
<div class="row"> <div class="row">
<div class="col-sm-10"> <div class="col-sm-10">
<p> <p>
<strong> <%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.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(', ').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> </p>
</div> </div>

2
app/components/document_index_table_body_component/document_index_table_body_component.html.erb

@ -40,7 +40,7 @@
<div class="row"> <div class="row">
<div class="col-sm-12 p-2"> <div class="col-sm-12 p-2">
<%= label_tag :editor_notes %> <%= label_tag :editor_notes %>
<trix-editor id="editor_notes" placeholder="Doctrine Content"> <%= params[:editor_notes] %> </trix-editor> <%= rich_text_area_tag :editor_notes, params[:editor_notes], placeholder: "Editor Notes" %>
</div> </div>
</div> </div>
</div> </div>

56
app/controllers/api/doctrine/annotations_controller.rb

@ -0,0 +1,56 @@
module Api
module Doctrine
class AnnotationsController < ::Api::BaseController
load_and_authorize_resource :doctrine, class: "Doctrine"
load_and_authorize_resource :annotation, class: "Annotation", through: :doctrine
def index
respond_with @annotations
end
def show
respond_with @annotation
end
def create
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
@annotation = @jurisprudence.annotations.new(attrs)
if @annotation.save
@annotation.subject_ids = subject_ids if subject_ids.present?
respond_with @annotation
else
render errors: @annotation.errors, status: 422
end
end
def update
attrs = resource_params.to_unsafe_h.deep_symbolize_keys
subject_ids = attrs.delete(:subject_ids)
if @annotation.update(attrs)
@annotation.subject_ids = subject_ids if subject_ids.present?
respond_with @annotation
else
render errors: @annotation.errors, status: 422
end
end
def destroy
@annotation.destroy
respond_with @annotation
end
private
def resource_params
params.permit(:content, subject_ids: [])
end
end
end
end
Loading…
Cancel
Save