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 / +15 lines)
Lines 227-232 Link Here
227
    [% IF Koha.Preference('UseCourseReserves') %]
227
    [% IF Koha.Preference('UseCourseReserves') %]
228
        const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
228
        const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib]));
229
    [% END %]
229
    [% END %]
230
231
    const coded_values = {
232
        library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
233
        item_type: new Map(all_item_types.map( i => [i.itemtype, i.translated_description] )),
234
        collection_code: new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.ccode' })) | $raw %].map( av => [av.lib, av.authorised_value])),
235
    };
236
230
    [% IF Koha.Preference('URLLinkText') %]
237
    [% IF Koha.Preference('URLLinkText') %]
231
        const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
238
        const url_link_text = "[% Koha.Preference('URLLinkText') | html %]";
232
    [% ELSE %]
239
    [% ELSE %]
Lines 236-242 Link Here
236
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
243
    [%# In case or SeparateHoldings we may need to display the number of biblios in each tab %]
237
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
244
    [%# Do we need separate/new endpoints or do we hack the somewhere client-side? %]
238
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
245
    let item_table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
239
    let embed = ["+strings,home_library,holding_library,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
246
    let embed = ["+strings,checkout,checkout.patron,transfer,transfer+strings,first_hold,first_hold+strings,first_hold.patron,first_hold.desk"];
240
    [% IF Koha.Preference('LocalCoverImages') %]
247
    [% IF Koha.Preference('LocalCoverImages') %]
241
        embed.push('cover_image_ids');
248
        embed.push('cover_image_ids');
242
    [% END %]
249
    [% END %]
Lines 278-283 Link Here
278
    };
285
    };
279
    function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
286
    function build_items_table (tab_id, add_filters, dt_options, drawcallback) {
280
287
288
        let table_dt;
281
        if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
289
        if ( dt_options && dt_options.hasOwnProperty('destroy') ) {
282
            // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
290
            // Keep a copy of the user settings, the destroy is going to trigger the column-visibility.dt event for all columns
283
            let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
291
            let user_colvis_bak= Object.assign({}, user_colvis[tab_id]);
Lines 366-371 Link Here
366
            [% IF ( item_level_itypes ) %]
374
            [% IF ( item_level_itypes ) %]
367
            {
375
            {
368
                data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
376
                data: "me.item_type_id", // FIXME Cannot filter by biblioitem.itemtype
377
                datatype: "coded_value:item_type",
369
                className: "itype",
378
                className: "itype",
370
                searchable: true,
379
                searchable: true,
371
                orderable: true,
380
                orderable: true,
Lines 384-390 Link Here
384
            },
393
            },
385
            [% END %]
394
            [% END %]
386
            {
395
            {
387
                data: "holding_library.name:me.holding_library_id",
396
                data: "me.holding_library_id",
388
                className: "location",
397
                className: "location",
389
                searchable: true,
398
                searchable: true,
390
                orderable: true,
399
                orderable: true,
Lines 393-399 Link Here
393
                }
402
                }
394
            },
403
            },
395
            {
404
            {
396
                data: "home_library.name:me.home_library_id",
405
                data: "me.home_library_id",
406
                datatype: "coded_value:library",
397
                className: "homebranch",
407
                className: "homebranch",
398
                searchable: true,
408
                searchable: true,
399
                orderable: true,
409
                orderable: true,
Lines 416-421 Link Here
416
            },
426
            },
417
            {
427
            {
418
                data: "me.collection_code",
428
                data: "me.collection_code",
429
                datatype: "coded_value:collection_code",
419
                searchable: true,
430
                searchable: true,
420
                orderable: true,
431
                orderable: true,
421
                render: function (data, type, row, meta) {
432
                render: function (data, type, row, meta) {
Lines 871-877 Link Here
871
        filters_options,
882
        filters_options,
872
        );
883
        );
873
884
874
        let table_dt = items_table.DataTable();
885
        table_dt = items_table.DataTable();
875
        table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
886
        table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
876
            if (recalc === false) return;
887
            if (recalc === false) return;
877
888
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-4 / +29 lines)
Lines 444-449 function _dt_default_ajax (params){ Link Here
444
            var length = data.length;
444
            var length = data.length;
445
            var start  = data.start;
445
            var start  = data.start;
446
446
447
            let api = new $.fn.dataTable.Api( settings );
448
            const global_search = api.search();
449
447
            var dataSet = {
450
            var dataSet = {
448
                _page: Math.floor(start/length) + 1,
451
                _page: Math.floor(start/length) + 1,
449
                _per_page: length
452
                _per_page: length
Lines 456-461 function _dt_default_ajax (params){ Link Here
456
                for (var i=0;i<attributes.length;i++){
459
                for (var i=0;i<attributes.length;i++){
457
                    var part = {};
460
                    var part = {};
458
                    var attr = attributes[i];
461
                    var attr = attributes[i];
462
                    let default_build = true;
459
                    let criteria = options.criteria;
463
                    let criteria = options.criteria;
460
                    if ( value.match(/^\^(.*)\$$/) ) {
464
                    if ( value.match(/^\^(.*)\$$/) ) {
461
                        value = value.replace(/^\^/, '').replace(/\$$/, '');
465
                        value = value.replace(/^\^/, '').replace(/\$$/, '');
Lines 474-479 function _dt_default_ajax (params){ Link Here
474
                    }
478
                    }
475
479
476
                    if ( col.datatype !== undefined ) {
480
                    if ( col.datatype !== undefined ) {
481
                        default_build = false;
482
                        let coded_datatype = col.datatype.match(/^coded_value:(.*)/);
477
                        if (col.datatype == 'related-object') {
483
                        if (col.datatype == 'related-object') {
478
                            let query_term = value;
484
                            let query_term = value;
479
485
Lines 485-496 function _dt_default_ajax (params){ Link Here
485
                                [col.related + '.' + col.relatedKey]: col.relatedValue,
491
                                [col.related + '.' + col.relatedKey]: col.relatedValue,
486
                                [col.related + '.' + col.relatedSearchOn]: query_term
492
                                [col.related + '.' + col.relatedSearchOn]: query_term
487
                            };
493
                            };
494
                        } else if (coded_datatype && coded_datatype.length > 1) {
495
                            if (global_search.length){
496
                                coded_datatype = coded_datatype[1];
497
                                const regex = new RegExp(`^${global_search}`, 'i');
498
                                if ( coded_values && coded_values.hasOwnProperty(coded_datatype) ) {
499
                                    let codes = [...coded_values[coded_datatype].entries()]
500
                                            .filter(([label]) => regex.test(label))
501
                                            .map(([, code]) => code);
502
503
                                    if (codes.length){
504
                                        part[!attr.includes('.')?'me.'+attr:attr] = codes;
505
                                    } else {
506
                                        // Coded value not found using the description, fallback to code
507
                                        default_build = true;
508
                                    }
509
                                } else {
510
                                    console.log("coded datatype %s not supported yet".format(coded_datatype));
511
                                }
512
                            } else {
513
                                default_build = true;
514
                            }
488
                        } else {
515
                        } else {
489
                            console.log("datatype %s not supported yet".format(col.datatype));
516
                            console.log("datatype %s not supported yet".format(col.datatype));
490
                        }
517
                        }
491
                    }
518
                    }
492
519
                    if ( default_build ) {
493
                    if (col.datatype != 'related-object') {
494
                        let value_part;
520
                        let value_part;
495
                        if ( criteria === 'exact' ) {
521
                        if ( criteria === 'exact' ) {
496
                            value_part = built_value ? [value, built_value] : value
522
                            value_part = built_value ? [value, built_value] : value
Lines 502-508 function _dt_default_ajax (params){ Link Here
502
                        part[!attr.includes('.')?'me.'+attr:attr] = value_part;
528
                        part[!attr.includes('.')?'me.'+attr:attr] = value_part;
503
                    }
529
                    }
504
530
505
                    parts.push(part);
531
                    if (Object.keys(part).length) parts.push(part);
506
                }
532
                }
507
                return parts;
533
                return parts;
508
            }
534
            }
509
- 

Return to bug 39011