From 30196fcdf3f5d726ad79c4f8983b17e9ad06b46a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 14 Oct 2021 15:06:30 +0100 Subject: [PATCH] Bug 29240: Centralise from/to handling This patch moves to using a data-start_for attribute to point the 'from' flatpickr to the 'to' flatpickr. We also fix the date validation issue in the onClose handler inline. Test plan. 1. Check that the from/to datpicker combinations work on each of the changed pages. 2. Look at the console for errors, there should be none Signed-off-by: Owen Leonard Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart --- .../prog/en/includes/calendar.inc | 19 ++++------ .../prog/en/includes/filter-orders.inc | 4 +-- .../prog/en/modules/acqui/invoices.tt | 30 +++------------- .../prog/en/modules/acqui/lateorders.tt | 4 +-- .../prog/en/modules/admin/aqbudgetperiods.tt | 8 ++--- .../prog/en/modules/admin/aqcontract.tt | 4 +-- .../prog/en/modules/circ/overdue.tt | 4 +-- .../prog/en/modules/circ/pendingreserves.tt | 4 +-- .../prog/en/modules/circ/reserveratios.tt | 4 +-- .../prog/en/modules/clubs/clubs-add-modify.tt | 4 +-- .../prog/en/modules/ill/ill-requests.tt | 8 ++--- .../prog/en/modules/labels/search.tt | 4 +-- .../prog/en/modules/members/memberentrygen.tt | 6 ++-- .../prog/en/modules/pos/register.tt | 4 +-- .../en/modules/reports/acquisitions_stats.tt | 35 +++---------------- .../en/modules/reports/cash_register_stats.tt | 4 +-- .../prog/en/modules/reports/dictionary.tt | 4 +-- .../prog/en/modules/reports/issues_stats.tt | 4 +-- .../prog/en/modules/serials/claims.tt | 4 +-- .../en/modules/serials/subscription-add.tt | 4 +-- .../modules/serials/subscription-history.tt | 4 +-- .../prog/en/modules/tags/review.tt | 4 +-- .../en/modules/tools/additional-contents.tt | 4 +-- .../modules/tools/batch_extend_due_dates.tt | 4 +-- .../prog/en/modules/tools/export.tt | 4 +-- .../prog/en/modules/tools/viewlog.tt | 4 +-- .../intranet-tmpl/prog/js/ill-list-table.js | 26 -------------- 27 files changed, 65 insertions(+), 147 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index aef5938d8e..3002796e24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -58,23 +58,16 @@ }); }, onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); + validate_date( dateText, instance ); + var thisInput = instance.input; + if ( thisInput.hasAttribute('data-start_for') ) { + var endPicker = document.querySelector("#"+thisInput.dataset.start_for)._flatpickr; + endPicker.set('minDate', selectedDates[0]); + } }, }); $(document).ready(function(){ $(".flatpickr").flatpickr(); - var startPicker = $(".flatpickrfrom").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - endPicker.set('minDate', selectedDates[0]); - } - }); - var endPicker = $(".flatpickrto").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - }, - }); - }); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc index ef8e38496d..efc1bc0f30 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/filter-orders.inc @@ -103,11 +103,11 @@
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt index 79c3942f30..7ff7b0e3ae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt @@ -297,12 +297,12 @@
    1. - +
      [% INCLUDE 'date-format.inc' %]
    2. - +
      [% INCLUDE 'date-format.inc' %]
    @@ -314,12 +314,12 @@
    1. - +
      [% INCLUDE 'date-format.inc' %]
    2. - +
      [% INCLUDE 'date-format.inc' %]
    @@ -459,28 +459,6 @@ $('#merge_invoices').show(); } }); - var shipmentdatefrom = $("#shipmentdatefrom").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - shipmentdateto.set('minDate', selectedDates[0]); - } - }); - var shipmentdateto = $("#shipmentdateto").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - }, - }); - var billingdatefrom = $("#billingdatefrom").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - billingdateto.set('minDate', selectedDates[0]); - } - }); - var billingdateto = $("#billingdateto").flatpickr({ - onClose: function( selectedDates, dateText, instance) { - validate_date( selectedDates, instance ); - }, - }); }); [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt index c4847c145c..6740629bd2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt @@ -232,11 +232,11 @@
    1. days ago
    2. - +
      [% INCLUDE 'date-format.inc' %]
    3. - +
      [% INCLUDE 'date-format.inc' %]
    4. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt index f2149b50dd..85acd8de7c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqbudgetperiods.tt @@ -189,14 +189,14 @@
    5. - + Required
      [% INCLUDE 'date-format.inc' %]
    6. - + Required
      [% INCLUDE 'date-format.inc' %]
    7. @@ -259,14 +259,14 @@
      1. - + Required
        [% INCLUDE 'date-format.inc' %]
      2. - + Required
        [% INCLUDE 'date-format.inc' %]
      3. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt index 1eee60f12d..c280345068 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/aqcontract.tt @@ -132,12 +132,12 @@
      4.   - + Required
        [% INCLUDE 'date-format.inc' %]
      5.   - + Required
        [% INCLUDE 'date-format.inc' %]
      6. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt index d1ecdca234..9e6077d066 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt @@ -156,11 +156,11 @@
      7. - +
      8. - +
      diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt index a8dd7f4539..8e0642f674 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -271,12 +271,12 @@ - +
    8. - +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt index 2a11966fa0..94dcd4ad68 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/reserveratios.tt @@ -164,12 +164,12 @@
  • - +
  • - +
  • (inclusive) 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 6a2b51a184..18e58f5faf 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 fb5a645dc7..dea023627b 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 aee3f2ffc7..a3e2a05f89 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/labels/search.tt @@ -90,12 +90,12 @@ to add to Batch [% batch_id | html %]
    1. - +
      [% INCLUDE 'date-format.inc' %]
    2. - +
      [% INCLUDE 'date-format.inc' %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 451ffaeee5..6450d5f1a4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1055,7 +1055,7 @@ legend:hover { [% END %] Registration date: - + [% IF ( mandatorydateenrolled ) %] Required [% END %] @@ -1079,9 +1079,9 @@ legend:hover { Expiry date (leave blank for auto calc): [% UNLESS ( opadd ) %] - + [% ELSE %] - + [% END %] [% IF ( mandatorydateexpiry ) %] Required 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 effc2c9591..b9ef85e550 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/pos/register.tt @@ -163,9 +163,9 @@
    1. - + - + [% INCLUDE 'date-format.inc' %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt index 2f9dee8e43..1a9667c4ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/acquisitions_stats.tt @@ -120,9 +120,9 @@ - From + From [% INCLUDE 'date-format.inc' %] - To + To [% INCLUDE 'date-format.inc' %] @@ -143,9 +143,9 @@ - From + From [% INCLUDE 'date-format.inc' %] - To + To [% INCLUDE 'date-format.inc' %] @@ -339,33 +339,6 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] - [% END %] [% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt index d2f54f421c..2017b58fb1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/cash_register_stats.tt @@ -58,12 +58,12 @@
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt index fd1bd3e223..349e1b2e88 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/dictionary.tt @@ -259,10 +259,10 @@
  • Start of date range - +
    [% INCLUDE 'date-format.inc' %]
    End of date range - +
    [% INCLUDE 'date-format.inc' %]
  • [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt index 37742acec8..3589e5f1c7 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/issues_stats.tt @@ -128,9 +128,9 @@ - + - + [% INCLUDE 'date-format.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt index cab4dc9eda..b79903386e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/claims.tt @@ -93,9 +93,9 @@
    1. - + - + [% INCLUDE 'date-format.inc' %] Clear filter diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 5de924a268..7f1f7641e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -327,11 +327,11 @@ fieldset.rows table { clear: none; margin: 0; }
    2. - +
    3. - +
    4. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt index 56827085ac..f90fdb18d4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-history.tt @@ -41,14 +41,14 @@ Subscription start date - (start date of the 1st subscription) + (start date of the 1st subscription)
      [% INCLUDE 'date-format.inc' %]
      Subscription end date - (if empty, subscription is still active) + (if empty, subscription is still active)
      [% 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 31bad4581e..7a2de0ad16 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; }
    5. - +
      [% INCLUDE 'date-format.inc' %]
      - +
      [% INCLUDE 'date-format.inc' %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index 9958807cd5..a867c70e92 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -214,12 +214,12 @@ [% END %]
  • - +
    [% INCLUDE 'date-format.inc' %]
  • - +
    [% INCLUDE 'date-format.inc' %] [% IF category == 'news' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt index 1fed15f83a..b4f0f345c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_extend_due_dates.tt @@ -82,12 +82,12 @@
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt index fe5011bd9b..bdf9b3586c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/export.tt @@ -110,11 +110,11 @@
    1. - +
    2. - +
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt index a1794b0e75..27b33a5c26 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -273,11 +273,11 @@ [% END %]
  • - +
    [% 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 2c39ad7aba..414bcf8f22 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js @@ -335,32 +335,6 @@ $(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'); -- 2.39.5