From 8213042e25cac548e73f3365bed8f951ee63230f Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Wed, 11 Jun 2025 13:21:29 +0000 Subject: [PATCH] Bug 40118: [24.11] Squashed patch for 24.11 --- .../prog/en/modules/circ/pendingreserves.tt | 2 +- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 32 ++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt index 8769a5be973..ef6df2a4e9e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt @@ -310,7 +310,7 @@ let options = [... new Set(column .data() .toArray() - .map(d => d.replace(regex, '').trim().split(/\n/gi).flat()) + .map(d => d.replace(regex, '').trim().split(/\n/gi).map(s => s.trim()).flat()) .flat() .sort())]; diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 084cb8c82c8..0caf1084f0a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -847,16 +847,27 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { } else if ( typeof filters_options[i] === "function" ) { filters_options[i] = filters_options[i](table_dt) } - $(filters_options[i]).each(function(){ - let o = $(''.format(this._id, this._str)); - // Compare with lc, or selfreg won't match ^SELFREG$ for instance, see bug 32517 - // This is only for category, we might want to apply it only in this case. - existing_search = existing_search.toLowerCase() - if ( existing_search === this._id || (existing_search && this._id.toLowerCase().match(existing_search)) ) { - o.prop("selected", "selected"); - } - o.appendTo(select); - }); + $(filters_options[i]) + .filter(function () { + return this._id && this._str; + }) + .each(function () { + let optionValue = + table_dt.settings()[0].ajax !== null + ? `^${this._id}$` + : this._id; + let o = $( + `` + ); + + // Compare with lc, or selfreg won't match ^SELFREG$ for instance, see bug 32517 + // This is only for category, we might want to apply it only in this case. + existing_search = existing_search.toLowerCase() + if ( existing_search === this._id || (existing_search && this._id.toLowerCase().match(existing_search)) ) { + o.prop("selected", "selected"); + } + o.appendTo(select); + }); $(th).html( select ); } else { var title = $(th).text(); @@ -911,7 +922,6 @@ function _dt_add_delay_filters(table_dt, table_node) { $(this).find("select") .unbind() .bind("keyup change", function(){ - let value = this.value.length ? '^'+this.value+'$' : ''; col_select_search(i, this.value) }); }); -- 2.39.5