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 225-230 Link Here
225
        [% IF Koha.Preference('UseCourseReserves') %]
225
        [% IF Koha.Preference('UseCourseReserves') %]
226
            const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
226
            const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
227
        [% END %]
227
        [% END %]
228
229
        const coded_values = {
230
            library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
231
            item_type: new Map(all_item_types.map( i => [i.translated_description, i.itemtype] )),
232
            collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])),
233
        };
234
228
        [% IF Koha.Preference('URLLinkText') %]
235
        [% IF Koha.Preference('URLLinkText') %]
229
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
236
            const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
230
        [% ELSE %]
237
        [% ELSE %]
Lines 234-240 Link Here
234
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
241
        [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
235
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
242
        [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
236
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
243
        let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
237
        let embed = ["+strings,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
244
        let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
238
        [% IF Koha.Preference('LocalCoverImages') %]
245
        [% IF Koha.Preference('LocalCoverImages') %]
239
            embed.push('cover_image_ids');
246
            embed.push('cover_image_ids');
240
        [% END %]
247
        [% END %]
Lines 276-281 Link Here
276
        };
283
        };
277
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
284
        function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
278
285
286
            let table_dt;
279
            if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
287
            if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
280
                // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
288
                // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
281
                let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
289
                let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
Lines 364-369 Link Here
364
                [% IF ( item_level_itypes ) %]
372
                [% IF ( item_level_itypes ) %]
365
                {
373
                {
366
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
374
                    data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
375
                    datatype: "coded_value:item_type",
367
                    className: "itype",
376
                    className: "itype",
368
                    searchable: true,
377
                    searchable: true,
369
                    orderable: true,
378
                    orderable: true,
Lines 382-388 Link Here
382
                },
391
                },
383
                [% END %]
392
                [% END %]
384
                {
393
                {
385
                    data: "holding_library.name:me.holding_library_id",
394
                    data: "me.holding_library_id",
395
                    datatype: "coded_value:library",
386
                    className: "location",
396
                    className: "location",
387
                    searchable: true,
397
                    searchable: true,
388
                    orderable: true,
398
                    orderable: true,
Lines 391-397 Link Here
391
                    }
401
                    }
392
                },
402
                },
393
                {
403
                {
394
                    data: "home_library.name:me.home_library_id",
404
                    data: "me.home_library_id",
405
                    datatype: "coded_value:library",
395
                    className: "homebranch",
406
                    className: "homebranch",
396
                    searchable: true,
407
                    searchable: true,
397
                    orderable: true,
408
                    orderable: true,
Lines 414-419 Link Here
414
                },
425
                },
415
                {
426
                {
416
                    data: "me.collection_code",
427
                    data: "me.collection_code",
428
                    datatype: "coded_value:collection_code",
417
                    searchable: true,
429
                    searchable: true,
418
                    orderable: true,
430
                    orderable: true,
419
                    render: function (data, type, row, meta) {
431
                    render: function (data, type, row, meta) {
Lines 869-875 Link Here
869
            filters_options,
881
            filters_options,
870
            );
882
            );
871
883
872
            let table_dt = items_table.DataTable();
884
            table_dt = items_table.DataTable();
873
            table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
885
            table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
874
                if (recalc === false) return;
886
                if (recalc === false) return;
875
887
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-4 / +51 lines)
Lines 521-526 function _dt_default_ajax(params) { Link Here
521
            var length = data.length;
521
            var length = data.length;
522
            var start = data.start;
522
            var start = data.start;
523
523
524
            let api = new $.fn.dataTable.Api(settings);
525
            const global_search = api.search();
526
524
            var dataSet = {
527
            var dataSet = {
525
                _page: Math.floor(start / length) + 1,
528
                _page: Math.floor(start / length) + 1,
526
                _per_page: length,
529
                _per_page: length,
Lines 532-537 function _dt_default_ajax(params) { Link Here
532
                for (var i = 0; i < attributes.length; i++) {
535
                for (var i = 0; i < attributes.length; i++) {
533
                    var part = {};
536
                    var part = {};
534
                    var attr = attributes[i];
537
                    var attr = attributes[i];
538
                    let default_build = true;
535
                    let criteria = options.criteria;
539
                    let criteria = options.criteria;
536
                    if (value.match(/^\^(.*)\$$/)) {
540
                    if (value.match(/^\^(.*)\$$/)) {
537
                        value = value.replace(/^\^/, "").replace(/\$$/, "");
541
                        value = value.replace(/^\^/, "").replace(/\$$/, "");
Lines 550-555 function _dt_default_ajax(params) { Link Here
550
                    }
554
                    }
551
555
552
                    if (col.datatype !== undefined) {
556
                    if (col.datatype !== undefined) {
557
                        default_build = false;
558
                        let coded_datatype =
559
                            col.datatype.match(/^coded_value:(.*)/);
553
                        if (col.datatype == "related-object") {
560
                        if (col.datatype == "related-object") {
554
                            let query_term = value;
561
                            let query_term = value;
555
562
Lines 576-581 function _dt_default_ajax(params) { Link Here
576
                                [col.related + "." + col.relatedSearchOn]:
583
                                [col.related + "." + col.relatedSearchOn]:
577
                                    query_term,
584
                                    query_term,
578
                            };
585
                            };
586
                        } else if (
587
                            coded_datatype &&
588
                            coded_datatype.length > 1
589
                        ) {
590
                            if (global_search.length) {
591
                                coded_datatype = coded_datatype[1];
592
                                const regex = new RegExp(
593
                                    `^${global_search}`,
594
                                    "i"
595
                                );
596
                                if (
597
                                    coded_values &&
598
                                    coded_values.hasOwnProperty(coded_datatype)
599
                                ) {
600
                                    let codes = [
601
                                        ...coded_values[
602
                                            coded_datatype
603
                                        ].entries(),
604
                                    ]
605
                                        .filter(([label]) => regex.test(label))
606
                                        .map(([, code]) => code);
607
608
                                    if (codes.length) {
609
                                        part[
610
                                            !attr.includes(".")
611
                                                ? "me." + attr
612
                                                : attr
613
                                        ] = codes;
614
                                    } else {
615
                                        // Coded value not found using the description, fallback to code
616
                                        default_build = true;
617
                                    }
618
                                } else {
619
                                    console.log(
620
                                        "coded datatype %s not supported yet".format(
621
                                            coded_datatype
622
                                        )
623
                                    );
624
                                }
625
                            } else {
626
                                default_build = true;
627
                            }
579
                        } else {
628
                        } else {
580
                            console.log(
629
                            console.log(
581
                                "datatype %s not supported yet".format(
630
                                "datatype %s not supported yet".format(
Lines 584-591 function _dt_default_ajax(params) { Link Here
584
                            );
633
                            );
585
                        }
634
                        }
586
                    }
635
                    }
587
636
                    if (default_build) {
588
                    if (col.datatype != "related-object") {
589
                        let value_part;
637
                        let value_part;
590
                        if (criteria === "exact") {
638
                        if (criteria === "exact") {
591
                            value_part = built_value
639
                            value_part = built_value
Lines 615-621 function _dt_default_ajax(params) { Link Here
615
                            value_part;
663
                            value_part;
616
                    }
664
                    }
617
665
618
                    parts.push(part);
666
                    if (Object.keys(part).length) parts.push(part);
619
                }
667
                }
620
                return parts;
668
                return parts;
621
            }
669
            }
622
- 

Return to bug 39011