Bugzilla – Attachment 194508 Details for
Bug 41995
Autocomplete for syspref search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41995: Autocomplete for syspref search
Bug-41995-Autocomplete-for-syspref-search.patch (text/plain), 7.24 KB, created by
OpenFifth Sandboxes
on 2026-03-05 13:37:51 UTC
(
hide
)
Description:
Bug 41995: Autocomplete for syspref search
Filename:
MIME Type:
Creator:
OpenFifth Sandboxes
Created:
2026-03-05 13:37:51 UTC
Size:
7.24 KB
patch
obsolete
>From bcd1d0fb4a4ca20492bf71574a3acf5eb5fb2c55 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Feb 2026 14:24:15 +0100 >Subject: [PATCH] Bug 41995: Autocomplete for syspref search >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds autocompletion to the syspref search in the header. > >Test plan: >1. Go to the admin home page - /cgi-bin/koha/admin/admin-home.pl >2. In the header start typing the name of a syspref and notice that > there is now autocompletion (you need at least 3 chars) >3. Select an entry and confirm that you are correctly redirected to the > correct search result > >Signed-off-by: Anneli Ãsterman <anneli.osterman@koha-suomi.fi> >--- > .../prog/en/includes/js_includes.inc | 10 ++++ > .../prog/en/includes/prefs-admin-search.inc | 4 +- > .../js/fetch/system-preferences-api-client.js | 17 +++++-- > .../intranet-tmpl/prog/js/staff-global.js | 50 +++++++++++++++++++ > 4 files changed, 75 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index 189a2687c9..999e180aaa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -97,6 +97,16 @@ > </script> > [% END %] > >+[% IF ( CAN_user_parameters_manage_sysprefs ) %] >+ <script> >+ $(document).ready(function () { >+ if ($("#syspref_searchfield").length) { >+ syspref_autocomplete($("#syspref_searchfield")); >+ } >+ }); >+ </script> >+[% END %] >+ > [% IF Koha.Preference( 'CookieConsent' ) %] > [% Asset.js("js/cookieconsent.js") | $raw %] > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc >index ed1827e45b..debafdd673 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc >@@ -11,11 +11,11 @@ > <input type="hidden" name="op" value="search" /> > > <div class="form-title"> >- <label class="control-label" for="searchfield"><span class="control-text">Search system preferences</span> <i class="fa fa-fw fa-cogs" aria-hidden="true"></i></label> >+ <label class="control-label" for="syspref_searchfield"><span class="control-text">Search system preferences</span> <i class="fa fa-fw fa-cogs" aria-hidden="true"></i></label> > </div> > > <div class="form-content"> >- <input class="head-searchbox form-control" type="text" name="searchfield" id="searchfield" value="" placeholder="System preference search" /> >+ <input class="head-searchbox form-control" type="text" name="searchfield" id="syspref_searchfield" value="" placeholder="System preference search" /> > </div> > > <button type="submit" aria-label="Search"><i class="fa fa-arrow-right"></i></button> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js >index 49b2f3212b..fd19fc0175 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js >@@ -1,7 +1,7 @@ > export class SysprefAPIClient { > constructor(HttpClient) { > this.httpClient = new HttpClient({ >- baseURL: "/cgi-bin/koha/svc/config/systempreferences", >+ baseURL: "", > }); > } > >@@ -9,11 +9,20 @@ export class SysprefAPIClient { > return { > get: variable => > this.httpClient.get({ >- endpoint: "/?pref=" + variable, >+ endpoint: >+ "/cgi-bin/koha/svc/config/systempreferences/?pref=" + >+ variable, >+ }), >+ getAll: (query, params) => >+ this.httpClient.getAll({ >+ endpoint: "/api/v1/sysprefs", >+ query, >+ params: { _order_by: "name", ...params }, >+ headers: {}, > }), > update: (variable, value) => > this.httpClient.post({ >- endpoint: "", >+ endpoint: "/cgi-bin/koha/svc/config/systempreferences", > body: "pref_%s=%s".format( > encodeURIComponent(variable), > encodeURIComponent(value) >@@ -25,7 +34,7 @@ export class SysprefAPIClient { > }), > update_all: sysprefs => > this.httpClient.post({ >- endpoint: "", >+ endpoint: "/cgi-bin/koha/svc/config/systempreferences", > body: Object.keys(sysprefs) > .map(variable => > sysprefs[variable].length >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index bfac800c53..d544cb30d7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -1094,3 +1094,53 @@ function validatePatronSearch(form) { > } > return true; > } >+ >+function syspref_autocomplete(node) { >+ const client = APIClient.sysprefs; >+ node >+ .autocomplete({ >+ source: function (request, response) { >+ let patterns = request.term >+ .split(/[\s,]+/) >+ .filter(function (s) { >+ return s.length; >+ }); >+ >+ var table_prefix = "me"; >+ let search_fields = ["variable"]; >+ let term_subquery_or = []; >+ search_fields.forEach(function (field, i) { >+ term_subquery_or.push({ >+ [table_prefix + "." + field]: { >+ like: "%" + request.term + "%", >+ }, >+ }); >+ }); >+ let query = [{ "-or": term_subquery_or }]; >+ >+ let params = { >+ _page: 1, >+ _per_page: 10, >+ _order_by: "+me.variable", >+ }; >+ client.sysprefs.getAll(query, params).then(data => { >+ return response(data); >+ }); >+ }, >+ minLength: 3, >+ select: function (event, ui) { >+ window.location.href = ui.item.link; >+ }, >+ focus: function (event, ui) { >+ event.preventDefault(); // Don't replace the text field >+ }, >+ }) >+ .data("ui-autocomplete")._renderItem = function (ul, item) { >+ item.link = `/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=${item.variable}`; >+ item.value = item.variable; // Or we replace the input with the syspref's value when the item is selected >+ return $("<li></li>") >+ .data("ui-autocomplete-item", item) >+ .append(`<a href="${item.link}">${item.variable}</a>`) >+ .appendTo(ul); >+ }; >+} >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41995
:
194492
|
194498
|
194501
|
194507
| 194508 |
194509