View | Details | Raw Unified | Return to bug 41995
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (+10 lines)
Lines 97-102 Link Here
97
    </script>
97
    </script>
98
[% END %]
98
[% END %]
99
99
100
[% IF ( CAN_user_parameters_manage_sysprefs ) %]
101
    <script>
102
        $(document).ready(function () {
103
            if ($("#syspref_searchfield").length) {
104
                syspref_autocomplete($("#syspref_searchfield"));
105
            }
106
        });
107
    </script>
108
[% END %]
109
100
[% IF Koha.Preference( 'CookieConsent' ) %]
110
[% IF Koha.Preference( 'CookieConsent' ) %]
101
    [% Asset.js("js/cookieconsent.js") | $raw %]
111
    [% Asset.js("js/cookieconsent.js") | $raw %]
102
[% END %]
112
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc (-2 / +2 lines)
Lines 11-21 Link Here
11
                <input type="hidden" name="op" value="search" />
11
                <input type="hidden" name="op" value="search" />
12
12
13
                <div class="form-title">
13
                <div class="form-title">
14
                    <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>
14
                    <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>
15
                </div>
15
                </div>
16
16
17
                <div class="form-content">
17
                <div class="form-content">
18
                    <input class="head-searchbox form-control" type="text" name="searchfield" id="searchfield" value="" placeholder="System preference search" />
18
                    <input class="head-searchbox form-control" type="text" name="searchfield" id="syspref_searchfield" value="" placeholder="System preference search" />
19
                </div>
19
                </div>
20
20
21
                <button type="submit" aria-label="Search"><i class="fa fa-arrow-right"></i></button>
21
                <button type="submit" aria-label="Search"><i class="fa fa-arrow-right"></i></button>
(-)a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js (-4 / +13 lines)
Lines 1-7 Link Here
1
export class SysprefAPIClient {
1
export class SysprefAPIClient {
2
    constructor(HttpClient) {
2
    constructor(HttpClient) {
3
        this.httpClient = new HttpClient({
3
        this.httpClient = new HttpClient({
4
            baseURL: "/cgi-bin/koha/svc/config/systempreferences",
4
            baseURL: "",
5
        });
5
        });
6
    }
6
    }
7
7
Lines 9-19 export class SysprefAPIClient { Link Here
9
        return {
9
        return {
10
            get: variable =>
10
            get: variable =>
11
                this.httpClient.get({
11
                this.httpClient.get({
12
                    endpoint: "/?pref=" + variable,
12
                    endpoint:
13
                        "/cgi-bin/koha/svc/config/systempreferences/?pref=" +
14
                        variable,
15
                }),
16
            getAll: (query, params) =>
17
                this.httpClient.getAll({
18
                    endpoint: "/api/v1/sysprefs",
19
                    query,
20
                    params: { _order_by: "name", ...params },
21
                    headers: {},
13
                }),
22
                }),
14
            update: (variable, value) =>
23
            update: (variable, value) =>
15
                this.httpClient.post({
24
                this.httpClient.post({
16
                    endpoint: "",
25
                    endpoint: "/cgi-bin/koha/svc/config/systempreferences",
17
                    body: "pref_%s=%s".format(
26
                    body: "pref_%s=%s".format(
18
                        encodeURIComponent(variable),
27
                        encodeURIComponent(variable),
19
                        encodeURIComponent(value)
28
                        encodeURIComponent(value)
Lines 25-31 export class SysprefAPIClient { Link Here
25
                }),
34
                }),
26
            update_all: sysprefs =>
35
            update_all: sysprefs =>
27
                this.httpClient.post({
36
                this.httpClient.post({
28
                    endpoint: "",
37
                    endpoint: "/cgi-bin/koha/svc/config/systempreferences",
29
                    body: Object.keys(sysprefs)
38
                    body: Object.keys(sysprefs)
30
                        .map(variable =>
39
                        .map(variable =>
31
                            sysprefs[variable].length
40
                            sysprefs[variable].length
(-)a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js (-1 / +50 lines)
Lines 1094-1096 function validatePatronSearch(form) { Link Here
1094
    }
1094
    }
1095
    return true;
1095
    return true;
1096
}
1096
}
1097
- 
1097
1098
function syspref_autocomplete(node) {
1099
    const client = APIClient.sysprefs;
1100
    node
1101
        .autocomplete({
1102
            source: function (request, response) {
1103
                let patterns = request.term
1104
                    .split(/[\s,]+/)
1105
                    .filter(function (s) {
1106
                        return s.length;
1107
                    });
1108
1109
                var table_prefix = "me";
1110
                let search_fields = ["variable"];
1111
                let term_subquery_or = [];
1112
                search_fields.forEach(function (field, i) {
1113
                    term_subquery_or.push({
1114
                        [table_prefix + "." + field]: {
1115
                            like: "%" + request.term + "%",
1116
                        },
1117
                    });
1118
                });
1119
                let query = [{ "-or": term_subquery_or }];
1120
1121
                let params = {
1122
                    _page: 1,
1123
                    _per_page: 10,
1124
                    _order_by: "+me.variable",
1125
                };
1126
                client.sysprefs.getAll(query, params).then(data => {
1127
                    return response(data);
1128
                });
1129
            },
1130
            minLength: 3,
1131
            select: function (event, ui) {
1132
                window.location.href = ui.item.link;
1133
            },
1134
            focus: function (event, ui) {
1135
                event.preventDefault(); // Don't replace the text field
1136
            },
1137
        })
1138
        .data("ui-autocomplete")._renderItem = function (ul, item) {
1139
        item.link = "/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=";
1140
        item.value = item.variable; // Or we replace the input with the syspref's value when the item is selected
1141
        return $("<li></li>")
1142
            .data("ui-autocomplete-item", item)
1143
            .append(`<a href="${item.link}">${item.variable}</a>`)
1144
            .appendTo(ul);
1145
    };
1146
}

Return to bug 41995