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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-4 / +16 lines)
Lines 231-236 Link Here
231
        [% IF Koha.Preference('UseCourseReserves') %]
231
        [% IF Koha.Preference('UseCourseReserves') %]
232
            const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
232
            const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
233
        [% END %]
233
        [% END %]
234
235
        const coded_values = {
236
            library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
237
            item_type: new Map(all_item_types.map( i => [i.translated_description, i.itemtype] )),
238
            collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])),
239
        };
240
234
        [% IF Koha.Preference('URLLinkText') %]
241
        [% IF Koha.Preference('URLLinkText') %]
235
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
242
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
236
        [% ELSE %]
243
        [% ELSE %]
Lines 240-246 Link Here
240
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
247
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
241
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
248
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
242
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
249
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
243
        let embed = ["+strings,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
250
        let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
244
        [% IF Koha.Preference('LocalCoverImages') %]
251
        [% IF Koha.Preference('LocalCoverImages') %]
245
            embed.push('cover_image_ids');
252
            embed.push('cover_image_ids');
246
        [% END %]
253
        [% END %]
Lines 282-287 Link Here
282
        };
289
        };
283
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
290
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
284
291
292
            let table_dt;
285
            if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
293
            if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
286
                // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
294
                // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
287
                let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
295
                let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
Lines 370-375 Link Here
370
                [% IF ( item_level_itypes ) %]
378
                [% IF ( item_level_itypes ) %]
371
                {
379
                {
372
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
380
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
381
                    datatype: "coded_value:item_type",
373
                    className: "itype",
382
                    className: "itype",
374
                    searchable: true,
383
                    searchable: true,
375
                    orderable: true,
384
                    orderable: true,
Lines 388-394 Link Here
388
                },
397
                },
389
                [% END %]
398
                [% END %]
390
                {
399
                {
391
                    data: "holding_library.name:me.holding_library_id",
400
                    data: "me.holding_library_id",
401
                    datatype: "coded_value:library",
392
                    className: "location",
402
                    className: "location",
393
                    searchable: true,
403
                    searchable: true,
394
                    orderable: true,
404
                    orderable: true,
Lines 397-403 Link Here
397
                    }
407
                    }
398
                },
408
                },
399
                {
409
                {
400
                    data: "home_library.name:me.home_library_id",
410
                    data: "me.home_library_id",
411
                    datatype: "coded_value:library",
401
                    className: "homebranch",
412
                    className: "homebranch",
402
                    searchable: true,
413
                    searchable: true,
403
                    orderable: true,
414
                    orderable: true,
Lines 427-432 Link Here
427
                },
438
                },
428
                {
439
                {
429
                    data: "me.collection_code",
440
                    data: "me.collection_code",
441
                    datatype: "coded_value:collection_code",
430
                    searchable: true,
442
                    searchable: true,
431
                    orderable: true,
443
                    orderable: true,
432
                    render: function (data, type, row, meta) {
444
                    render: function (data, type, row, meta) {
Lines 882-888 Link Here
882
            filters_options,
894
            filters_options,
883
            );
895
            );
884
896
885
            let table_dt = items_table.DataTable();
897
            table_dt = items_table.DataTable();
886
            table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
898
            table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
887
                if (recalc === false) return;
899
                if (recalc === false) return;
888
900
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-4 / +51 lines)
Lines 510-515 function _dt_default_ajax(params) { Link Here
510
            var length = data.length;
510
            var length = data.length;
511
            var start = data.start;
511
            var start = data.start;
512
512
513
            let api = new $.fn.dataTable.Api(settings);
514
            const global_search = api.search();
515
513
            var dataSet = {
516
            var dataSet = {
514
                _page: Math.floor(start / length) + 1,
517
                _page: Math.floor(start / length) + 1,
515
                _per_page: length,
518
                _per_page: length,
Lines 521-526 function _dt_default_ajax(params) { Link Here
521
                for (var i = 0; i < attributes.length; i++) {
524
                for (var i = 0; i < attributes.length; i++) {
522
                    var part = {};
525
                    var part = {};
523
                    var attr = attributes[i];
526
                    var attr = attributes[i];
527
                    let default_build = true;
524
                    let criteria = options.criteria;
528
                    let criteria = options.criteria;
525
                    if (value.match(/^\^(.*)\$$/)) {
529
                    if (value.match(/^\^(.*)\$$/)) {
526
                        value = value.replace(/^\^/, "").replace(/\$$/, "");
530
                        value = value.replace(/^\^/, "").replace(/\$$/, "");
Lines 539-544 function _dt_default_ajax(params) { Link Here
539
                    }
543
                    }
540
544
541
                    if (col.datatype !== undefined) {
545
                    if (col.datatype !== undefined) {
546
                        default_build = false;
547
                        let coded_datatype =
548
                            col.datatype.match(/^coded_value:(.*)/);
542
                        if (col.datatype == "related-object") {
549
                        if (col.datatype == "related-object") {
543
                            let query_term = value;
550
                            let query_term = value;
544
551
Lines 565-570 function _dt_default_ajax(params) { Link Here
565
                                [col.related + "." + col.relatedSearchOn]:
572
                                [col.related + "." + col.relatedSearchOn]:
566
                                    query_term,
573
                                    query_term,
567
                            };
574
                            };
575
                        } else if (
576
                            coded_datatype &&
577
                            coded_datatype.length > 1
578
                        ) {
579
                            if (global_search.length) {
580
                                coded_datatype = coded_datatype[1];
581
                                const regex = new RegExp(
582
                                    `^${global_search}`,
583
                                    "i"
584
                                );
585
                                if (
586
                                    coded_values &&
587
                                    coded_values.hasOwnProperty(coded_datatype)
588
                                ) {
589
                                    let codes = [
590
                                        ...coded_values[
591
                                            coded_datatype
592
                                        ].entries(),
593
                                    ]
594
                                        .filter(([label]) => regex.test(label))
595
                                        .map(([, code]) => code);
596
597
                                    if (codes.length) {
598
                                        part[
599
                                            !attr.includes(".")
600
                                                ? "me." + attr
601
                                                : attr
602
                                        ] = codes;
603
                                    } else {
604
                                        // Coded value not found using the description, fallback to code
605
                                        default_build = true;
606
                                    }
607
                                } else {
608
                                    console.log(
609
                                        "coded datatype %s not supported yet".format(
610
                                            coded_datatype
611
                                        )
612
                                    );
613
                                }
614
                            } else {
615
                                default_build = true;
616
                            }
568
                        } else {
617
                        } else {
569
                            console.log(
618
                            console.log(
570
                                "datatype %s not supported yet".format(
619
                                "datatype %s not supported yet".format(
Lines 573-580 function _dt_default_ajax(params) { Link Here
573
                            );
622
                            );
574
                        }
623
                        }
575
                    }
624
                    }
576
625
                    if (default_build) {
577
                    if (col.datatype != "related-object") {
578
                        let value_part;
626
                        let value_part;
579
                        if (criteria === "exact") {
627
                        if (criteria === "exact") {
580
                            value_part = built_value
628
                            value_part = built_value
Lines 604-610 function _dt_default_ajax(params) { Link Here
604
                            value_part;
652
                            value_part;
605
                    }
653
                    }
606
654
607
                    parts.push(part);
655
                    if (Object.keys(part).length) parts.push(part);
608
                }
656
                }
609
                return parts;
657
                return parts;
610
            }
658
            }
611
- 

Return to bug 39011