mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
introduce "Now" button
Throught the plugin: https://github.com/jcsmorais/shortcut-buttons-flatpickr import js library via yarn
This commit is contained in:
@@ -1,7 +1,24 @@
|
||||
$(document).ready(function(){
|
||||
window.FLATPICKR_DATE_DEFAULT = {
|
||||
dateFormat: Spree.translations.flatpickr_date_format,
|
||||
locale: I18n.locale
|
||||
locale: I18n.locale,
|
||||
plugins: [
|
||||
ShortcutButtonsPlugin({
|
||||
button: [{
|
||||
label: "Today"
|
||||
}],
|
||||
label: "or",
|
||||
onClick: (index, fp) => {
|
||||
let date;
|
||||
switch (index) {
|
||||
case 0:
|
||||
date = new Date();
|
||||
break;
|
||||
}
|
||||
fp.setDate(date);
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
window.FLATPICKR_DATETIME_DEFAULT = Object.assign(
|
||||
{},
|
||||
@@ -9,6 +26,23 @@ $(document).ready(function(){
|
||||
{
|
||||
enableTime: true,
|
||||
time_24hr: true,
|
||||
plugins: [
|
||||
ShortcutButtonsPlugin({
|
||||
button: [{
|
||||
label: "Now"
|
||||
}],
|
||||
label: "or",
|
||||
onClick: (index, fp) => {
|
||||
let date;
|
||||
switch (index) {
|
||||
case 0:
|
||||
date = new Date();
|
||||
break;
|
||||
}
|
||||
fp.setDate(date);
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
);
|
||||
flatpickr(".datetimepicker", window.FLATPICKR_DATETIME_DEFAULT);
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
angular.module("admin.utils").directive "datepicker", ->
|
||||
angular.module("admin.utils").directive "datepicker", ($window, $timeout) ->
|
||||
require: "ngModel"
|
||||
link: (scope, element, attrs, ngModel) ->
|
||||
flatpickr(element, Object.assign({},
|
||||
window.FLATPICKR_DATE_DEFAULT, {
|
||||
onOpen: (selectedDates, dateStr, instance) ->
|
||||
instance.setDate(ngModel.$modelValue)
|
||||
}));
|
||||
$timeout ->
|
||||
flatpickr(element, Object.assign(
|
||||
{},
|
||||
$window.FLATPICKR_DATE_DEFAULT, {
|
||||
onOpen: (selectedDates, dateStr, instance) ->
|
||||
instance.setDate(ngModel.$modelValue)
|
||||
}
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user