diff options
Diffstat (limited to 'web_src/js')
-rw-r--r-- | web_src/js/features/datetimepicker.js | 8 | ||||
-rw-r--r-- | web_src/js/index.js | 14 |
2 files changed, 16 insertions, 6 deletions
diff --git a/web_src/js/features/datetimepicker.js b/web_src/js/features/datetimepicker.js new file mode 100644 index 0000000000..fb9a75a57a --- /dev/null +++ b/web_src/js/features/datetimepicker.js @@ -0,0 +1,8 @@ +export default async function initDateTimePicker(locale) { + await Promise.all([ + import(/* webpackChunkName: "datetimepicker" */'jquery-datetimepicker'), + import(/* webpackChunkName: "datetimepicker" */'jquery-datetimepicker/build/jquery.datetimepicker.min.css'), + ]); + + $.datetimepicker.setLocale(locale); +} diff --git a/web_src/js/index.js b/web_src/js/index.js index 455e6cc3ff..2db5b08b8b 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -15,6 +15,7 @@ import initHighlight from './features/highlight.js'; import initGitGraph from './features/gitgraph.js'; import initClipboard from './features/clipboard.js'; import initUserHeatmap from './features/userheatmap.js'; +import initDateTimePicker from './features/datetimepicker.js'; import createDropzone from './features/dropzone.js'; import ActivityTopAuthors from './components/ActivityTopAuthors.vue'; @@ -633,7 +634,7 @@ function initIssueComments() { }); } -function initRepository() { +async function initRepository() { if ($('.repository').length === 0) { return; } @@ -731,15 +732,16 @@ function initRepository() { // Milestones if ($('.repository.new.milestone').length > 0) { const $datepicker = $('.milestone.datepicker'); + + await initDateTimePicker($datepicker.data('lang')); + $datepicker.datetimepicker({ - lang: $datepicker.data('lang'), inline: true, timepicker: false, startDate: $datepicker.data('start-date'), - formatDate: 'Y-m-d', - onSelectDate(ct) { - $('#deadline').val(ct.dateFormat('Y-m-d')); - } + onSelectDate(date) { + $('#deadline').val(date.toISOString().substring(0, 10)); + }, }); $('#clear-date').click(() => { $('#deadline').val(''); |