Browse Source

Fix bugs from `annotations` CRUD

pull/78/head
alexdbondoc17 4 years ago
parent
commit
a66786c9df
  1. 5
      app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb
  2. 13
      app/controllers/doctrine/annotations_controller.rb

5
app/components/annotation_marks_modal_form_component/annotation_marks_modal_form_component.html.erb

@ -1,7 +1,4 @@
<div class="modal fade modal-doctrine-body <%= opts[:is_show].present? ? 'show' : '' %>" <div class="modal fade modal-doctrine-body" id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" data-controller="annotations">
id="annotationModal" tabindex="-1" aria-labelledby="annotationModal" aria-hidden="true"
style="<%= opts[:is_show].present? ? 'display: block;' : '' %>" aria-modal="<%= opts[:is_show].present? %>"
data-controller="annotations">
<div class="modal-dialog modal-lg modal-dialog-scrollable"> <div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">

13
app/controllers/doctrine/annotations_controller.rb

@ -21,10 +21,10 @@ class Doctrine::AnnotationsController < ApplicationController
if @annotation.save if @annotation.save
@documents.each { |document| @annotation.add_document(document) } if @documents.present? @documents.each { |document| @annotation.add_document(document) } if @documents.present?
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine), format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully created." } notice: "Doctrine Annotation was successfully created." }
else else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) } format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine) }
end end
end end
end end
@ -48,22 +48,21 @@ class Doctrine::AnnotationsController < ApplicationController
@documents.each { |document| @annotation.add_document(document) } if @documents.present? @documents.each { |document| @annotation.add_document(document) } if @documents.present?
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine), format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully updated." } notice: "Doctrine Annotation was successfully updated." }
else else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine) } format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine) }
end end
end end
end end
def destroy def destroy
document_id = @doctrine.document_id
respond_to do |format| respond_to do |format|
if @annotation.destroy if @annotation.destroy
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine), format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
notice: "Doctrine Annotation was successfully destroyed." } notice: "Doctrine Annotation was successfully destroyed." }
else else
format.html { redirect_to document_doctrine_path(@doctrine.document, @doctrine), format.html { redirect_to document_doctrine_path(@doctrine.doctrine_jurisprudences.first.jurisprudence, @doctrine),
alert: @annotation.errors.full_messages } alert: @annotation.errors.full_messages }
end end
end end

Loading…
Cancel
Save