Browse Source

Merge pull request #130 from lexintegritastech/improve-main-ui

Fix UI for `doctrines#form` and `doctrines#destroy`
pull/131/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
83d340b013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/components/doctrine_form_component/doctrine_form_component.html.erb
  2. 4
      app/components/document_doctrine_show_component.rb
  3. 4
      app/components/document_doctrine_show_component/document_doctrine_show_component.html.erb
  4. 4
      app/javascript/controllers/doctrines_controller.js

2
app/components/doctrine_form_component/doctrine_form_component.html.erb

@ -2,7 +2,7 @@
<div class="col-sm-12"> <div class="col-sm-12">
<label for="subject-name" class="col-form-label"> Subjects </label> <label for="subject-name" class="col-form-label"> Subjects </label>
<%= hidden_field_tag :document_id, jurisprudence_id, data: { target: "doctrines.document_id" } %> <%= hidden_field_tag :document_id, jurisprudence_id, data: { target: "doctrines.document_id" } %>
<%= hidden_field_tag :doctrine_id, nil, data: { target: "doctrines.doctrine_id" } %> <%= hidden_field_tag :doctrine_id, doctrine.id, data: { target: "doctrines.doctrine_id" } %>
<select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required> <select class="form-control subject-ids-selectize ps-0" name="subject_ids[]" id="subject_ids_" multiple="true" required>
<% doctrine.subjects.each do |subject| %> <% doctrine.subjects.each do |subject| %>
<option value="<%= subject.id %>" selected> <%= subject.lineage_name %> </option> <option value="<%= subject.id %>" selected> <%= subject.lineage_name %> </option>

4
app/components/document_doctrine_show_component.rb

@ -25,8 +25,8 @@ class DocumentDoctrineShowComponent < BaseComponent
annotation.document.title annotation.document.title
end end
def document def jurisprudence
Document.find(document_id) Cdao::Jurisprudence.find(opts[:jurisprudence_id])
end end
def date_or_year(annotation) 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> <h5> <b>Doctrine Details</b> </h5>
</div> </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-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>
</div> </div>

4
app/javascript/controllers/doctrines_controller.js

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

Loading…
Cancel
Save