[UPDT] HORILLA: Updated multiple forms with date widget

This commit is contained in:
Horilla
2025-09-03 12:53:51 +05:30
parent 748d6dcfa6
commit 95fb8da712
8 changed files with 14 additions and 104 deletions

View File

@@ -413,17 +413,6 @@ class EmployeeKeyResultForm(BaseForm):
]
widgets = {
"employee_objective_id": forms.HiddenInput(),
"start_date": forms.DateInput(
attrs={
"class": "oh-input w-100",
"type": "date",
"required": True,
"onchange": "startDateChange()",
}
),
"end_date": forms.DateInput(
attrs={"class": "oh-input w-100", "type": "date"}
),
}
def as_p(self):
@@ -437,6 +426,7 @@ class EmployeeKeyResultForm(BaseForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
request = getattr(horilla_middlewares._thread_locals, "request", None)
self.fields["start_date"].widget.attrs.update({"onchange": "startDateChange()"})
if self.initial.get("employee_objective_id"):
if (
type(self.initial.get("employee_objective_id")) == int
@@ -580,12 +570,6 @@ class KeyResultForm(ModelForm):
"target_value": forms.NumberInput(
attrs={"class": "oh-input w-100", "required": True}
),
"start_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100", "required": True}
),
"end_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100", "required": True}
),
"progress_type": forms.Select(
attrs={
"class": "oh-select oh-select--lg oh-select-no-search w-100",
@@ -691,12 +675,6 @@ class FeedbackForm(HorillaModelForm):
"review_cycle": forms.TextInput(
attrs={"placeholder": _("Enter a title"), "class": "oh-input w-100"}
),
"start_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
),
"end_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
),
"cyclic_feedback": forms.CheckboxInput(
attrs={
"class": "oh-switch__checkbox",
@@ -958,7 +936,7 @@ class ObjectiveCommentForm(ModelForm):
reload_queryset(self.fields)
class PeriodForm(ModelForm):
class PeriodForm(HorillaModelForm):
"""
A form for creating or updating a Period object.
"""
@@ -975,12 +953,6 @@ class PeriodForm(ModelForm):
"period_name": forms.TextInput(
attrs={"placeholder": "Q1.", "class": "oh-input w-100"}
),
"start_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
),
"end_date": forms.DateInput(
attrs={"type": "date", "class": "oh-input w-100"}
),
}
def __init__(self, *args, **kwargs):
@@ -1024,8 +996,13 @@ class AnonymousFeedbackForm(BaseForm):
class MeetingsForm(BaseForm):
date = forms.DateTimeField(
widget=forms.DateTimeInput(
attrs={"class": "oh-input w-100", "type": "datetime-local"}
format="%Y-%m-%dT%H:%M",
attrs={
"class": "oh-input w-100",
"type": "datetime-local",
},
),
input_formats=["%Y-%m-%dT%H:%M"],
)
class Meta: