diff --git a/app/components/analysis_form_component/analysis_form_component.html.erb b/app/components/analysis_form_component/analysis_form_component.html.erb index afbcb32..49b9f74 100644 --- a/app/components/analysis_form_component/analysis_form_component.html.erb +++ b/app/components/analysis_form_component/analysis_form_component.html.erb @@ -11,7 +11,7 @@
- + <%= doctrine_form.rich_text_area :content, placeholder: "Doctrine Content" %>
@@ -51,4 +51,4 @@ <% end %> - \ No newline at end of file + diff --git a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb index 77b1be7..5bb36f3 100644 --- a/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb +++ b/app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb @@ -56,7 +56,7 @@
<%= label_tag :editor_notes %> - <%= annotation.editor_notes %> + <%= rich_text_area_tag :editor_notes, annotation.editor_notes, placeholder: "Editor Notes" %>
diff --git a/app/components/base_component.rb b/app/components/base_component.rb index 59c9e97..3c68a82 100644 --- a/app/components/base_component.rb +++ b/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:) diff --git a/app/components/doctrine_modal_form_component.rb b/app/components/doctrine_modal_form_component.rb index bc70adc..d102aae 100644 --- a/app/components/doctrine_modal_form_component.rb +++ b/app/components/doctrine_modal_form_component.rb @@ -10,4 +10,4 @@ class DoctrineModalFormComponent < BaseComponent def render? opts[:form_url].present? && opts[:form_method].present? end -end \ No newline at end of file +end diff --git a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb index daee096..f4aa8d6 100644 --- a/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb +++ b/app/components/doctrine_modal_form_component/doctrine_modal_form_component.html.erb @@ -18,7 +18,7 @@
<%= label_tag :content %> - <%= doctrine.content %> + <%= rich_text_area_tag :content, doctrine.content, placeholder: "Doctrine Content" %>
diff --git a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb index 77cde84..e4446d2 100644 --- a/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb +++ b/app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb @@ -26,7 +26,7 @@
<%= label_tag :content %> - <%= content %> + <%= rich_text_area_tag :content, content, placeholder: "Doctrine Content" %>
<% end %> @@ -37,7 +37,7 @@ - +
@@ -69,9 +69,9 @@
-

+

<%= "#{annotation.annomarks.map { |annomark| "(#{annomark.code})" }.join(" ")}" %> - <%= 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 %>

diff --git a/app/components/document_index_table_body_component/document_index_table_body_component.html.erb b/app/components/document_index_table_body_component/document_index_table_body_component.html.erb index 97d5d8d..f39b4c6 100644 --- a/app/components/document_index_table_body_component/document_index_table_body_component.html.erb +++ b/app/components/document_index_table_body_component/document_index_table_body_component.html.erb @@ -40,7 +40,7 @@
<%= label_tag :editor_notes %> - <%= params[:editor_notes] %> + <%= rich_text_area_tag :editor_notes, params[:editor_notes], placeholder: "Editor Notes" %>
diff --git a/app/controllers/api/doctrine/annotations_controller.rb b/app/controllers/api/doctrine/annotations_controller.rb new file mode 100644 index 0000000..a6e37df --- /dev/null +++ b/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