From 140493faf71b2545a41032b1d0db5d11f1db5f65 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 1 Feb 2023 10:47:27 +0100 Subject: [PATCH] Bug 31665: Set today date for date cataloguing plugin dateaccessioned.pl must pick today's date when the input gets the focus on. Test plan: Edit an item, or create a new one. Confirm that today's date is prefilled into the date's input when it's empty and that it gets the focus on Signed-off-by: Lucas Gass Signed-off-by: Michael Adamyk Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- cataloguing/value_builder/dateaccessioned.pl | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cataloguing/value_builder/dateaccessioned.pl b/cataloguing/value_builder/dateaccessioned.pl index f0d89b528f..48c44e5647 100755 --- a/cataloguing/value_builder/dateaccessioned.pl +++ b/cataloguing/value_builder/dateaccessioned.pl @@ -21,24 +21,21 @@ # along with Koha; if not, see . use Modern::Perl; -use Koha::DateUtils qw( flatpickr_date_format ); - my $builder = sub { my ( $params ) = @_; my $function_name = $params->{id}; - my $dateformat = flatpickr_date_format(); - my $res = < /* from: cataloguing/value_builder/dateaccessioned.pl */ \$(document).ready(function(){ \$("#$function_name").flatpickr({ - altInput: true, - altFormat: "$dateformat", - altInputClass: "input_marceditor flatpickr-input", - dateFormat: "Y-m-d" + onOpen: function(selectedDates, dateStr, instance) { + if (dateStr == '') { + instance.setDate(new Date()); + } + } }); }); -- 2.39.5