[UPDT] ATTENDANCE: Changed shift_id field hx-attributes in html form

This commit is contained in:
Horilla
2024-08-30 14:52:22 +05:30
parent c88a8202c2
commit 61f3ece4cd
4 changed files with 3 additions and 9 deletions

View File

@@ -206,7 +206,6 @@ class AttendanceUpdateForm(ModelForm):
"id": str(uuid.uuid4()),
"hx-include": "#attendanceUpdateForm",
"hx-target": "#attendanceUpdateForm",
"hx-trigger": "change",
"hx-get": "/attendance/update-fields-based-shift",
}
)
@@ -325,7 +324,6 @@ class AttendanceForm(ModelForm):
"id": str(uuid.uuid4()),
"hx-include": "#attendanceCreateForm",
"hx-target": "#attendanceCreateForm",
"hx-trigger": "change",
"hx-get": "/attendance/update-fields-based-shift",
}
)
@@ -580,7 +578,6 @@ class AttendanceRequestForm(ModelForm):
"id": str(uuid.uuid4()),
"hx-include": "#attendanceRequestForm",
"hx-target": "#attendanceRequestDiv",
"hx-trigger": "change",
"hx-swap": "outerHTML",
"hx-get": "/attendance/update-fields-based-shift",
}
@@ -644,7 +641,6 @@ class NewRequestForm(AttendanceRequestForm):
"class": "oh-select oh-select-2 w-100",
"hx-target": "#id_shift_id_div",
"hx-get": "/attendance/get-employee-shift?bulk=False",
"hx-trigger": "change",
}
),
initial=view_initial.get("employee_id"),
@@ -657,7 +653,6 @@ class NewRequestForm(AttendanceRequestForm):
"class": "oh-checkbox",
"hx-target": "#objectCreateModalTarget",
"hx-get": "/attendance/request-new-attendance?bulk=True",
"hx-trigger": "change",
}
),
),
@@ -945,7 +940,6 @@ class BulkAttendanceRequestForm(ModelForm):
attrs={
"hx-target": "#id_shift_id_div",
"hx-get": "/attendance/get-employee-shift?bulk=True",
"hx-trigger": "change",
}
),
label=_("Employee"),
@@ -959,7 +953,6 @@ class BulkAttendanceRequestForm(ModelForm):
"class": "oh-checkbox",
"hx-target": "#objectCreateModalTarget",
"hx-get": "/attendance/request-new-attendance?bulk=False",
"hx-trigger": "change",
}
),
)

View File

@@ -2,10 +2,8 @@
<label class="oh-label" for="id_{{field.name }}" title="{{field.help_text|safe }}">{{field.label}}</label>
{{field}}
<script>
$("[name={{field.name}}]").change()
$(document).ready(function () {
$("select").on("select2:select", function (e) {
$(".leave-message").hide()
$(this).closest("select")[0].dispatchEvent(new Event("change"));
});
});

View File

@@ -757,11 +757,13 @@ def get_employee_shift(request):
if request.GET.get("bulk") and eval(request.GET.get("bulk")):
form = BulkAttendanceRequestForm()
form.fields["shift_id"].queryset = EmployeeShift.objects.all()
form.fields["shift_id"].widget.attrs["hx-trigger"] = "load,change"
form.fields["shift_id"].initial = shift
shift_id = render_to_string(
"requests/attendance/form_field.html",
{
"field": form["shift_id"],
"shift": shift,
},
)
return HttpResponse(f"{shift_id}")

View File

@@ -143,6 +143,7 @@ remove_urls = [
"objective-detailed-view",
"ticket-detail",
"faq-view",
"get-job-positions",
]
user_breadcrumbs = {}