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 <arthur.suzuki@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Pedro Amorim 2024-03-26 17:13:51 +00:00 committed by Martin Renvoize
parent 1dfec21694
commit ad243d8e93
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 119 additions and 56 deletions

View File

@ -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');

View File

@ -169,6 +169,17 @@ fieldset {
padding-left: 0;
}
}
div.ms-drop {
label {
text-align: left;
width:auto;
span{
margin-left:5px;
width:auto;
}
}
}
}
ol {

View File

@ -28,6 +28,7 @@
[% t("Koha") | html %]
[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
[% Asset.css("lib/jquery/plugins/multiple-select/multiple-select.min.css") | $raw %]
<style>#enrolmentmessage.hint { display : none; }</style>
</head>
@ -340,25 +341,27 @@
[% END %]
</select>
</li>
<li><label for="block_expired">Block expired patrons:</label>
<select name="BlockExpiredPatronOpacActions" id="block_expired">
[% IF not category or category.BlockExpiredPatronOpacActions == -1%]
<option value="-1" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
<li><label for="block_expired">Block expired patrons actions:</label>
<select name="BlockExpiredPatronOpacActions" id="block_expired" multiple="multiple">
<optgroup label="Follow system preference">
[% IF not category or category.BlockExpiredPatronOpacActions_contains('follow_syspref_BlockExpiredPatronOpacActions') %]
<option value="follow_syspref_BlockExpiredPatronOpacActions" selected="selected"> Follow system preference BlockExpiredPatronOpacActions </option>
[% ELSE %]
<option value="-1"> Follow system preference BlockExpiredPatronOpacActions </option>
<option value="follow_syspref_BlockExpiredPatronOpacActions"> BlockExpiredPatronOpacActions </option>
[% END %]
[% IF category and category.BlockExpiredPatronOpacActions == 1 %]
<option value="1" selected="selected"> Block </option>
</optgroup>
<optgroup label="Specific actions">
[% IF category and category.BlockExpiredPatronOpacActions_contains('hold') %]
<option value="hold" selected="selected"> Placing a hold on an item </option>
[% ELSE %]
<option value="1"> Block </option>
<option value="hold"> Placing a hold on an item </option>
[% END %]
[% IF category and category.BlockExpiredPatronOpacActions == 0 %]
<option value="0" selected="selected"> Don't block </option>
[% IF category and category.BlockExpiredPatronOpacActions_contains('renew') %]
<option value="renew" selected="selected"> Renewing an item </option>
[% ELSE %]
<option value="0"> Don't block </option>
<option value="renew"> Renewing an item </option>
[% END %]
</optgroup>
</select>
<div class="hint">
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 @@
</script>
[% 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' %]

View File

@ -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"
);
}
},
});
});