From 589ed94a5cb6d8c883febbb30106741c01ca8114 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 31 May 2022 12:10:33 +0200 Subject: [PATCH] Bug 30718: POC - Use flatpickr's altInput --- .../prog/en/includes/calendar.inc | 7 +++++-- koha-tmpl/intranet-tmpl/prog/js/members.js | 2 +- members/memberentry.pl | 20 ------------------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 47a3f76ec2d..a3a19db4cdd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -35,7 +35,10 @@ flatpickr.l10ns.default.months = flatpickr_months; flatpickr.setDefaults({ allowInput: true, - dateFormat: flatpickr_dateformat_string, + dateFormat: "Y-m-d", + altInput: true, + altFormat: flatpickr_dateformat_string, + altInputClass: 'flatpickr-input', nextArrow: '', prevArrow: '', time_24hr: flatpickr_timeformat, @@ -46,7 +49,7 @@ }, onReady: function( selectedDates, dateStr, instance ){ /* When flatpickr instance is created, automatically append a "clear date" link */ - $(instance.input) + $(instance.input).siblings('input.flatpickr') /* Add a wrapper element so that we can prevent the clear button from wrapping */ .wrap("") .attr("autocomplete", "off") diff --git a/koha-tmpl/intranet-tmpl/prog/js/members.js b/koha-tmpl/intranet-tmpl/prog/js/members.js index 7a9f844a865..f711a19aaca 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/members.js +++ b/koha-tmpl/intranet-tmpl/prog/js/members.js @@ -128,7 +128,7 @@ function select_user(borrowernumber, borrower, relationship) { function CalculateAge(dateofbirth) { var today = new Date(); - var dob = Date_from_syspref(dateofbirth); + var dob = new Date(dateofbirth); var age = {}; age.year = today.getFullYear() - dob.getFullYear(); diff --git a/members/memberentry.pl b/members/memberentry.pl index 0f369ebc219..3b0be69348b 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -198,19 +198,6 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } } - foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) { - next unless exists $newdata{$_}; - my $userdate = $newdata{$_} or next; - - my $formatteddate = eval { output_pref({ dt => dt_from_string( $userdate ), dateformat => 'iso', dateonly => 1 } ); }; - if ( $formatteddate ) { - $newdata{$_} = $formatteddate; - } else { - $template->param( "ERROR_$_" => 1 ); - push(@errors,"ERROR_$_"); - } - } - # check permission to modify login info. if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) { $NoUpdateLogin = 1; @@ -797,13 +784,6 @@ if (C4::Context->preference('uppercasesurnames')) { $data{'contactname'} &&= uc( $data{'contactname'} ); } -foreach (qw(dateenrolled dateexpiry dateofbirth password_expiration_date)) { - if ( $data{$_} ) { - $data{$_} = eval { output_pref({ dt => dt_from_string( $data{$_} ), dateonly => 1 } ); }; # back to syspref for display - } - $template->param( $_ => $data{$_}); -} - if ( C4::Context->preference('ExtendedPatronAttributes') ) { patron_attributes_form( $template, $extended_patron_attributes, $op ); } -- 2.25.1