From 4540dd2a5af825ad94f55b49bcf93afa787d371b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 26 Feb 2026 06:53:35 +0000 Subject: [PATCH] Bug 33886: Replace DateInputStyle syspref with data-flatpickr-split attribute Remove the DateInputStyle system preference and instead control split date input mode via a data-flatpickr-split="true" attribute on individual fields. This allows per-field control rather than a global setting. Apply split inputs to fields where they are most appropriate: - dateofbirth (memorable date, typically far in the past) - dateexpiry (far-future date, analogous to card expiry) The atomicupdate is updated to delete the preference on upgrade. --- installer/data/mysql/atomicupdate/bug_33886.pl | 13 +++---------- .../intranet-tmpl/prog/en/includes/calendar.inc | 3 +-- .../en/modules/admin/preferences/i18n_l10n.pref | 8 -------- .../prog/en/modules/members/memberentrygen.tt | 5 +++-- .../opac-tmpl/bootstrap/en/includes/calendar.inc | 3 +-- .../bootstrap/en/modules/opac-memberentry.tt | 1 + 6 files changed, 9 insertions(+), 24 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_33886.pl b/installer/data/mysql/atomicupdate/bug_33886.pl index 4a0474580c2..c3d9ac1aadb 100644 --- a/installer/data/mysql/atomicupdate/bug_33886.pl +++ b/installer/data/mysql/atomicupdate/bug_33886.pl @@ -3,24 +3,17 @@ use Koha::Installer::Output qw(say_warning say_success say_info); return { bug_number => "33886", - description => "Add DateInputStyle system preference", + description => "Remove DateInputStyle system preference", up => sub { my ($args) = @_; my ( $dbh, $out ) = @$args{qw(dbh out)}; $dbh->do( q{ - INSERT IGNORE INTO systempreferences ( variable, value, options, explanation, type ) - VALUES ( - 'DateInputStyle', - 'single', - 'single|split', - 'Controls how date input fields are displayed. "single" uses the standard flatpickr calendar widget with maskito input masking. "split" shows three separate inputs for day, month, and year (order follows the dateformat preference) with an optional calendar button; does not apply to time, datetime, or booking date range fields.', - 'Choice' - ) + DELETE FROM systempreferences WHERE variable = 'DateInputStyle' } ); - say_success( $out, "Added new system preference 'DateInputStyle'" ); + say_success( $out, "Removed system preference 'DateInputStyle'" ); }, }; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index d785927a4fc..ad50ca43bfd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -31,7 +31,6 @@ delimiter = "-"; } var sentmsg = 0; - var dateInputStyle = "[% Koha.Preference('DateInputStyle') | html %]"; var bidi = [% IF(bidi) %] true[% ELSE %] false[% END %]; var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]'; var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %]; @@ -277,7 +276,7 @@ } let fp; - if ( dateInputStyle === 'split' && !is_time && !is_time_only && !is_period ) { + if ( $(input).data('flatpickr-split') && !is_time && !is_time_only && !is_period ) { fp = apply_split_date_widget(input, options); } else { fp = $(input).flatpickr(options); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref index 3e625e732e1..be78a5088a8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/i18n_l10n.pref @@ -10,14 +10,6 @@ I18N/L10N: dmydot: dd.mm.yyyy iso: yyyy-mm-dd - . - - - - Use - - pref: DateInputStyle - default: single - choices: - single: single input field with calendar picker - split: split inputs (day, month, year) with optional calendar button - - "style for date entry fields. The split option follows the dateformat preference for field order and is recommended for accessibility; it does not apply to time, datetime, or booking date range fields." - - Format times in - pref: TimeFormat 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 d6dbd0954fc..a1c4b7ce257 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -393,6 +393,7 @@ size="20" value="[% borrower_data.dateofbirth | html UNLESS op == 'duplicate' %]" class="flatpickr" + data-flatpickr-split="true" data-flatpickr-pastinclusive="true" /> [% IF ( mandatorydateofbirth ) %] @@ -1127,9 +1128,9 @@
  • [% UNLESS ( op == 'add_form' ) %] - + [% ELSE %] - + [% END %] [% IF ( mandatorydateexpiry ) %] Required diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc index 437067dd25c..757ddbdb355 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc @@ -13,7 +13,6 @@ }; var debug = "[% debug | html %]"; var dateformat_pref = "[% Koha.Preference('dateformat') | html %]"; - var dateInputStyle = "[% Koha.Preference('DateInputStyle') | html %]"; var sentmsg = 0; if (debug > 1) {alert("dateformat: " + dateformat_pref + "\ndebug is on (level " + debug + ")");} var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]'; @@ -394,7 +393,7 @@ } let fp; - if (typeof dateInputStyle !== "undefined" && dateInputStyle === "split" && !is_time && !is_period) { + if ($(this).data("flatpickr-split") && !is_time && !is_period) { fp = apply_split_date_widget(this, options); } else { fp = $(this).flatpickr(options); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 1e6f167b59d..27f310cec65 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -490,6 +490,7 @@ value="[% borrower.dateofbirth | html %]" size="10" class="[% required.dateofbirth | html %] flatpickr pastdate" + data-flatpickr-split="true" [% IF required.dateofbirth %]required[% END %] />
    Required
    -- 2.53.0