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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-13 / +13 lines)
Lines 205-219 Link Here
205
            });
205
            });
206
        });
206
        });
207
207
208
        const all_libraries = [% To.json(Branches.all) | $raw %];
208
        const all_libraries = [% To.json(Branches.all) | $raw %].map(e => {
209
        const libraries_filters = all_libraries.map(e => {
210
                    e["_id"] = e["branchcode"];
209
                    e["_id"] = e["branchcode"];
211
                    e["_str"] = e["branchname"];
210
                    e["_str"] = e["branchname"];
212
                    return e;
211
                    return e;
213
                });
212
                });
214
        const libraries_names = new Map(all_libraries.map( l => [l.branchcode, l.branchname] ));
213
        const libraries_names = new Map(all_libraries.map( l => [l.branchcode, l.branchname] ));
215
        const all_item_types = [% To.json(ItemTypes.Get) | $raw %];
214
        const all_item_types = [% To.json(ItemTypes.Get) | $raw %].map(e => {
216
        const item_types_filters = all_item_types.map(e => {
217
                    e["_id"] = e["itemtype"];
215
                    e["_id"] = e["itemtype"];
218
                    e["_str"] = e["translated_description"];
216
                    e["_str"] = e["translated_description"];
219
                    return e;
217
                    return e;
Lines 241-246 Link Here
241
            collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])),
239
            collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])),
242
        };
240
        };
243
241
242
        let filters_options = {
243
            item_types: all_item_types,
244
            libraries: all_libraries,
245
            libraries: all_libraries,
246
            statuses: all_statuses,
247
        };
248
244
        [% IF Koha.Preference('URLLinkText') %]
249
        [% IF Koha.Preference('URLLinkText') %]
245
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
250
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
246
        [% ELSE %]
251
        [% ELSE %]
Lines 326-340 Link Here
326
                return $("#" + tab_id + "_status select").val();
331
                return $("#" + tab_id + "_status select").val();
327
            };
332
            };
328
333
329
            let offset = 2;
330
            [% UNLESS Koha.Preference('LocalCoverImages') %]offset--;[% END %]
331
            let filters_options = {
332
                [offset]   : () => all_item_types,
333
                [offset+1] : () => all_libraries,
334
                [offset+2] : () => all_libraries,
335
                [offset+7] : () => all_statuses,
336
            };
337
338
            var items_table = $("#" + tab_id + '_table').kohaTable({
334
            var items_table = $("#" + tab_id + '_table').kohaTable({
339
                ajax: { url: item_table_url },
335
                ajax: { url: item_table_url },
340
                order: [],
336
                order: [],
Lines 387-392 Link Here
387
                {
383
                {
388
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
384
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
389
                    datatype: "coded_value:item_type",
385
                    datatype: "coded_value:item_type",
386
                    dataFilter: "item_types",
390
                    className: "itype",
387
                    className: "itype",
391
                    searchable: true,
388
                    searchable: true,
392
                    orderable: true,
389
                    orderable: true,
Lines 407-412 Link Here
407
                {
404
                {
408
                    data: "me.holding_library_id",
405
                    data: "me.holding_library_id",
409
                    datatype: "coded_value:library",
406
                    datatype: "coded_value:library",
407
                    dataFilter: "libraries",
410
                    className: "location",
408
                    className: "location",
411
                    searchable: true,
409
                    searchable: true,
412
                    orderable: true,
410
                    orderable: true,
Lines 417-422 Link Here
417
                {
415
                {
418
                    data: "me.home_library_id",
416
                    data: "me.home_library_id",
419
                    datatype: "coded_value:library",
417
                    datatype: "coded_value:library",
418
                    dataFilter: "libraries",
420
                    className: "homebranch",
419
                    className: "homebranch",
421
                    searchable: true,
420
                    searchable: true,
422
                    orderable: true,
421
                    orderable: true,
Lines 507-512 Link Here
507
                {
506
                {
508
                    data: "",
507
                    data: "",
509
                    className: "status",
508
                    className: "status",
509
                    dataFilter: "statuses",
510
                    searchable: false,
510
                    searchable: false,
511
                    orderable: false,
511
                    orderable: false,
512
                    render: function (data, type, row, meta) {
512
                    render: function (data, type, row, meta) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-33 / +38 lines)
Lines 175-183 Link Here
175
                        [% CASE 'address-library' %]
175
                        [% CASE 'address-library' %]
176
                            <th>Address</th>
176
                            <th>Address</th>
177
                        [% CASE 'branch' %]
177
                        [% CASE 'branch' %]
178
                            <th data-filter="libraries">Library</th>
178
                            <th>Library</th>
179
                        [% CASE 'category' %]
179
                        [% CASE 'category' %]
180
                            <th data-filter="categories">Category</th>
180
                            <th>Category</th>
181
                        [% CASE 'dateexpiry' %]
181
                        [% CASE 'dateexpiry' %]
182
                            <th>Expires on</th>
182
                            <th>Expires on</th>
183
                        [% CASE 'borrowernotes' %]
183
                        [% CASE 'borrowernotes' %]
Lines 189-205 Link Here
189
                        [% CASE 'account_balance' %]
189
                        [% CASE 'account_balance' %]
190
                            <th>Fines</th>
190
                            <th>Fines</th>
191
                        [% CASE 'sort1' %]
191
                        [% CASE 'sort1' %]
192
                            [% IF av_bsort1.size %]
192
                            <th>Sort 1</th>
193
                                <th data-filter="av_bsort1">Sort 1</th>
194
                            [% ELSE %]
195
                                <th>Sort 1</th>
196
                            [% END %]
197
                        [% CASE 'sort2' %]
193
                        [% CASE 'sort2' %]
198
                            [% IF av_bsort2.size %]
194
                            <th>Sort 2</th>
199
                                <th data-filter="av_bsort2">Sort 2</th>
200
                            [% ELSE %]
201
                                <th>Sort 2</th>
202
                            [% END %]
203
                        [% CASE 'action' %]
195
                        [% CASE 'action' %]
204
                            <th class="no-export">&nbsp;</th>
196
                            <th class="no-export">&nbsp;</th>
205
                        [% END %]
197
                        [% END %]
Lines 244-252 Link Here
244
        </script>
236
        </script>
245
    [% END %]
237
    [% END %]
246
    <script>
238
    <script>
247
        [% SET libraries = Branches.all %]
239
        var categories = [% To.json(Categories.all.unblessed) | $raw %].map(e => {
248
        [% SET categories = Categories.all.unblessed %]
249
        var categories = [% To.json(categories) | $raw %].map(e => {
250
            e['_id'] = e.categorycode.toLowerCase();
240
            e['_id'] = e.categorycode.toLowerCase();
251
            e['_str'] = e.description;
241
            e['_str'] = e.description;
252
            return e;
242
            return e;
Lines 255-261 Link Here
255
            map[e._id] = e;
245
            map[e._id] = e;
256
            return map;
246
            return map;
257
        }, {});
247
        }, {});
258
        var libraries  = [% To.json(libraries) | $raw %].map(e => {
248
        var libraries = [% To.json(Branches.all) | $raw %].map(e => {
259
            e['_id'] = e.branchcode;
249
            e['_id'] = e.branchcode;
260
            e['_str'] = e.branchname;
250
            e['_str'] = e.branchname;
261
            return e;
251
            return e;
Lines 285-290 Link Here
285
            return map;
275
            return map;
286
        }, {});
276
        }, {});
287
277
278
        let filters_options = {
279
            libraries,
280
            categories,
281
            av_bsort1,
282
            av_bsort2,
283
        };
284
288
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
285
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
289
            [% SET extended_attribute_types = ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) %]
286
            [% SET extended_attribute_types = ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) %]
290
            [% IF ( extended_attribute_types ) %][% extended_attribute_types = [ extended_attribute_types ]  %][% END %]
287
            [% IF ( extended_attribute_types ) %][% extended_attribute_types = [ extended_attribute_types ]  %][% END %]
Lines 627-636 Link Here
627
                                }
624
                                }
628
                                [% CASE 'branch' %]
625
                                [% CASE 'branch' %]
629
                                {
626
                                {
630
                                    "data": "library.name:me.library_id",
627
                                    data: "library.name:me.library_id",
631
                                    "searchable": true,
628
                                    dataFilter: "libraries",
632
                                    "orderable": true,
629
                                    searchable: true,
633
                                    "render": function( data, type, row, meta ) {
630
                                    orderable: true,
631
                                    render: function( data, type, row, meta ) {
634
                                        if( !singleBranchMode && row.library.library_id == logged_in_library_id ) {
632
                                        if( !singleBranchMode && row.library.library_id == logged_in_library_id ) {
635
                                            return "<span class=\"currentlibrary\">" + escape_str(row.library.name) + "</span>";
633
                                            return "<span class=\"currentlibrary\">" + escape_str(row.library.name) + "</span>";
636
                                        } else {
634
                                        } else {
Lines 640-649 Link Here
640
                                }
638
                                }
641
                                [% CASE 'category' %]
639
                                [% CASE 'category' %]
642
                                {
640
                                {
643
                                    "data": "category_id",
641
                                    data: "category_id",
644
                                    "searchable": true,
642
                                    dataFilter: "categories",
645
                                    "orderable": true,
643
                                    searchable: true,
646
                                    "render": function( data, type, row, meta ) {
644
                                    orderable: true,
645
                                    render: function( data, type, row, meta ) {
647
                                        return escape_str(categories_map[data.toLowerCase()].description);
646
                                        return escape_str(categories_map[data.toLowerCase()].description);
648
                                    }
647
                                    }
649
                                }
648
                                }
Lines 711-720 Link Here
711
710
712
                                [% CASE 'sort1' %]
711
                                [% CASE 'sort1' %]
713
                                {
712
                                {
714
                                    "data": "statistics_1",
713
                                    data: "statistics_1",
715
                                    "searchable": true,
714
                                    [% IF av_bsort1.size %]
716
                                    "orderable": true,
715
                                        dataFilter: "av_bsort1",
717
                                    "render": function( data, type, row, meta ) {
716
                                    [% END %]
717
                                    searchable: true,
718
                                    orderable: true,
719
                                    render: function( data, type, row, meta ) {
718
                                        if (data === null) return '';
720
                                        if (data === null) return '';
719
                                        let bsort1 = av_bsort1_map[data.toString()];
721
                                        let bsort1 = av_bsort1_map[data.toString()];
720
                                        return escape_str(bsort1 ? bsort1.lib : data);
722
                                        return escape_str(bsort1 ? bsort1.lib : data);
Lines 723-732 Link Here
723
725
724
                                [% CASE 'sort2' %]
726
                                [% CASE 'sort2' %]
725
                                {
727
                                {
726
                                    "data": "statistics_2",
728
                                    data: "statistics_2",
727
                                    "searchable": true,
729
                                    [% IF av_bsort2.size %]
728
                                    "orderable": true,
730
                                        dataFilter: "av_bsort2",
729
                                    "render": function( data, type, row, meta ) {
731
                                    [% END %]
732
                                    searchable: true,
733
                                    orderable: true,
734
                                    render: function( data, type, row, meta ) {
730
                                        if (data === null) return '';
735
                                        if (data === null) return '';
731
                                        let bsort2 = av_bsort2_map[data.toString()];
736
                                        let bsort2 = av_bsort2_map[data.toString()];
732
                                        return escape_str(bsort2 ? bsort2.lib : data);
737
                                        return escape_str(bsort2 ? bsort2.lib : data);
Lines 783-789 Link Here
783
                        },
788
                        },
784
                    [% END %]
789
                    [% END %]
785
                    fixedHeader: false,
790
                    fixedHeader: false,
786
                }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters, undefined, external_filter_nodes, parent_block.find(".search_description"), additional_search_descriptions );
791
                }, typeof table_settings !== 'undefined' ? table_settings : null, 1, additional_filters, filters_options, external_filter_nodes, parent_block.find(".search_description"), additional_search_descriptions );
787
792
788
                patron_search_form.on('submit', filter);
793
                patron_search_form.on('submit', filter);
789
                patron_search_form.on('submit', update_search_type);
794
                patron_search_form.on('submit', update_search_type);
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/itemsearch.tt (-18 / +17 lines)
Lines 632-646 Link Here
632
            } );
632
            } );
633
633
634
            let filters_options = {
634
            let filters_options = {
635
                4: () => all_ccodes,
635
                collection_codes: all_ccodes,
636
                9: () => all_libraries,
636
                libraries: all_libraries,
637
                10: () => all_libraries,
637
                locations: all_locations,
638
                11: () => all_locations,
638
                item_types: all_item_types,
639
                12: () => all_item_types,
639
                av_notforloan: all_notforloans,
640
                14: () => all_notforloans,
640
                av_lost: all_losts,
641
                15: () => all_losts,
641
                av_withdrawn: all_withdrawns,
642
                16: () => all_withdrawns,
642
                av_damaged: all_damageds,
643
                17: () => all_damageds,
644
            };
643
            };
645
644
646
            var table_settings = [% TablesSettings.GetTableSettings( 'catalogue', 'itemsearch', 'results', 'json' ) | $raw %];
645
            var table_settings = [% TablesSettings.GetTableSettings( 'catalogue', 'itemsearch', 'results', 'json' ) | $raw %];
Lines 672-691 Link Here
672
                    { 'name': 'title' },
671
                    { 'name': 'title' },
673
                    { 'name': 'publicationyear' },
672
                    { 'name': 'publicationyear' },
674
                    { 'name': 'publishercode' },
673
                    { 'name': 'publishercode' },
675
                    { 'name': 'ccode' },
674
                    { 'name': 'ccode', dataFilter: 'collection_codes' },
676
                    { 'name': 'barcode' },
675
                    { 'name': 'barcode' },
677
                    { 'name': 'itemnumber' },
676
                    { 'name': 'itemnumber' },
678
                    { 'name': 'enumchron' },
677
                    { 'name': 'enumchron' },
679
                    { 'name': 'itemcallnumber' },
678
                    { 'name': 'itemcallnumber' },
680
                    { 'name': 'homebranch' },
679
                    { 'name': 'homebranch', dataFilter: 'libraries' },
681
                    { 'name': 'holdingbranch' },
680
                    { 'name': 'holdingbranch', dataFilter: 'libraries' },
682
                    { 'name': 'location' },
681
                    { 'name': 'location', dataFilter: 'locations' },
683
                    { 'name': 'itype'},
682
                    { 'name': 'itype', dataFilter: 'item_types' },
684
                    { 'name': 'stocknumber' },
683
                    { 'name': 'stocknumber' },
685
                    { 'name': 'notforloan' },
684
                    { 'name': 'notforloan', dataFilter: 'av_notforloan' },
686
                    { 'name': 'itemlost' },
685
                    { 'name': 'itemlost', dataFilter: 'av_lost' },
687
                    { 'name': 'withdrawn' },
686
                    { 'name': 'withdrawn', dataFilter: 'av_widthdrawn' },
688
                    { 'name': 'damaged' },
687
                    { 'name': 'damaged', dataFilter: 'av_damaged' },
689
                    { 'name': 'dateaccessioned' },
688
                    { 'name': 'dateaccessioned' },
690
                    { 'name': 'issues' },
689
                    { 'name': 'issues' },
691
                    { 'name': 'datelastborrowed' },
690
                    { 'name': 'datelastborrowed' },
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingbookings.tt (-3 / +2 lines)
Lines 154-167 Link Here
154
                }
154
                }
155
            };
155
            };
156
156
157
            [% SET libraries = Branches.all %]
157
            let all_libraries  = [% To.json(Branches.all) | $raw %].map(e => {
158
            let all_libraries  = [% To.json(libraries) | $raw %].map(e => {
159
                e['_id'] = e.branchcode;
158
                e['_id'] = e.branchcode;
160
                e['_str'] = e.branchname;
159
                e['_str'] = e.branchname;
161
                return e;
160
                return e;
162
            });
161
            });
163
            let filters_options = {
162
            let filters_options = {
164
                [1] : () => all_libraries,
163
                libraries: all_libraries,
165
            };
164
            };
166
165
167
            var bookings_table_url = '/api/v1/bookings?';
166
            var bookings_table_url = '/api/v1/bookings?';
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-4 / +23 lines)
Lines 310-319 Link Here
310
310
311
        $(document).ready(function() {
311
        $(document).ready(function() {
312
            let filters_options = {
312
            let filters_options = {
313
                [5] : (table_dt) => get_options(table_dt.column(5)),
313
                libraries: (table_dt) => get_options(table_dt.column(5)),
314
                [10] : (table_dt) => get_options(table_dt.column(10)),
314
                item_types: (table_dt) => get_options(table_dt.column(10)),
315
                [11] : (table_dt) => get_options(table_dt.column(11)),
315
                locations: (table_dt) => get_options(table_dt.column(11)),
316
                [15] : (table_dt) => get_options(table_dt.column(15)),
316
                pickup_locations : (table_dt) => get_options(table_dt.column(15)),
317
            };
317
            };
318
318
319
319
Lines 321-326 Link Here
321
            var holdst = $("#holdst").kohaTable(
321
            var holdst = $("#holdst").kohaTable(
322
                {
322
                {
323
                    pagingType: "full_numbers",
323
                    pagingType: "full_numbers",
324
                    columns: [
325
                        {name: "pull_items" },
326
                        {name: "available_items" },
327
                        {name: "patrons" },
328
                        {name: "patron" },
329
                        {name: "title" },
330
                        {name: "libraries", dataFilter: "libraries" },
331
                        {name: "barcodes" },
332
                        {name: "call_numbers" },
333
                        {name: "copy_numbers" },
334
                        {name: "enumeration" },
335
                        {name: "itemtypes", dataFilter: "item_types" },
336
                        {name: "locations", dataFilter: "locations" },
337
                        {name: "collection" },
338
                        {name: "hold_date" },
339
                        {name: "reserve_nodes" },
340
                        {name: "pickup_location", dataFilter: "pickup_locations" },
341
                        {name: "action" },
342
                    ],
324
                },
343
                },
325
                table_settings,
344
                table_settings,
326
                true,
345
                true,
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-11 / +9 lines)
Lines 1035-1063 function _dt_add_filters(table_node, table_dt, filters_options = {}) { Link Here
1035
        let th = $(table_node).find(
1035
        let th = $(table_node).find(
1036
            "thead tr:eq(1) th:eq(%s)".format(visible_i)
1036
            "thead tr:eq(1) th:eq(%s)".format(visible_i)
1037
        );
1037
        );
1038
        var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
1038
        let col = table_dt.settings()[0].aoColumns[i];
1039
        var is_searchable = col.bSearchable;
1039
        $(this)
1040
        $(this)
1040
            .removeClass("sorting")
1041
            .removeClass("sorting")
1041
            .removeClass("sorting_asc")
1042
            .removeClass("sorting_asc")
1042
            .removeClass("sorting_desc");
1043
            .removeClass("sorting_desc");
1043
        $(this).data("th-id", i);
1044
        $(this).data("th-id", i);
1044
        if (is_searchable || $(this).data("filter") || filters_options[i]) {
1045
        if (is_searchable || col.dataFilter) {
1045
            let input_type = "input";
1046
            let input_type = "input";
1046
            let existing_search = column.search();
1047
            let existing_search = column.search();
1047
            if ($(th).data("filter") || filters_options.hasOwnProperty(i)) {
1048
            if (col.dataFilter) {
1048
                input_type = "select";
1049
                input_type = "select";
1049
                let filter_type = $(th).data("filter");
1050
                let filter_type = $(th).data("filter");
1050
                let select = $(
1051
                let select = $(
1051
                    '<select class="dt-select-filter"><option value=""></option></select'
1052
                    '<select class="dt-select-filter"><option value=""></option></select'
1052
                );
1053
                );
1053
1054
1054
                // FIXME eval here is bad and dangerous, how do we workaround that?
1055
                if (typeof filters_options[col.dataFilter] === "function") {
1055
                if (!filters_options.hasOwnProperty(i)) {
1056
                    filters_options[col.dataFilter] =
1056
                    filters_options[i] = eval(filter_type);
1057
                        filters_options[col.dataFilter](table_dt);
1057
                } else if (typeof filters_options[i] === "function") {
1058
                    filters_options[i] = filters_options[i](table_dt);
1059
                }
1058
                }
1060
                $(filters_options[i])
1059
                $(filters_options[col.dataFilter])
1061
                    .filter(function () {
1060
                    .filter(function () {
1062
                        return this._id !== "" && this._str !== "";
1061
                        return this._id !== "" && this._str !== "";
1063
                    })
1062
                    })
Lines 1066-1072 function _dt_add_filters(table_node, table_dt, filters_options = {}) { Link Here
1066
1065
1067
                        if (
1066
                        if (
1068
                            table_dt.settings()[0].ajax !== null &&
1067
                            table_dt.settings()[0].ajax !== null &&
1069
                            table_node.attr("id") !== "item_search"
1068
                            $(table_node).attr("id") !== "item_search"
1070
                        ) {
1069
                        ) {
1071
                            optionValue = `^${this._id}$`;
1070
                            optionValue = `^${this._id}$`;
1072
                        }
1071
                        }
1073
- 

Return to bug 38311