[UPDT] LEAVE: Updated HTMX method for leave forms

This commit is contained in:
Horilla
2024-08-28 17:03:22 +05:30
parent 0c3fd2bef8
commit 997391a2ce
4 changed files with 12 additions and 3 deletions

View File

@@ -867,7 +867,11 @@ class UserLeaveRequestCreationForm(ModelForm):
self.fields["leave_type_id"].queryset = assigned_leave_types
self.fields["leave_type_id"].widget.attrs.update(
{
"onchange": "typeChange($(this))",
"hx-include": "#userLeaveForm",
"hx-target": "#availableLeaveCount",
"hx-swap": "outerHTML",
"hx-trigger": "change",
"hx-get": f"/leave/employee-available-leave-count",
}
)
self.fields["employee_id"].initial = employee

View File

@@ -18,7 +18,7 @@
hx-get="{% url 'type-filter' %}"
hx-target="#leaveTypes"
></span>
{% endif %}
{% endif %}
{% if leave_type and request.GET.instances_ids and not compensatory %}
<div class="oh-modal__dialog oh-modal__dialog--navigation m-0 p-0">
<button

View File

@@ -133,7 +133,7 @@
</div>
<div class="oh-pagination">
<span class="oh-pagination__page">
{% trans "Page" %} {{ leave_types.number }}
{% trans "Page" %} {{ leave_types.number }}
{% trans "of" %} {{ leave_types.paginator.num_pages }}.
</span>
<nav class="oh-pagination__nav">

View File

@@ -26,6 +26,7 @@
>
<ion-icon name="close-outline"></ion-icon>
</button>
<div id="availableLeaveCount" style="height: 40px;display: none;"></div>
</div>
<div class="oh-modal__dialog-body">
<form
@@ -51,6 +52,10 @@
$("#userLeaveForm .row").after(button);
$(document).ready(function () {
$("select").on("select2:select", function (e) {
$(this).closest("select")[0].dispatchEvent(new Event("change"));
});
$("#buttonID").on("click", function () {
event.preventDefault();
event.stopPropagation();