55 lines
2.1 KiB
HTML
55 lines
2.1 KiB
HTML
{% load i18n crispy_forms_tags %}
|
|
<div class="modal fade"
|
|
id="noteModal"
|
|
tabindex="-1"
|
|
aria-labelledby="noteModalLabel"
|
|
aria-hidden="true">
|
|
<div class="modal-dialog modal-md">
|
|
<div class="modal-content">
|
|
<div class="modal-header justify-content-between align-items-start gap-5 px-4 pt-4 pb-3 border-0">
|
|
<h4 class="modal-title" id="noteModalLabel">{% trans 'Note' %}</h4>
|
|
<button class="btn p-0 text-body-quaternary fs-6"
|
|
data-bs-dismiss="modal"
|
|
aria-label="Close">
|
|
<span class="fas fa-times"></span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="noteForm"
|
|
hx-boost="true"
|
|
action="{% url 'add_note' request.dealer.slug content_type slug %}"
|
|
hx-select="#notesTable"
|
|
hx-target="#notesTable"
|
|
hx-on::after-request="{ resetSubmitButton(document.querySelector('.add_note_form button[type=submit]')); $('#noteModal').modal('hide'); }"
|
|
hx-swap="outerHTML show:window.top"
|
|
hx-select-oob="#timeline"
|
|
method="post"
|
|
class="add_note_form">
|
|
{% csrf_token %}
|
|
{{ note_form|crispy }}
|
|
<button type="submit" class="btn btn-phoenix-success w-100">{% trans 'Save' %}</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
function updateNote(e) {
|
|
let form = document.querySelector('#noteForm');
|
|
|
|
let url = e.getAttribute('data-url');
|
|
let note = e.getAttribute('data-note');
|
|
|
|
document.querySelector('#id_note').value = note;
|
|
|
|
form.action = url;
|
|
htmx.process(form);
|
|
}
|
|
$('#noteModal').on('hidden.bs.modal', function () {
|
|
let form = document.querySelector('#noteForm');
|
|
form.action = "{% url 'add_note' request.dealer.slug content_type slug %}";
|
|
document.querySelector('#id_note').value = "";
|
|
htmx.process(form);
|
|
});
|
|
</script>
|