From 8c4780c3072088c0223aeb7af1278097d74007a8 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 8 Sep 2021 11:15:00 +0000 Subject: [PATCH] Bug 28983: Use Flatpickr on various pages This patch replaces the use of jQueryUI's datepicker on various unrelated pages. To test, apply the patch and test the following pages to confirm that datepickers work correctly. "Linked" date fields should prevent a "to" selection which preceeds the selected "from" date. - Tools -> Patron clubs -> New club: Linked "start date" and "end date" fields. - ILL requests: Two linked pairs of date fields in the sidebar, "Date placed between" and "Updated between." Each pair should work correctly and table filtering by date should work correctly. - Tools -> Label creator -> Manage -> Layout batches -> Edit a batch -> Add items. This should trigger a popup window with a linked pair of date fields, "Added on or after date," and "Added on or before date." - Point of sale -> Transaction history: "From" and "To" linked date field in the "Older transactions" section. - Acquisitions -> Suggestions -> Add a suggestion: "Created by," "Accepted on," and "Managed by" fields. - Tools -> Tags -> Filter tags by date. Signed-off-by: David Nind --- .../prog/en/modules/clubs/clubs-add-modify.tt | 4 +-- .../prog/en/modules/ill/ill-requests.tt | 8 ++--- .../prog/en/modules/labels/search.tt | 21 ++++++------ .../prog/en/modules/pos/register.tt | 21 ++---------- .../prog/en/modules/suggestion/suggestion.tt | 6 ++-- .../prog/en/modules/tags/review.tt | 4 +-- .../intranet-tmpl/prog/js/ill-list-table.js | 34 ++++++++++++++++--- 7 files changed, 54 insertions(+), 44 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt index 8d89d44b4d..6a2b51a184 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/clubs-add-modify.tt @@ -73,12 +73,12 @@
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 64336f5c4e..2f304484f1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -73,19 +73,19 @@
  • - +
  • - +
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt index a6f905d2ec..aee3f2ffc7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt @@ -88,16 +88,17 @@ to add to Batch [% batch_id | html %]
      -
    1. - - -
      [% INCLUDE 'date-format.inc' %]
      -
    2. -
    3. - - -
      [% INCLUDE 'date-format.inc' %]
      -
    +
  • + + +
    [% INCLUDE 'date-format.inc' %]
    +
  • +
  • + + +
    [% INCLUDE 'date-format.inc' %]
    +
  • +
    Cancel
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt index bdef70e02a..b3f4a43536 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -160,9 +160,9 @@
    1. - + - + [% INCLUDE 'date-format.inc' %]
    @@ -471,23 +471,6 @@ } ] }, [], 1); - - $(document).ready(function() { - // http://jqueryui.com/demos/datepicker/#date-range - var dates = $( "#from, #to" ).datepicker({ - changeMonth: true, - numberOfMonths: 1, - onSelect: function( selectedDate ) { - var option = this.id == "from" ? "minDate" : "maxDate", - instance = $( this ).data( "datepicker" ); - date = $.datepicker.parseDate( - instance.settings.dateFormat || - $.datepicker._defaults.dateFormat, - selectedDate, instance.settings ); - dates.not( this ).datepicker( "option", option, date ); - } - }); - }); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index 416623a846..ad00aff2ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -500,7 +500,7 @@ - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %] @@ -517,7 +517,7 @@ - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %] @@ -547,7 +547,7 @@
  • - [% INCLUDE 'date-format.inc' %] + [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt index 3f20d5e9fb..261604f205 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -230,11 +230,11 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
  • - +
    [% INCLUDE 'date-format.inc' %]
    - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js index abd01861a7..2c39ad7aba 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -335,6 +335,32 @@ $(document).ready(function() { $('#addcomment').toggleClass('content_hidden'); }); + var illfilter_dateplaced_start = $("#illfilter_dateplaced_start").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + illfilter_dateplaced_end.set('minDate', selectedDates[0]); + } + }); + + var illfilter_dateplaced_end = $("#illfilter_dateplaced_end").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + }, + }); + + var illfilter_datemodified_start = $("#illfilter_datemodified_start").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + illfilter_datemodified_end.set('minDate', selectedDates[0]); + } + }); + + var illfilter_datemodified_end = $("#illfilter_datemodified_end").flatpickr({ + onClose: function( selectedDates, dateText, instance) { + validate_date( selectedDates, instance ); + }, + }); + // Filter partner list // Record the list of all options var ill_partner_options = $('#partners > option'); @@ -498,10 +524,10 @@ $(document).ready(function() { // Custom date range filtering $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) { - var placedStart = $('#illfilter_dateplaced_start').datepicker('getDate'); - var placedEnd = $('#illfilter_dateplaced_end').datepicker('getDate'); - var modifiedStart = $('#illfilter_datemodified_start').datepicker('getDate'); - var modifiedEnd = $('#illfilter_datemodified_end').datepicker('getDate'); + var placedStart = illfilter_dateplaced_start.selectedDates[0]; + var placedEnd = illfilter_dateplaced_end.selectedDates[0]; + var modifiedStart = illfilter_datemodified_start.selectedDates[0]; + var modifiedEnd = illfilter_datemodified_end.selectedDates[0]; var rowPlaced = data[14] ? new Date(data[14]) : null; var rowModified = data[16] ? new Date(data[16]) : null; var placedPassed = true; -- 2.20.1