mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +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)
|
||||
}
|
||||
));
|
||||
|
||||
@@ -1519,6 +1519,11 @@ setprototypeof@1.1.1:
|
||||
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683"
|
||||
integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==
|
||||
|
||||
shortcut-buttons-flatpickr@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/shortcut-buttons-flatpickr/-/shortcut-buttons-flatpickr-0.3.1.tgz#25ec705db8e7c80f0f81f5e160783102775ef529"
|
||||
integrity sha512-zZRLJXF7WSeQJ0ZES+PdD1FI+yjBOufqOQ4AU5przR71Rhyekiw/6/JLA33zOqVkgR7QQ1NbVcuuSqNHHGneEg==
|
||||
|
||||
snapdragon-node@^2.0.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
|
||||
|
||||
Reference in New Issue
Block a user