Files
ihrm/base/templates/shift_request/allocation_request_update_form.html
Ashwanth Balakrishnan 58be33a8d7 Added Pre-Commit Hooks (#175)
* Added pre commit hook

* Run pre commit hook on all files

---------

Co-authored-by: Horilla <131998600+horilla-opensource@users.noreply.github.com>
2024-05-07 12:23:36 +05:30

41 lines
1.1 KiB
HTML

{% load i18n %}
{% load static %}
<form hx-post="{% url 'shift-allocation-request-update' form.instance.id %}"
hx-target="#shiftRequestModalUpdateBody">
{{form.as_p}}
</form>
<script>
$("#id_shift_id").change(function(e){
var selectedElement = $("#id_shift_id")
var selectElement = $("#id_shift_id").val();
let parentForm = selectedElement.parents().closest("form")
$.ajax({
type: "post",
url: "{% url 'update-employee-allocation' %}",
data: {
csrfmiddlewaretoken: getCookie("csrftoken"),
"shift_id":selectElement
},
success: function (response) {
var reallocateToSelect = parentForm.find("[name=reallocate_to]");
reallocateToSelect.empty(); // Clear existing options
for (var i = 0; i < response.employee_data.length; i++) {
var employee = response.employee_data[i];
// Log the values being added
reallocateToSelect.append('<option value="' + employee[0] + '">' + employee[1] + ' ' + employee[2] + '</option>');
}
}
});
});
</script>