From ad243d8e93b948cd5937a6242da2f440926e7f52 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 26 Mar 2024 17:13:51 +0000 Subject: [PATCH] Bug 36453: Categories admin page: Account for multiple values param Input is now multipleselect select JavaScript Staff CSS updates to account for multiselect dropdown in categories admin page Signed-off-by: Arthur Suzuki Signed-off-by: Martin Renvoize --- admin/categories.pl | 2 +- .../intranet-tmpl/prog/css/src/_forms.scss | 11 ++ .../prog/en/modules/admin/categories.tt | 30 ++-- koha-tmpl/intranet-tmpl/prog/js/categories.js | 132 ++++++++++++------ 4 files changed, 119 insertions(+), 56 deletions(-) diff --git a/admin/categories.pl b/admin/categories.pl index b928b0649c..5495210b6d 100755 --- a/admin/categories.pl +++ b/admin/categories.pl @@ -70,7 +70,7 @@ elsif ( $op eq 'cud-add_validate' ) { my $hidelostitems = $input->param('hidelostitems'); my $overduenoticerequired = $input->param('overduenoticerequired'); my $category_type = $input->param('category_type'); - my $BlockExpiredPatronOpacActions = $input->param('BlockExpiredPatronOpacActions'); + my $BlockExpiredPatronOpacActions = join( ',', $input->multi_param('BlockExpiredPatronOpacActions') ); my $checkPrevCheckout = $input->param('checkprevcheckout'); my $can_place_ill_in_opac = $input->param('can_place_ill_in_opac') // 1; my $default_privacy = $input->param('default_privacy'); diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/_forms.scss b/koha-tmpl/intranet-tmpl/prog/css/src/_forms.scss index 99f8adfbca..6a98f023e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/css/src/_forms.scss +++ b/koha-tmpl/intranet-tmpl/prog/css/src/_forms.scss @@ -169,6 +169,17 @@ fieldset { padding-left: 0; } } + + div.ms-drop { + label { + text-align: left; + width:auto; + span{ + margin-left:5px; + width:auto; + } + } + } } ol { diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt index 2144484642..4834ac4e77 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt @@ -28,6 +28,7 @@ [% t("Koha") | html %] [% END %] [% INCLUDE 'doc-head-close.inc' %] +[% Asset.css("lib/jquery/plugins/multiple-select/multiple-select.min.css") | $raw %] @@ -340,25 +341,27 @@ [% END %] -
  • - + + [% IF not category or category.BlockExpiredPatronOpacActions_contains('follow_syspref_BlockExpiredPatronOpacActions') %] + [% ELSE %] - + [% END %] - - [% IF category and category.BlockExpiredPatronOpacActions == 1 %] - + + + [% IF category and category.BlockExpiredPatronOpacActions_contains('hold') %] + [% ELSE %] - + [% END %] - - [% IF category and category.BlockExpiredPatronOpacActions == 0 %] - + [% IF category and category.BlockExpiredPatronOpacActions_contains('renew') %] + [% ELSE %] - + [% END %] +
    Choose whether patrons of this category be blocked from public catalog actions such as renewing and placing holds when their cards have expired. @@ -751,6 +754,7 @@ [% Asset.js("js/admin-menu.js") | $raw %] [% Asset.js("js/messaging-preference-form.js") | $raw %] + [% Asset.js("lib/jquery/plugins/multiple-select/multiple-select.min.js") | $raw %] [% INCLUDE 'calendar.inc' %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'columns_settings.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/categories.js b/koha-tmpl/intranet-tmpl/prog/js/categories.js index 50b19382d9..615e5554f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/categories.js +++ b/koha-tmpl/intranet-tmpl/prog/js/categories.js @@ -1,45 +1,63 @@ /* global __ */ -jQuery.validator.addMethod( "letters_numbers", function(value,element){ - var patt = /^[a-zA-Z0-9\-_]+$/g; - if (patt.test(element.value)) { - return true; - } else { - return false; - } - }, __("Category code can only contain the following characters: letters, numbers, - and _.") +jQuery.validator.addMethod( + "letters_numbers", + function (value, element) { + var patt = /^[a-zA-Z0-9\-_]+$/g; + if (patt.test(element.value)) { + return true; + } else { + return false; + } + }, + __( + "Category code can only contain the following characters: letters, numbers, - and _." + ) ); -jQuery.validator.addMethod( "enrollment_period", function(){ +jQuery.validator.addMethod( + "enrollment_period", + function () { enrolmentperiod = $("#enrolmentperiod").val(); enrolmentperioddate = $("#enrolmentperioddate").val(); - if ( $("#enrolmentperiod").val() !== "" && $("#enrolmentperioddate").val() !== "" ) { + if ( + $("#enrolmentperiod").val() !== "" && + $("#enrolmentperioddate").val() !== "" + ) { return false; } else { return true; } - }, __("Please choose an enrollment period in months OR by date.") + }, + __("Please choose an enrollment period in months OR by date.") ); -$(document).ready(function() { - KohaTable("patron_categories", { - "columnDefs": [{ - "targets": [-1], - "orderable": false, - "searchable": false - }, { - "targets": [3, 4, 5], - "type": "natural" - }, ], - "pagingType": "full", - "exportColumns": [0,1,2,3,4,5,6,7,8,9,10,11,12], - }, table_settings); +$(document).ready(function () { + KohaTable( + "patron_categories", + { + columnDefs: [ + { + targets: [-1], + orderable: false, + searchable: false, + }, + { + targets: [3, 4, 5], + type: "natural", + }, + ], + pagingType: "full", + exportColumns: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], + }, + table_settings + ); if ($("#branches option:selected").length < 1) { $("#branches option:first").attr("selected", "selected"); } - $("#categorycode").on("blur",function(){ + $("#categorycode").on("blur", function () { toUC(this); }); @@ -47,53 +65,83 @@ $(document).ready(function() { rules: { categorycode: { required: true, - letters_numbers: true + letters_numbers: true, }, description: "required", enrolmentperiod: { - required: function(element){ + required: function (element) { return $("#enrolmentperioddate").val() === ""; }, digits: true, enrollment_period: true, - min: 1 + min: 1, }, enrolmentperioddate: { - required: function(element){ + required: function (element) { return $("#enrolmentperiod").val() === ""; }, - enrollment_period: true + enrollment_period: true, }, password_expiry_days: { - digits: true + digits: true, }, dateofbirthrequired: { - digits: true + digits: true, }, upperagelimit: { - digits: true + digits: true, }, enrolmentfee: { - number: true + number: true, }, reservefee: { - number: true + number: true, }, category_type: { - required: true + required: true, }, min_password_length: { - digits: true - } + digits: true, + }, }, messages: { enrolmentperiod: { - required: __("Please choose an enrollment period in months OR by date.") + required: __( + "Please choose an enrollment period in months OR by date." + ), }, enrolmentperioddate: { - required: __("Please choose an enrollment period in months OR by date.") - } - } + required: __( + "Please choose an enrollment period in months OR by date." + ), + }, + }, + }); + let blocked_actions_select = $("select#block_expired[multiple='multiple']"); + blocked_actions_select.multipleSelect({ + placeholder: _("Please select ..."), + selectAll: false, + hideOptgroupCheckboxes: true, + allSelected: _("All selected"), + countSelected: _("# of % selected"), + noMatchesFound: _("No matches found"), + onClick: function (view) { + if ( + view.value == "follow_syspref_BlockExpiredPatronOpacActions" && + view.selected + ) { + blocked_actions_select.multipleSelect("uncheck", "hold"); + blocked_actions_select.multipleSelect("uncheck", "renew"); + } else if ( + view.value != "follow_syspref_BlockExpiredPatronOpacActions" && + view.selected + ) { + blocked_actions_select.multipleSelect( + "uncheck", + "follow_syspref_BlockExpiredPatronOpacActions" + ); + } + }, }); }); -- 2.39.5