Browse Source

Fix `doctrines#destroy`

pull/130/head
alexdbondoc17 4 years ago
parent
commit
e66ea59b44
  1. 4
      app/components/document_doctrine_show_component.rb
  2. 4
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  3. 4
      app/javascript/controllers/doctrines_controller.js

4
app/components/document_doctrine_show_component.rb

@ -25,8 +25,8 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title
end
def document
Document.find(document_id)
def jurisprudence
Cdao::Jurisprudence.find(opts[:jurisprudence_id])
end
def date_or_year(annotation)

4
app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb

@ -5,9 +5,9 @@
<h5> <b>Doctrine Details</b> </h5>
</div>
<div class="col-sm-2 d-flex justify-content-end pe-0" data-controller="doctrines" data-jurisprudence-id="<%= opts[:jurisprudence_id] %>" data-doctrine-id="<%= id %>" >
<div class="col-sm-2 d-flex justify-content-end pe-0" >
<a class="btn btn-success me-3 for-selectize-edit" href="<%= edit_doctrine_path(id, jurisprudence_id: opts[:jurisprudence_id]) %>"> Edit </a>
<a class="btn btn-danger " data-action="click->doctrines#delete" > Delete </a>
<a class="btn btn-danger " data-controller="doctrines" data-doctrine-id="<%= id %>" data-document-id="<%= jurisprudence.document.id %>" data-action="click->doctrines#delete" > Delete </a>
</div>
</div>

4
app/javascript/controllers/doctrines_controller.js

@ -123,7 +123,7 @@ export default class extends ApplicationController {
}
delete(ev) {
var doctrine_id = this.element.dataset["doctrineId"], jurisprudence_id = this.element.dataset["jurisprudenceId"]
var doctrine_id = this.element.dataset["doctrineId"], document_id = this.element.dataset["documentId"]
ev.preventDefault();
const contrim_alert = confirm("Are you sure to delete this record?")
@ -135,7 +135,7 @@ export default class extends ApplicationController {
$('.toast').addClass('bg-danger').show();
$( ".toast-body" ).html( "<span><b>Deleted Successfully</b></span>" );
$('.toast').fadeOut(5000);
location.pathname = "/documents/" + jurisprudence_id
location.pathname = "/documents/" + document_id
},
error: function () {
$('.toast').addClass('bg-danger').show();

Loading…
Cancel
Save