Bugzilla – Attachment 127920 Details for
Bug 29478
flatpickr misses quick shortcut to "Today" date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29478: Flatpickr - Restore 'Today' button
Bug-29478-Flatpickr---Restore-Today-button.patch (text/plain), 4.88 KB, created by
Martin Renvoize (ashimema)
on 2021-11-22 10:36:00 UTC
(
hide
)
Description:
Bug 29478: Flatpickr - Restore 'Today' button
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-22 10:36:00 UTC
Size:
4.88 KB
patch
obsolete
>From 60860fd12fe5a6d34185e5794cb1d900732c5fc8 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 15 Nov 2021 10:59:08 +0100 >Subject: [PATCH] Bug 29478: Flatpickr - Restore 'Today' button > >It's not implemented, looks like we need to use a plugin for that > >https://github.com/flatpickr/flatpickr/issues/576 > >https://github.com/jcsmorais/shortcut-buttons-flatpickr > >Test plan: >Confirm that flatpickr instances now have a yesterday, today and >tomorrow buttons. > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../shortcut-buttons-flatpickr.min.js | 2 ++ > .../prog/en/includes/calendar.inc | 33 +++++++++++++++++++ > 2 files changed, 35 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/lib/flatpickr/shortcut-buttons-flatpickr.min.js > >diff --git a/koha-tmpl/intranet-tmpl/lib/flatpickr/shortcut-buttons-flatpickr.min.js b/koha-tmpl/intranet-tmpl/lib/flatpickr/shortcut-buttons-flatpickr.min.js >new file mode 100644 >index 0000000000..55c5023eb9 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/flatpickr/shortcut-buttons-flatpickr.min.js >@@ -0,0 +1,2 @@ >+!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ShortcutButtonsPlugin=e():t.ShortcutButtonsPlugin=e()}(window,function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:o})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const o={theme:"light"};e.ShortcutButtonsPlugin=function(t){const e=Object.assign({},o,t);return t=>{let n;function o(n){n.stopPropagation(),n.preventDefault();const o=n.target;if("button"!==o.tagName.toLowerCase()||void 0===e.onClick)return;const r=parseInt(o.dataset.index,10),c=Array.isArray(e.onClick)?e.onClick:[e.onClick];for(const e of c)"function"==typeof e&&e(r,t)}return{onReady:()=>{if((n=document.createElement("div")).classList.add("shortcut-buttons-flatpickr-wrapper",e.theme),void 0!==e.label&&e.label.length){const t=document.createElement("div");t.classList.add("shortcut-buttons-flatpickr-label"),t.textContent=e.label,n.appendChild(t)}const r=document.createElement("div");r.classList.add("shortcut-buttons-flatpickr-buttons"),(Array.isArray(e.button)?e.button:[e.button]).forEach((t,e)=>{const n=document.createElement("button");n.classList.add("shortcut-buttons-flatpickr-button"),n.textContent=t.label,n.dataset.index=String(e),r.appendChild(n)}),n.appendChild(r),t.calendarContainer.appendChild(n),n.addEventListener("click",o)},onDestroy:()=>{n.removeEventListener("click",o),n=void 0}}}}}]).ShortcutButtonsPlugin}); >+//# sourceMappingURL=shortcut-buttons-flatpickr.min.js.map >\ No newline at end of file >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index eebb7ff699..ac17aa8325 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -34,6 +34,7 @@ > <!-- / calendar.inc --> > [% Asset.js("js/calendar.js") | $raw %] > [% Asset.js("lib/flatpickr/flatpickr.min.js") | $raw %] >+[% Asset.js("lib/flatpickr/shortcut-buttons-flatpickr.min.js") | $raw %] > <script> > flatpickr.l10ns.default.weekdays = flatpickr_weekdays; > flatpickr.l10ns.default.months = flatpickr_months; >@@ -84,6 +85,38 @@ > $(on_close_focus).focus(); > } > }, >+ plugins: [ >+ ShortcutButtonsPlugin({ >+ button: [ >+ { >+ label: __("Yesterday") >+ }, >+ { >+ label: __("Today") >+ }, >+ { >+ label: __("Tomorrow") >+ } >+ ], >+ label: "or", >+ onClick: (index, fp) => { >+ let date; >+ switch (index) { >+ case 0: >+ date = new Date(Date.now() - 24 * 60 * 60 * 1000); >+ break; >+ case 1: >+ date = new Date(); >+ break; >+ case 2: >+ date = new Date(Date.now() + 24 * 60 * 60 * 1000); >+ break; >+ } >+ date.setHours(23, 59, 0, 0); >+ fp.setDate(date); >+ } >+ }) >+ ] > }); > $(document).ready(function(){ > $(".flatpickr").each(function(){ >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29478
:
127626
|
127676
|
127694
|
127721
|
127722
|
127730
|
127804
|
127850
|
127890
|
127891
|
127892
|
127893
| 127920 |
127921
|
127922
|
127923
|
127968