-
Notifications
You must be signed in to change notification settings - Fork 168
Replace bootstrap-datetimepicker #2608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
982e7e3
96ef45f
8eb3d24
6439923
79d0852
20219d4
1552cdc
979ae27
f40355d
1f4a889
ae3619a
73f0337
1c4eb9d
e49ebf5
b99dbc9
98ca7b0
b01f1e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <div class="input-group" id="datepicker1" data-td-target-input="nearest" data-td-target-toggle="nearest"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do we use this for anything? If not, let's just remove it. Otherwise, we have to use some other mechanism to identify these elements (probably classes)? |
||
| <input id="datetimepickerInput" | ||
| type="text" | ||
| class="form-control" | ||
| data-td-target="#datetimepicker" | ||
| name="{{ widget.name }}" | ||
| {% if widget.value and widget.value != 'None' %} | ||
| value="{{ widget.value }}"{% endif %} | ||
| {% include 'django/forms/widgets/attrs.html' %} | ||
| /> | ||
| <span class="input-group-text" data-td-target="#datetimepicker" data-td-toggle="datetimepicker"> | ||
| <i class="fas fa-calendar"></i> | ||
| </span> | ||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <div class="input-group" id="datetimepicker" data-td-target-input="nearest" data-td-target-toggle="nearest"> | ||
| <input id="datetimepickerInput" | ||
| type="text" | ||
| class="form-control" | ||
| data-td-target="#datetimepicker" | ||
| name="{{ widget.name }}" | ||
| {% if widget.value and widget.value != 'None' %} | ||
| value="{{ widget.value }}"{% endif %} | ||
| {% include 'django/forms/widgets/attrs.html' %} | ||
| /> | ||
| <span class="input-group-text" data-td-target="#datetimepicker" data-td-toggle="datetimepicker"> | ||
| <i class="fas fa-calendar"></i> | ||
| </span> | ||
| </div> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,3 @@ | |
| } | ||
| } | ||
| </script> | ||
|
|
||
| {% block additional_javascript %} | ||
| {% include 'bootstrap_datetimepicker.html' %} | ||
| {% endblock %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -99,8 +99,19 @@ def clean(self): | |
| class ImportForm(forms.Form): | ||
| use_required_attribute = False | ||
|
|
||
| vote_start_datetime = forms.DateTimeField(label=_("Start of evaluation"), localize=True, required=False) | ||
| vote_end_date = forms.DateField(label=_("End of evaluation"), localize=True, required=False) | ||
| vote_start_datetime = forms.DateTimeField( | ||
| label=_("Start of evaluation"), | ||
| widget=forms.DateTimeInput(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? I would have expected tht |
||
| localize=True, | ||
| required=False, | ||
| ) | ||
|
|
||
| vote_end_date = forms.DateField( | ||
| label=_("End of evaluation"), | ||
| widget=forms.DateInput(attrs={"type": "date", "class": "form-control"}), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we need |
||
| localize=True, | ||
| required=False, | ||
| ) | ||
|
|
||
| excel_file = forms.FileField( | ||
| label=_("Excel file"), | ||
|
|
@@ -283,8 +294,18 @@ def __init__(self, *args, **kwargs): | |
|
|
||
| class CourseCopyForm(CourseFormMixin, forms.ModelForm): # type: ignore[misc] | ||
| semester = forms.ModelChoiceField(Semester.objects.all()) | ||
| vote_start_datetime = forms.DateTimeField(label=_("Start of evaluations"), localize=True) | ||
| vote_end_date = forms.DateField(label=_("Last day of evaluations"), localize=True) | ||
|
|
||
| vote_start_datetime = forms.DateTimeField( | ||
| label=_("Start of evaluations"), | ||
| localize=True, | ||
| widget=forms.DateTimeInput(), | ||
| ) | ||
|
|
||
| vote_end_date = forms.DateField( | ||
| label=_("Last day of evaluations"), | ||
| localize=True, | ||
| widget=forms.DateInput(attrs={"type": "date", "class": "form-control"}), | ||
| ) | ||
|
|
||
| field_order = ["semester"] | ||
|
|
||
|
|
@@ -401,6 +422,10 @@ class Meta: | |
| field_classes = { | ||
| "participants": UserModelMultipleChoiceField, | ||
| } | ||
| widgets = { | ||
| "vote_start_datetime": forms.DateTimeInput(), | ||
| "vote_end_date": forms.DateInput(attrs={"type": "date", "class": "form-control"}), | ||
| } | ||
|
|
||
| def __init__(self, *args, requires_decided_main_language=False, **kwargs): | ||
| semester = kwargs.pop("semester", None) | ||
|
|
||
This file was deleted.
This file was deleted.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| // fix datetimepicker time selector width | ||
| .time-container-clock, | ||
| .time-container-hour, | ||
| .time-container-minute { | ||
| width: 100%; | ||
| } | ||
|
|
||
| /* Overall widget wider */ | ||
| .tempus-dominus-widget.timepicker-sbs { | ||
| width: auto !important; | ||
| max-width: 540px; | ||
| } | ||
|
|
||
| /* Time container - wider to accommodate bigger inner elements */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container { | ||
| flex: 0 0 160px !important; | ||
| width: 160px !important; | ||
| padding: 6px !important; | ||
| display: flex !important; | ||
| flex-direction: column; | ||
| justify-content: center !important; | ||
| align-items: center !important; | ||
| } | ||
|
|
||
| /* Clock - vertical centering */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock { | ||
| padding: 0 !important; | ||
| margin: 0 !important; | ||
| display: flex !important; | ||
| flex-direction: column; | ||
| justify-content: center !important; | ||
| align-items: center !important; | ||
| } | ||
|
|
||
| /* Hour/Minute display - WIDER to fill horizontal space */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock .hour, | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock .minute { | ||
|
Comment on lines
+36
to
+37
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't find the |
||
| min-width: 65px !important; /* Increased from 50px */ | ||
| width: 65px !important; /* Increased from 50px */ | ||
| font-size: 1.2em !important; | ||
| padding: 4px !important; | ||
| } | ||
|
|
||
| /* Up/down buttons - WIDER to match hour/minute width */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock button { | ||
| min-width: 65px !important; /* Increased from 50px */ | ||
| width: 65px !important; /* Increased from 50px */ | ||
| padding: 6px 8px !important; | ||
| margin: 2px !important; | ||
| } | ||
|
|
||
| /* Clock face - LARGER */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock .clock-face { | ||
| width: 110px !important; | ||
| height: 110px !important; | ||
| } | ||
|
|
||
| /* Separator between hour/minute */ | ||
| .tempus-dominus-widget.timepicker-sbs .time-container .clock .separator { | ||
| padding: 0 8px !important; | ||
| font-size: 1.2em !important; | ||
| } | ||
|
|
||
| /* Date container */ | ||
| .tempus-dominus-widget.timepicker-sbs .date-container { | ||
| flex: 1 1 auto; | ||
| min-width: 290px; | ||
| } | ||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { tempusDominus } from "./tempus-dominus.js"; | ||
|
|
||
| document.addEventListener("DOMContentLoaded", () => { | ||
| const pickerElements = document.querySelectorAll<HTMLElement>("[id^='datepicker']"); | ||
| pickerElements.forEach(pickerElement => { | ||
| const inputElement = pickerElement.querySelector("input"); | ||
| if (!inputElement) { | ||
| return; | ||
| } | ||
|
|
||
| const toggleElement = pickerElement.querySelector("[data-td-toggle]"); | ||
| if (!toggleElement) { | ||
| return; | ||
| } | ||
|
|
||
| const picker = new tempusDominus.TempusDominus(pickerElement, { | ||
| display: { | ||
| theme: "light", | ||
| icons: { | ||
| time: "fa fa-clock", | ||
| date: "fa fa-calendar", | ||
| up: "fa fa-arrow-up", | ||
| down: "fa fa-arrow-down", | ||
| previous: "fa fa-chevron-left", | ||
| next: "fa fa-chevron-right", | ||
| today: "fa fa-calendar-check", | ||
| clear: "fa fa-trash", | ||
| close: "fa fa-times", | ||
| }, | ||
| components: { | ||
| clock: false, | ||
| hours: false, | ||
| minutes: false, | ||
| seconds: false, | ||
| }, | ||
| }, | ||
| localization: { | ||
| format: "yyyy-MM-dd", | ||
| startOfTheWeek: 1, | ||
| hourCycle: "h23", | ||
| }, | ||
| }); | ||
|
|
||
| const openPicker = (): void => { | ||
| picker.show(); | ||
| }; | ||
|
|
||
| inputElement.addEventListener("click", openPicker); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.