Browse Source

Fix trix-editor

pull/17/head
Angel Aviel Domaoan 4 years ago committed by Angel Aviel Domaoan
parent
commit
439e59b7b4
  1. 2
      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/doctrine_modal_form_component.html.erb
  5. 2
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  6. 2
      app/components/document_index_table_body_component/document_index_table_body_component.html.erb
  7. 56
      app/controllers/api/doctrine/annotations_controller.rb

2
app/components/analysis_form_component/analysis_form_component.html.erb

@ -11,7 +11,7 @@
<div class="row">
<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>

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

@ -56,7 +56,7 @@
<div class="row">
<div class="col-sm-12 p-2">
<%= 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>

2
app/components/base_component.rb

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

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

@ -18,7 +18,7 @@
<div class="row">
<div class="col-sm-12 p-2">
<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>

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

@ -26,7 +26,7 @@
<div class="row">
<div class="col-sm-12 p-2">
<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>
<% end %>

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

@ -40,7 +40,7 @@
<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>
<%= rich_text_area_tag :editor_notes, params[:editor_notes], placeholder: "Editor Notes" %>
</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