[FIX] LEAVE: Leave allocation request modal issue

This commit is contained in:
Horilla
2024-01-20 12:53:25 +05:30
parent 02320c6315
commit 79a2e53eb7
5 changed files with 82 additions and 51 deletions

View File

@@ -1,27 +1,53 @@
{% load i18n %}
{% load i18n %}
{% if messages %}
<div class="oh-wrapper">
{% for message in messages %}
<div class="oh-alert-container">
<div class="oh-alert oh-alert--animated {{message.tags}}">
{{ message }}
</div>
</div>
{% endfor %}
<script>
setTimeout(function () {
$('.oh-modal__close').click()
}, 1000);
</script>
</div>
{% endif %}
{% if form.errors %}
<!-- form errors -->
<div class="oh-wrapper">
<div class="oh-alert-container">
{% for error in form.non_field_errors %}
<div class="oh-alert oh-alert--animated oh-alert--danger">
{{ error }}
</div>
{% endfor %}
</div>
</div>
<div class="oh-wrapper">
<div class="oh-alert-container">
{% for error in form.non_field_errors %}
<div class="oh-alert oh-alert--animated oh-alert--danger">{{ error }}</div>
{% endfor %}
</div>
</div>
{% endif %}
<form
hx-post="{% url 'allocation-request-add-comment' request_id %}"
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="createModalTitle">
{% trans "Add Comment" %}
</h2>
<button class="oh-modal__close" aria-label="Close"
hx-get="{% url 'leave-allocation-request-filter' %}?{{pd}}"
hx-target="#view-container"
>
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body">
<form
hx-post="{% url 'allocation-request-add-comment' request_id %}?{{pd}}"
hx-target="#shiftRequestCommentForm"
method="post"
hx-encoding="multipart/form-data">
{% csrf_token %}
{{form.as_p}}
hx-encoding="multipart/form-data"
>
{% csrf_token %} {{form.as_p}}
<button
type="submit"
class="oh-btn oh-btn--secondary mt-2 mr-0 oh-btn--w-100-resp"
>
{% trans "Save" %}
</button>
</form>
type="submit"
class="oh-btn oh-btn--secondary mt-2 mr-0 oh-btn--w-100-resp"
>
{% trans "Save" %}
</button>
</form>
</div>

View File

@@ -1,6 +1,18 @@
{% load basefilters %}
{% load i18n %}
{% if messages %}
<div class="oh-wrapper">
{% for message in messages %}
<div class="oh-alert-container">
<div class="oh-alert oh-alert--animated {{message.tags}}">
{{ message }}
</div>
</div>
{% endfor %}
</div>
{% endif %}
{% if no_comments %}
<div class="oh-timeoff-modal__profile-content">
@@ -19,7 +31,7 @@
<div class="oh-profile ms-4">
<div>
<span class="oh-timeoff-modal__stat-title fw-bold">{% trans "Comment" %}
<a href='{% url "leave-request-delete-comment" comment.id %}' title="{% trans 'Delete Comment' %}">
<a hx-get="{% url 'allocation-request-delete-comment' comment.id %}" hx-target="#shiftRequestDetailTarget" title="{% trans 'Delete Comment' %}">
<ion-icon name="close-circle-outline" class="text-danger ms-3 mt-1" aria-label="close outline"></ion-icon></a>
</span>
<div>

View File

@@ -72,13 +72,13 @@
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
<div class="oh-btn-group" >
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}?{{pd}}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
hx-swap="innerHTML" class="oh-btn oh-btn--light" data-toggle="oh-modal-toggle" data-target="#shiftcommentModal"
style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
</button>
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}?{{pd}}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
data-target = '#shiftRequestDetailModal' title="{% trans 'View Comment' %}" class="oh-btn oh-btn--light" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="eye-outline" role="img" class="md hydrated" aria-label="eye outline"></ion-icon>
</button>
@@ -251,13 +251,13 @@
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
<div class="oh-btn-group" >
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}?{{pd}}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
hx-swap="innerHTML" class="oh-btn oh-btn--light" data-toggle="oh-modal-toggle" data-target="#shiftcommentModal"
style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
</button>
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}?{{pd}}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
data-target = '#shiftRequestDetailModal' title="{% trans 'View Comment' %}" class="oh-btn oh-btn--light" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="eye-outline" role="img" class="md hydrated" aria-label="eye outline"></ion-icon>
</button>

View File

@@ -209,13 +209,13 @@
<div class="oh-sticky-table__td" onclick="event.stopPropagation();">
<div class="oh-btn-group" >
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
<button type="button" hx-get="{% url 'allocation-request-add-comment' leave_allocation_request.id %}?{{pd}}" title="{% trans 'Add Comment' %}" hx-target="#shiftRequestCommentForm"
hx-swap="innerHTML" class="oh-btn oh-btn--light" data-toggle="oh-modal-toggle" data-target="#shiftcommentModal"
style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="newspaper-outline" role="img" class="md hydrated" aria-label="newspaper outline"></ion-icon>
</button>
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
<button type="button" hx-get="{% url 'allocation-request-view-comment' leave_allocation_request.id %}?{{pd}}" hx-target="#shiftRequestDetailTarget" data-toggle='oh-modal-toggle'
data-target = '#shiftRequestDetailModal' title="{% trans 'View Comment' %}" class="oh-btn oh-btn--light" style="flex: 1 0 auto; width:20px;height: 40.68px; padding: 0;">
<ion-icon name="eye-outline" role="img" class="md hydrated" aria-label="eye outline"></ion-icon>
</button>
@@ -353,23 +353,13 @@
<!-- start of comment modal -->
<div
class="oh-modal"
id="shiftcommentModal"
role="dialog"
aria-labelledby="emptagModal"
aria-hidden="true"
>
<div class="oh-modal__dialog">
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="createModalTitle">
{% trans "Add Comment" %}
</h2>
<button class="oh-modal__close" aria-label="Close">
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body" id="shiftRequestCommentForm"></div>
</div>
class="oh-modal"
id="shiftcommentModal"
role="dialog"
aria-labelledby="emptagModal"
aria-hidden="true"
>
<div class="oh-modal__dialog" id="shiftRequestCommentForm"> </div>
</div>
<!-- end of comment modal -->

View File

@@ -3207,6 +3207,7 @@ def cut_available_leave(request, instance_id):
"""
This method is used to create the penalties
"""
previous_data = request.GET.urlencode()
instance = LeaveRequest.objects.get(id=instance_id)
form = PenaltyAccountForm()
available = AvailableLeave.objects.filter(employee_id=instance.employee_id)
@@ -3230,7 +3231,7 @@ def cut_available_leave(request, instance_id):
return render(
request,
"leave/leave_request/penalty/form.html",
{"available": available, "form": form, "instance": instance},
{"available": available, "form": form, "instance": instance,"pd":previous_data},
)
@@ -3360,6 +3361,7 @@ def create_allocationrequest_comment(request, leave_id):
"""
This method renders form and template to create Allocation request comments
"""
previous_data = request.GET.urlencode()
leave = LeaveAllocationRequest.objects.filter(id=leave_id).first()
emp = request.user.employee_get
form = LeaveallocationrequestcommentForm(
@@ -3427,7 +3429,7 @@ def create_allocationrequest_comment(request, leave_id):
return render(
request,
"leave/leave_allocation_request/allocation_request_comment_form.html",
{"form": form, "request_id": leave_id},
{"form": form, "request_id": leave_id,"pd":previous_data},
)
@@ -3455,7 +3457,8 @@ def delete_allocationrequest_comment(request, comment_id):
"""
This method is used to delete Allocation request comments
"""
LeaveallocationrequestComment.objects.get(id=comment_id).delete()
command = LeaveallocationrequestComment.objects.get(id=comment_id)
request_id = command.request_id.id
command.delete()
messages.success(request, _("Comment deleted successfully!"))
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
return redirect("allocation-request-view-comment",leave_id=request_id)