Skip to content
Snippets Groups Projects
Verified Commit de31b448 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use default values in date inputs as preselected value for date pickers

Also move initialization of date and time pickers to own functions
parent 8deeee41
No related branches found
No related tags found
1 merge request!369Resolve "Use default values in date inputs as preselected value for datepickers"
Pipeline #3772 failed
$(document).ready( function () {
$("dmc-datetime input").addClass("datepicker");
$("[data-form-control='date']").addClass("datepicker");
$("[data-form-control='time']").addClass("timepicker");
// Initialize sidenav [MAT]
$(".sidenav").sidenav();
function initDatePicker(sel) {
// Initialize datepicker [MAT]
$('.datepicker').datepicker({
format: get_format('SHORT_DATE_FORMAT').toLowerCase().replace('d', 'dd').replace('m', 'mm').replace('y', 'yyyy'),
const format = get_format('SHORT_DATE_FORMAT').toLowerCase().replace('d', 'dd').replace('m', 'mm').replace('y', 'yyyy');
const el = $(sel).datepicker({
format: format,
// Pull translations from Django helpers
i18n: {
months: calendarweek_i18n.month_names,
monthsShort: calendarweek_i18n.month_abbrs,
weekdays: calendarweek_i18n.day_names,
weekdaysShort: calendarweek_i18n.day_abbrs,
weekdaysAbbrev: calendarweek_i18n.day_abbrs.map(([v])=> v),
weekdaysAbbrev: calendarweek_i18n.day_abbrs.map(([v]) => v),
// Buttons
today: gettext('Today'),
......@@ -27,9 +21,13 @@ $(document).ready( function () {
firstDay: get_format('FIRST_DAY_OF_WEEK'),
autoClose: true
});
el.datepicker("setDate", $(sel).val());
return el;
}
function initTimePicker(sel) {
// Initialize timepicker [MAT]
$('.timepicker').timepicker({
return $(sel).timepicker({
twelveHour: false,
autoClose: true,
i18n: {
......@@ -38,6 +36,21 @@ $(document).ready( function () {
done: 'OK'
},
});
}
$(document).ready(function () {
$("dmc-datetime input").addClass("datepicker");
$("[data-form-control='date']").addClass("datepicker");
$("[data-form-control='time']").addClass("timepicker");
// Initialize sidenav [MAT]
$(".sidenav").sidenav();
// Initialize datepicker [MAT]
initDatePicker(".datepicker");
// Initialize timepicker [MAT]
initTimePicker(".timepicker");
// Initialize tooltip [MAT]
$('.tooltipped').tooltip();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment