[UPDT] LEAVE: Refactor forms with Horilla label craft

This commit is contained in:
Horilla
2025-04-02 14:30:50 +05:30
parent 2f87fa2f53
commit 67b1b8abcb
8 changed files with 150 additions and 255 deletions

View File

@@ -13,11 +13,11 @@ from django import forms
from django.apps import apps
from django.core.exceptions import ValidationError
from django.db.models import Q
from django.forms import ModelForm
from django.forms.widgets import TextInput
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from base.forms import ModelForm as BaseModelForm
from base.methods import filtersubordinatesemployeemodel, reload_queryset
from base.models import CompanyLeaves, Holidays
from employee.filters import EmployeeFilter
@@ -49,67 +49,6 @@ CHOICES = [("yes", _("Yes")), ("no", _("No"))]
LEAVE_MAX_LIMIT = 1e5
class ModelForm(forms.ModelForm):
"""
Customized ModelForm class with additional functionality for field customization
based on the type of widget and setting initial values based on the current request.
"""
def __init__(self, *args, **kwargs):
"""
Initializes the ModelForm instance.
This method customizes field attributes such as CSS classes and placeholders
based on the type of widget. It also sets initial values for specific fields
based on the current request, particularly for 'employee_id' and 'company_id' fields.
"""
super().__init__(*args, **kwargs)
request = getattr(horilla_middlewares._thread_locals, "request", None)
reload_queryset(self.fields)
for field_name, field in self.fields.items():
widget = field.widget
if isinstance(widget, (forms.DateInput)):
field.widget.attrs.update({"class": "oh-input oh-calendar-input w-100"})
field.initial = date.today()
elif isinstance(
widget, (forms.NumberInput, forms.EmailInput, forms.TextInput)
):
field.widget.attrs.update(
{"class": "oh-input w-100", "placeholder": field.label}
)
elif isinstance(widget, (forms.Select,)):
field.widget.attrs.update(
{"class": "oh-select oh-select-2 select2-hidden-accessible"}
)
elif isinstance(widget, (forms.Textarea)):
field.widget.attrs.update(
{
"class": "oh-input w-100",
"placeholder": field.label,
"rows": 2,
"cols": 40,
}
)
elif isinstance(
widget,
(
forms.CheckboxInput,
forms.CheckboxSelectMultiple,
),
):
field.widget.attrs.update({"class": "oh-switch__checkbox"})
try:
self.fields["employee_id"].initial = request.user.employee_get
except:
pass
try:
self.fields["company_id"].initial = request.user.employee_get.get_company
except:
pass
class ConditionForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -170,7 +109,7 @@ class LeaveTypeForm(ConditionForm):
filter_template_path="employee_filters.html",
required=False,
),
label="Employee",
label=_("Employee"),
)
class Meta:
@@ -305,7 +244,6 @@ def leaveoverlaping(
)
if len(overlapping_requests) == 1:
existing_leave = overlapping_requests.first()
print("existing_leave =", existing_leave)
if (
existing_leave.start_date == start_date
@@ -318,7 +256,7 @@ def leaveoverlaping(
return overlapping_requests
class LeaveRequestCreationForm(ModelForm):
class LeaveRequestCreationForm(BaseModelForm):
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
@@ -458,7 +396,7 @@ class LeaveRequestCreationForm(ModelForm):
]
class LeaveRequestUpdationForm(ModelForm):
class LeaveRequestUpdationForm(BaseModelForm):
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
@@ -587,7 +525,7 @@ class LeaveRequestUpdationForm(ModelForm):
]
class AvailableLeaveForm(ModelForm):
class AvailableLeaveForm(BaseModelForm):
"""
Form for managing available leave data.
@@ -651,7 +589,7 @@ class LeaveOneAssignForm(HorillaModelForm):
reload_queryset(self.fields)
class AvailableLeaveUpdateForm(ModelForm):
class AvailableLeaveUpdateForm(BaseModelForm):
"""
Form for updating available leave data.
@@ -673,31 +611,7 @@ class AvailableLeaveUpdateForm(ModelForm):
fields = ["available_days", "carryforward_days", "is_active"]
class CompanyLeaveForm(ModelForm):
"""
Form for managing company leave data.
This form allows users to manage company leave data by including all fields from
the CompanyLeaves model except for is_active.
Attributes:
- Meta: Inner class defining metadata options.
- model: The model associated with the form (CompanyLeaves).
- fields: A special value indicating all fields should be included in the form.
- exclude: A list of fields to exclude from the form (is_active).
"""
class Meta:
"""
Meta class for additional options
"""
model = CompanyLeaves
fields = "__all__"
exclude = ["is_active"]
class UserLeaveRequestForm(ModelForm):
class UserLeaveRequestForm(BaseModelForm):
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
description = forms.CharField(label=_("Description"), widget=forms.Textarea)
@@ -878,7 +792,7 @@ class RejectForm(forms.Form):
fields = ["reject_reason"]
class UserLeaveRequestCreationForm(ModelForm):
class UserLeaveRequestCreationForm(BaseModelForm):
start_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
end_date = forms.DateField(widget=forms.DateInput(attrs={"type": "date"}))
@@ -990,7 +904,7 @@ class UserLeaveRequestCreationForm(ModelForm):
}
class LeaveAllocationRequestForm(ModelForm):
class LeaveAllocationRequestForm(BaseModelForm):
"""
Form for creating a leave allocation request.
@@ -1131,7 +1045,7 @@ class AssignLeaveForm(HorillaForm):
self.fields["leave_type_id"].label = "Leave Type"
class LeaverequestcommentForm(ModelForm):
class LeaverequestcommentForm(BaseModelForm):
"""
LeaverequestComment form
"""
@@ -1145,7 +1059,7 @@ class LeaverequestcommentForm(ModelForm):
fields = ("comment",)
class LeaveCommentForm(ModelForm):
class LeaveCommentForm(BaseModelForm):
"""
Leave request comment model form
"""
@@ -1193,7 +1107,7 @@ class LeaveCommentForm(ModelForm):
return instance, files
class LeaveallocationrequestcommentForm(ModelForm):
class LeaveallocationrequestcommentForm(BaseModelForm):
"""
Leave Allocation Requestcomment form
"""
@@ -1207,7 +1121,7 @@ class LeaveallocationrequestcommentForm(ModelForm):
fields = ("comment",)
class LeaveAllocationCommentForm(ModelForm):
class LeaveAllocationCommentForm(BaseModelForm):
"""
Leave request comment model form
"""
@@ -1253,14 +1167,7 @@ class LeaveAllocationCommentForm(ModelForm):
return instance, files
class RestrictLeaveForm(ModelForm):
start_date = forms.DateField(
widget=forms.DateInput(attrs={"type": "date"}),
)
end_date = forms.DateField(
widget=forms.DateInput(attrs={"type": "date"}),
)
class RestrictLeaveForm(BaseModelForm):
def clean_end_date(self):
start_date = self.cleaned_data.get("start_date")
end_date = self.cleaned_data.get("end_date")
@@ -1276,13 +1183,16 @@ class RestrictLeaveForm(ModelForm):
model = RestrictLeave
fields = "__all__"
exclude = ["is_active"]
labels = {
"title": _("Title"),
}
def __init__(self, *args, **kwargs):
super(RestrictLeaveForm, self).__init__(*args, **kwargs)
self.fields["title"].widget.attrs["autocomplete"] = "title"
self.fields["start_date"].widget = forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
)
self.fields["end_date"].widget = forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
)
self.fields["department"].widget.attrs.update(
{
"hx-include": "#leaveRestrictForm",
@@ -1296,7 +1206,7 @@ class RestrictLeaveForm(ModelForm):
if apps.is_installed("attendance"):
from .models import CompensatoryLeaveRequest, CompensatoryLeaverequestComment
class CompensatoryLeaveForm(ModelForm):
class CompensatoryLeaveForm(BaseModelForm):
"""
Form for creating a leave allocation request.
@@ -1417,7 +1327,7 @@ if apps.is_installed("attendance"):
model = CompensatoryLeaveRequest
fields = ["reject_reason"]
class CompensatoryLeaveRequestcommentForm(ModelForm):
class CompensatoryLeaveRequestcommentForm(BaseModelForm):
"""
LeaverequestComment form
"""

View File

@@ -592,6 +592,8 @@ class LeaveRequest(HorillaModel):
class Meta:
ordering = ["-id"]
verbose_name = "Leave Request"
verbose_name_plural = "Leave Requests"
def tracking(self):
return get_diff(self)
@@ -1004,16 +1006,21 @@ class LeaverequestComment(HorillaModel):
class LeaveAllocationRequest(HorillaModel):
leave_type_id = models.ForeignKey(
LeaveType, on_delete=models.PROTECT, verbose_name="Leave type"
LeaveType, on_delete=models.PROTECT, verbose_name=_("Leave type")
)
employee_id = models.ForeignKey(
Employee, on_delete=models.CASCADE, verbose_name="Employee"
Employee, on_delete=models.CASCADE, verbose_name=_("Employee")
)
requested_days = models.FloatField(
blank=True, null=True, verbose_name=_("Requested days")
)
requested_days = models.FloatField(blank=True, null=True)
requested_date = models.DateField(default=timezone.now)
description = models.TextField(max_length=255)
description = models.TextField(max_length=255, verbose_name=_("Description"))
attachment = models.FileField(
null=True, blank=True, upload_to="leave/leave_attachment"
null=True,
blank=True,
upload_to="leave/leave_attachment",
verbose_name=_("Attachment"),
)
status = models.CharField(
max_length=30, choices=LEAVE_ALLOCATION_STATUS, default="requested"
@@ -1031,6 +1038,8 @@ class LeaveAllocationRequest(HorillaModel):
class Meta:
ordering = ["-id"]
verbose_name = _("Leave Allocation Request")
verbose_name_plural = _("Leave Allocation Requests")
def __str__(self):
return f"{self.employee_id}| {self.leave_type_id}| {self.id}"
@@ -1084,7 +1093,7 @@ class LeaveRequestConditionApproval(models.Model):
class RestrictLeave(HorillaModel):
title = models.CharField(max_length=200)
title = models.CharField(max_length=200, verbose_name=_("Title"))
start_date = models.DateField(verbose_name=_("Start Date"))
end_date = models.DateField(verbose_name=_("End Date"))
department = models.ForeignKey(
@@ -1099,18 +1108,20 @@ class RestrictLeave(HorillaModel):
),
)
include_all = models.BooleanField(
default=True, help_text=_("Enable to select all Leave types.")
default=True,
help_text=_("Enable to select all Leave types."),
verbose_name=_("Include All"),
)
spesific_leave_types = models.ManyToManyField(
LeaveType,
verbose_name=_("Spesific leave types"),
verbose_name=_("Specific Leave Types"),
related_name="spesific_leave_type",
blank=True,
help_text=_("Choose specific leave types to restrict."),
)
exclued_leave_types = models.ManyToManyField(
LeaveType,
verbose_name=_("Exclude leave types"),
verbose_name=_("Exclude Leave Types"),
related_name="excluded_leave_type",
blank=True,
help_text=_("Choose leave types to exclude from restriction."),

View File

@@ -1,28 +1,24 @@
{% load i18n %}
{% 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 %}
<div class="oh-modal__dialog-header">
<h2 class="oh-modal__dialog-title" id="createTitle">
{% trans "Create Leave Allocation Request" %}
</h2>
<button class="oh-modal__close" aria-label="Close">
<ion-icon name="close-outline"></ion-icon>
</button>
<h2 class="oh-modal__dialog-title" id="createTitle">
{% trans "Create" %} {{form.verbose_name}}
</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="createTarget">
<form
hx-post="{% url 'leave-allocation-request-create' %}"
hx-target="#objectCreateModalTarget"
hx-encoding="multipart/form-data"
>
{% csrf_token %} {{form.as_p}}
</form>
<form hx-post="{% url 'leave-allocation-request-create' %}" hx-target="#objectCreateModalTarget"
hx-encoding="multipart/form-data">
{% csrf_token %} {{form.as_p}}
</form>
</div>

View File

@@ -1,61 +1,51 @@
{% 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 }}
{% 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--custom").click();
}, 1000);
</script>
</div>
{% endif %}
{% if 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>
{% endfor %}
<script>
setTimeout(function () {
$(".oh-modal__close--custom").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>
{% endif %}
<div class="oh-modal__dialog-header">
<span class="oh-modal__dialog-title" id="updateAssignLeaveModalLabel"
>{% trans "Update Available Leave" %}</span
>
<button
class="oh-modal__close--custom"
onclick="$(this).closest('.oh-modal--show').removeClass('oh-modal--show');"
aria-label="Close"
{% if messages %}
hx-get="{% url 'assign-filter' %}?{{pd}}"
hx-target="#assignedLeaves"
{% endif %}
>
<ion-icon name="close-outline"></ion-icon>
</button>
<span class="oh-modal__dialog-title" id="updateAssignLeaveModalLabel">{% trans "Update Available Leave" %}</span>
<button class="oh-modal__close--custom" onclick="$(this).closest('.oh-modal--show').removeClass('oh-modal--show');"
aria-label="Close" {% if messages %} hx-get="{% url 'assign-filter' %}?{{pd}}" hx-target="#assignedLeaves" {% endif %}>
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body">
<form hx-post="{% url 'available-leave-update' id %}?{{pd}}"
hx-target="#objectUpdateModalTarget"
class="oh-profile-section p-0"
>
<div class="oh-modal__dialog-body pb-2">
<label class="oh-label d-block">{% trans "Available Days" %}</label>
{{form.available_days}} {{form.available_days.errors}}
</div>
<div class="oh-modal__dialog-body pb-2">
<label class="oh-label d-block">{% trans "Carryforward Days" %}</label>
{{form.carryforward_days}} {{form.carryforward_days.errors}}
</div>
<div class="oh-modal__dialog-footer pb-3">
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow">
{% trans "Save" %}
</button>
</div>
</form>
<form hx-post="{% url 'available-leave-update' id %}?{{pd}}" hx-target="#objectUpdateModalTarget"
class="oh-profile-section p-0">
<div class="oh-modal__dialog-body pb-2">
<label for="{{form.available_days.id_for_label}}" class="oh-label d-block">{{form.available_days.label}}</label>
{{form.available_days}} {{form.available_days.errors}}
</div>
<div class="oh-modal__dialog-body pb-2">
<label for="{{form.carryforward_days.id_for_label}}" class="oh-label d-block">{{form.carryforward_days.label}}</label>
{{form.carryforward_days}} {{form.carryforward_days.errors}}
</div>
<div class="oh-modal__dialog-footer pb-3">
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow">
{% trans "Save" %}
</button>
</div>
</form>
</div>

View File

@@ -15,28 +15,15 @@
</div>
{% endif %}
<div class="oh-modal__dialog-header">
<span class="oh-modal__dialog-title" id="objectCreateModalLabel"
>{% trans "Leave Request" %}</span
>
<button
class="oh-modal__close"
aria-label="Close"
{% if messages %}
hx-get="{{hx_url}}"
hx-target="{{hx_target}}"
{% endif %}
>
<span class="oh-modal__dialog-title" id="objectCreateModalLabel">{{form.verbose_name}}</span>
<button class="oh-modal__close" aria-label="Close" {% if messages %} hx-get="{{hx_url}}" hx-target="{{hx_target}}" {% endif %}>
<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
hx-post="{% url 'request-creation' %}?{{pd}}"
hx-encoding="multipart/form-data"
hx-target="#objectCreateModalTarget"
id="leaveRequestCreateForm"
>
<form hx-post="{% url 'request-creation' %}?{{pd}}" hx-encoding="multipart/form-data"
hx-target="#objectCreateModalTarget" id="leaveRequestCreateForm">
{{form.as_p}}
</form>
</div>
@@ -54,12 +41,12 @@
<script>
$("#leaveRequestCreateForm [type=submit]").hide();
var button = `
<div class="oh-modal__dialog-footer p-0 mt-3">
<button id="buttonID" class="oh-btn oh-btn--secondary oh-btn--shadow">
Save
</button>
</div>
`;
<div class="oh-modal__dialog-footer p-0 mt-3">
<button id="buttonID" class="oh-btn oh-btn--secondary oh-btn--shadow">
Save
</button>
</div>
`;
$("#leaveRequestCreateForm .row").after(button);
$(document).ready(function () {
@@ -83,14 +70,14 @@
title = "Leave Request Alert.";
var content = `<div>
<p>${employee} has interview in the requested date.</p>
<ol style="margin-left:5%">`;
interviews.forEach(function (interview, index) {
content += `<li style="text-align:left; font-size:14px">${interview}</li>`;
});
content += `</ol>
<p style="font-weight:700">Are you sure you want to proceed with the request?</p>
</div>`;
<p>${employee} has interview in the requested date.</p>
<ol style="margin-left:5%">`;
interviews.forEach(function (interview, index) {
content += `<li style="text-align:left; font-size:14px">${interview}</li>`;
});
content += `</ol>
<p style="font-weight:700">Are you sure you want to proceed with the request?</p>
</div>`;
if (interviews.length != 0) {
Swal.fire({

View File

@@ -2,40 +2,40 @@
{% 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 class="oh-alert-container">
<div class="oh-alert oh-alert--animated {{ message.tags }}">
{{ message }}
</div>
</div>
</div>
{% endfor %}
<script>
setTimeout(function () {
$(".oh-modal__close").click();
$(".oh-modal__close").click();
}, 1000);
</script>
</div>
<span hx-get="{% url 'restrict-filter' %}?{{pd}}" hx-target="#restrictDays" hx-trigger="load"></span>
{% endif %}
<div class="oh-modal__dialog-header">
<span class="oh-modal__dialog-title" id="editDialogDialog">{% trans "Create Restricted Day" %}</span>
<span class="oh-modal__dialog-title">{% trans "Create Restricted Day" %}</span>
<button class="oh-modal__close" aria-label="Close">
<ion-icon name="close-outline"></ion-icon>
</button>
</div>
<div class="oh-modal__dialog-body">
<form hx-post="{% url 'restrict-creation' %}?{{pd}}" hx-target="#objectCreateModalTarget" class="oh-profile-section" id="leaveRestrictForm">
<label class="oh-label d-block" for="{{ form.title.id_for_label }}">{% trans "Title" %}</label>
<label class="oh-label d-block" for="{{ form.title.id_for_label }}">{{ form.title.label }}</label>
{{form.title}} {{form.title.errors}}
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{% trans "Start Date" %}</label>
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{{ form.start_date.label }}</label>
{{form.start_date}} {{form.start_date.errors}}
</div>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.end_date.id_for_label }}">{% trans "End Date" %}</label>
<label class="oh-label d-block" for="{{ form.end_date.id_for_label }}">{{ form.end_date.label }}</label>
{{form.end_date}} {{form.end_date.errors}}
</div>
</div>
@@ -43,7 +43,7 @@
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.department.id_for_label }}">{% trans "Department" %}</label>
<label class="oh-label d-block" for="{{ form.department.id_for_label }}">{{ form.department.label }}</label>
{{form.department}} {{form.department.errors}}
</div>
</div>
@@ -56,7 +56,7 @@
<!-- Include All Checkbox -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-flex" for="{{ form.include_all.id_for_label }}">{% trans "Include all" %}
<label class="oh-label d-flex" for="{{ form.include_all.id_for_label }}">{{ form.include_all.label }}
<span class="oh-info ms-2" title="{{ form.include_all.help_text|safe }}"></span>
</label>
<div class="oh-switch">
@@ -69,8 +69,9 @@
<!-- Spesific Leave Types Field -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6" id="specific-leave-group" style="display: none;">
<div class="oh-input__group">
<label class="oh-label d-flex" for="{{ form.spesific_leave_types.id_for_label }}">{% trans "Specific Leave Types" %}
<span class="oh-info ms-2" title="{{ form.spesific_leave_types.help_text|safe }}"></span></label>
<label class="oh-label d-flex" for="{{ form.spesific_leave_types.id_for_label }}">{{ form.spesific_leave_types.label }}
<span class="oh-info ms-2" title="{{ form.spesific_leave_types.help_text|safe }}"></span>
</label>
{{ form.spesific_leave_types }} {{ form.spesific_leave_types.errors }}
</div>
</div>
@@ -78,7 +79,7 @@
<!-- Exclude Leave Types Field -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6" id="exclude-leave-group" style="display: none;">
<div class="oh-input__group">
<label class="oh-label d-flex" for="{{ form.exclued_leave_types.id_for_label }}">{% trans "Exclude Leave Types" %}
<label class="oh-label d-flex" for="{{ form.exclued_leave_types.id_for_label }}">{{ form.exclued_leave_types.label }}
<span class="oh-info ms-2" title="{{ form.exclued_leave_types.help_text|safe }}"></span>
</label>
{{ form.exclued_leave_types }} {{ form.exclued_leave_types.errors }}
@@ -86,12 +87,12 @@
</div>
</div>
<label class="oh-label d-block" for="{{ form.description.id_for_label }}">{% trans "Description" %}</label>
<label class="oh-label d-block" for="{{ form.description.id_for_label }}">{{ form.description.label }}</label>
{{form.description}} {{form.description.errors}}
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.company_id.id_for_label }}">{% trans "Company" %}</label>
<label class="oh-label d-block" for="{{ form.company_id.id_for_label }}">{{ form.company_id.label }}</label>
{{form.company_id}} {{form.company_id.errors}}
</div>
</div>
@@ -145,7 +146,7 @@
}
// Add an event listener to the specific leave field to handle its value changes
specificLeaveField.addEventListener('input', function() {
specificLeaveField.addEventListener('input', function () {
if (specificLeaveField.value.trim()) {
// If there's a value, remove the required attribute
specificLeaveField.removeAttribute('required');

View File

@@ -24,18 +24,18 @@
</div>
<div class="oh-modal__dialog-body">
<form hx-post="{% url 'restrict-update' id %}?{{pd}}" hx-target="#objectUpdateModalTarget" class="oh-profile-section">
<label class="oh-label d-block" for="{{ form.title.id_for_label }}">{% trans "Title" %}</label>
<label class="oh-label d-block" for="{{ form.title.id_for_label }}">{{ form.title.label }}</label>
{{form.title}} {{form.title.errors}}
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{% trans "Start Date" %}</label>
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{{ form.start_date.label }}</label>
{{form.start_date}} {{form.start_date.errors}}
</div>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.end_date.id_for_label }}">{% trans "End Date" %}</label>
<label class="oh-label d-block" for="{{ form.end_date.id_for_label }}">{{ form.end_date.label }}</label>
{{form.end_date}} {{form.end_date.errors}}
</div>
</div>
@@ -43,7 +43,7 @@
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{% trans "Department" %}</label>
<label class="oh-label d-block" for="{{ form.start_date.id_for_label }}">{{ form.department.label }}</label>
{{form.department}} {{form.department.errors}}
</div>
</div>
@@ -56,7 +56,7 @@
<!-- Include All Checkbox -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.include_all.id_for_label }}">{% trans "Include all" %}</label>
<label class="oh-label d-block" for="{{ form.include_all.id_for_label }}">{{ form.include_all.label }}</label>
<div class="oh-switch">
{{ form.include_all }} <!-- Checkbox -->
</div>
@@ -67,7 +67,7 @@
<!-- Spesific Leave Types Field -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6" id="specific-leave-group" style="display: none;">
<div class="oh-input__group">
<label class="oh-label d-flex" for="{{ form.spesific_leave_types.id_for_label }}">{% trans "Specific Leave Types" %}
<label class="oh-label d-flex" for="{{ form.spesific_leave_types.id_for_label }}">{{ form.spesific_leave_types.label }}
<span class="oh-info ms-2" title="{{ form.spesific_leave_types.help_text|safe }}"></span></label>
{{ form.spesific_leave_types }} {{ form.spesific_leave_types.errors }}
</div>
@@ -76,7 +76,7 @@
<!-- Exclude Leave Types Field -->
<div class="col-12 col-sm-12 col-md-6 col-lg-6" id="exclude-leave-group" style="display: none;">
<div class="oh-input__group">
<label class="oh-label d-flex" for="{{ form.exclued_leave_types.id_for_label }}">{% trans "Exclude Leave Types" %}
<label class="oh-label d-flex" for="{{ form.exclued_leave_types.id_for_label }}">{{ form.exclued_leave_types.label }}
<span class="oh-info ms-2" title="{{ form.exclued_leave_types.help_text|safe }}"></span>
</label>
{{ form.exclued_leave_types }} {{ form.exclued_leave_types.errors }}
@@ -85,12 +85,12 @@
</div>
<label class="oh-label d-block" for="{{ form.description.id_for_label }}">{% trans "Description" %}</label>
<label class="oh-label d-block" for="{{ form.description.id_for_label }}">{{ form.description.label }}</label>
{{form.description}} {{form.description.errors}}
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-6">
<div class="oh-input__group">
<label class="oh-label d-block" for="{{ form.company_id.id_for_label }}">{% trans "Company" %}</label>
<label class="oh-label d-block" for="{{ form.company_id.id_for_label }}">{{ form.company_id.label }}</label>
{{form.company_id}} {{form.company_id.errors}}
</div>
</div>

View File

@@ -16,7 +16,7 @@
{% endif %}
<div class="oh-modal__dialog-header">
<span class="oh-modal__dialog-title" id="requestCreateModalLabel"
>{% trans "Leave Request" %}</span
>{{form.verbose_name}}</span
>
<button
class="oh-modal__close"