Skip to content
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

Pickadate format based on js format #242

Merged
merged 13 commits into from
Jun 19, 2024
12 changes: 6 additions & 6 deletions NEMO/apps/kiosk/templates/kiosk/tool_reservation.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ <h4>When would you like to reserve the {{ tool }}?</h4>
{% for item in tool_reservation_times %}
unavailable_times.push([{{ item.start|date:"U" }},{{ item.end|date:"U" }}]);
{% endfor %}
let date_picker = $('#date').pickadate({format: "{{ pick_date_format }}", formatSubmit: "yyyy-mm-dd", firstDay: 1, hiddenName: true, onSet: refresh_times});
let start_time_picker = $('#start').pickatime({interval: 15, format: "{{ pick_time_format }}", formatSubmit: "HH:i", hiddenName: true, formatLabel: format_label});
let end_time_picker = $('#end').pickatime({interval: 15, format: "{{ pick_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label});
let date_picker = $('#date').pickadate({format: "{{ pickadata_date_format }}", formatSubmit: "yyyy-mm-dd", firstDay: 1, hiddenName: true, onSet: refresh_times});
r-xyz marked this conversation as resolved.
Show resolved Hide resolved
let start_time_picker = $('#start').pickatime({interval: 15, format: "{{ pickadate_time_format }}", formatSubmit: "HH:i", hiddenName: true, formatLabel: format_label});
rptmat57 marked this conversation as resolved.
Show resolved Hide resolved
let end_time_picker = $('#end').pickatime({interval: 15, format: "{{ pickadate_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label});
// set initial date
if ('{{ date|default_if_none:'' }}') {
date_picker.pickadate('picker').set('select', '{{ date }}', {format: 'yyyy-mm-dd'})
date_picker.pickadate('picker').set('select', '{{ date }}', {format: '{{ pickadate_time_format }}'})
rptmat57 marked this conversation as resolved.
Show resolved Hide resolved
}
function refresh_times() {
start_time_picker.pickatime('picker').render();
Expand All @@ -77,11 +77,11 @@ <h4>When would you like to reserve the {{ tool }}?</h4>
let start = times[0];
let end = times[1];
if (date_time_selected >= start && date_time_selected < end) {
return '<sp !an>{{ pick_time_format }}</sp !an> <sm !all> !alre!ad!y re!serve!d</sm !all>';
return '<sp !an>{{ pickadate_time_format }}</sp !an> <sm !all> !alre!ad!y re!serve!d</sm !all>';
}
}
}
return '{{ pick_time_format }}';
return '{{ pickadate_time_format }}';
}
revert(120)
</script>
8 changes: 4 additions & 4 deletions NEMO/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
date_input_js_format,
datetime_input_js_format,
time_input_js_format,
date_pick_format,
time_pick_format,
pickadate_date_format,
pickadate_time_format,
)
from NEMO.views.customization import CustomizationBase
from NEMO.views.notifications import get_notification_counts
Expand Down Expand Up @@ -90,8 +90,8 @@ def base_context(request):
"time_input_js_format": time_input_js_format,
"date_input_js_format": date_input_js_format,
"datetime_input_js_format": datetime_input_js_format,
"date_pick_format": date_pick_format,
"time_pick_format": time_pick_format,
"pickadate_date_format": pickadate_date_format,
"pickadate_time_format": pickadatetime_format,
r-xyz marked this conversation as resolved.
Show resolved Hide resolved
"no_header": request.session.get("no_header", False),
"safety_menu_item": customization_values.get("safety_main_menu") == "enabled",
"calendar_page_title": customization_values.get("calendar_page_title"),
Expand Down
12 changes: 6 additions & 6 deletions NEMO/templates/mobile/new_reservation.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ <h4>When would you like to reserve the {{ item }}?</h4>
{% for times in item_reservation_times %}
unavailable_times.push([{{ times.start|date:"U" }},{{ times.end|date:"U" }}]);
{% endfor %}
let date_picker = $('#date').pickadate({format: "{{ pick_date_format }}", formatSubmit: "yyyy-mm-dd", firstDay: 1, hiddenName: true, onSet: refresh_times});
let start_time_picker = $('#start').pickatime({interval: 15, format: "{{ pick_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label });
let end_time_picker = $('#end').pickatime({interval: 15, format: "{{ pick_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label});
let date_picker = $('#date').pickadate({format: "{{ pickadate_date_format }}", formatSubmit: "yyyy-mm-dd", firstDay: 1, hiddenName: true, onSet: refresh_times});
let start_time_picker = $('#start').pickatime({interval: 15, format: "{{ pickadate_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label });
rptmat57 marked this conversation as resolved.
Show resolved Hide resolved
let end_time_picker = $('#end').pickatime({interval: 15, format: "{{ pickadate_time_format }}", formatSubmit: "H:i", hiddenName: true, formatLabel: format_label});
// set initial date
if ('{{ date|default_if_none:'' }}')
{
date_picker.pickadate('picker').set('select', '{{ date }}', {format: 'yyyy-mm-dd'})
date_picker.pickadate('picker').set('select', '{{ date }}', {format: '{{ pickadate_date_format }}'})
}
function refresh_times()
{
Expand All @@ -93,11 +93,11 @@ <h4>When would you like to reserve the {{ item }}?</h4>
let start = times[0];
let end = times[1];
if (date_time_selected >= start && date_time_selected < end) {
return '<sp !an>{{ pick_time_format }}</sp !an> <sm !all> !alre!ad!y re!serve!d</sm !all>';
return '<sp !an>{{ pickadate_time_format }}</sp !an> <sm !all> !alre!ad!y re!serve!d</sm !all>';
}
}
}
return "{{ pick_time_format }}";
return "{{ pickadate_time_format }}";
}

</script>
Expand Down
4 changes: 2 additions & 2 deletions NEMO/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def convert_py_to_pick_time(string_format: str) -> str:
time_input_js_format = convert_py_format_to_js(time_input_format)
date_input_js_format = convert_py_format_to_js(date_input_format)
datetime_input_js_format = convert_py_format_to_js(datetime_input_format)
date_pick_format = convert_py_to_pick_time(date_input_format)
time_pick_format = convert_py_to_pick_time(time_input_format)
pickadate_date_format = convert_py_to_pick_time(date_input_format)
pickadate_time_format = convert_py_to_pick_time(time_input_format)

supported_embedded_video_extensions = [".mp4", ".ogv", ".webm", ".3gp"]
supported_embedded_pdf_extensions = [".pdf"]
Expand Down