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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-10 / +38 lines)
Lines 8-13 Link Here
8
[% USE To %]
8
[% USE To %]
9
[% USE AuthorisedValues %]
9
[% USE AuthorisedValues %]
10
[% SET search_results_block_id = 'searchresults' %]
10
[% SET search_results_block_id = 'searchresults' %]
11
[% SET av_bsort1 = AuthorisedValues.Get('Bsort1') %]
12
[% SET av_bsort2 = AuthorisedValues.Get('Bsort2') %]
11
13
12
[%# Display a simple form %]
14
[%# Display a simple form %]
13
[% BLOCK patron_search_filters_simple  %]
15
[% BLOCK patron_search_filters_simple  %]
Lines 178-185 Link Here
178
                            [% CASE 'phone' %]<th>Phone</th>
180
                            [% CASE 'phone' %]<th>Phone</th>
179
                            [% CASE 'checkouts' %]<th>Checkouts</th>
181
                            [% CASE 'checkouts' %]<th>Checkouts</th>
180
                            [% CASE 'account_balance' %]<th>Fines</th>
182
                            [% CASE 'account_balance' %]<th>Fines</th>
181
                            [% CASE 'sort1' %]<th>Sort 1</th>
183
                            [% CASE 'sort1' %]
182
                            [% CASE 'sort2' %]<th>Sort 2</th>
184
                                [% IF av_bsort1.size %]
185
                                    <th data-filter="av_bsort1">Sort 1</th>
186
                                [% ELSE %]
187
                                    <th>Sort 1</th>
188
                                [% END %]
189
                            [% CASE 'sort2' %]
190
                                [% IF av_bsort2.size %]
191
                                    <th data-filter="av_bsort2">Sort 2</th>
192
                                [% ELSE %]
193
                                    <th>Sort 2</th>
194
                                [% END %]
183
                            [% CASE 'action' %]<th class="noExport">&nbsp;</th>
195
                            [% CASE 'action' %]<th class="noExport">&nbsp;</th>
184
                        [% END %]
196
                        [% END %]
185
                    [% END %]
197
                    [% END %]
Lines 247-252 Link Here
247
            return map;
259
            return map;
248
        }, {});
260
        }, {});
249
261
262
263
        const av_bsort1= [% To.json(av_bsort1) | $raw %].map( e => {
264
            e['_id'] = e.authorised_value;
265
            e['_str'] = e.lib;
266
            return e;
267
        });
268
        var av_bsort1_map = av_bsort1.reduce((map, e) => {
269
            map[e._id] = e;
270
            return map;
271
        }, {});
272
        const av_bsort2= [% To.json(av_bsort2) | $raw %].map( e => {
273
            e['_id'] = e.authorised_value;
274
            e['_str'] = e.lib;
275
            return e;
276
        });
277
        var av_bsort2_map = av_bsort2.reduce((map, e) => {
278
            map[e._id] = e;
279
            return map;
280
        }, {});
281
250
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
282
        [% IF Koha.Preference('ExtendedPatronAttributes') %]
251
            [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %]
283
            [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %]
252
            var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
284
            var extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %];
Lines 309-317 Link Here
309
            let patron_search_url = '/api/v1/patrons';
341
            let patron_search_url = '/api/v1/patrons';
310
        [% END %]
342
        [% END %]
311
343
312
        const av_bsort1= new Map([% To.json(AuthorisedValues.Get('Bsort1')) | $raw %].map( av => [av.authorised_value, av.lib]));
313
        const av_bsort2= new Map([% To.json(AuthorisedValues.Get('Bsort2')) | $raw %].map( av => [av.authorised_value, av.lib]));
314
315
        $(document).ready(function(){
344
        $(document).ready(function(){
316
345
317
            let parent_block = $("#[% search_results_block_id | html %]");
346
            let parent_block = $("#[% search_results_block_id | html %]");
Lines 627-634 Link Here
627
                                "searchable": true,
656
                                "searchable": true,
628
                                "orderable": true,
657
                                "orderable": true,
629
                                "render": function( data, type, row, meta ) {
658
                                "render": function( data, type, row, meta ) {
630
                                    let bsort2_lib = av_bsort2.get( data.toString() ) || data;
659
                                    let bsort2 = av_bsort2_map[data.toString()];
631
                                    return escape_str( bsort2_lib );
660
                                    return escape_str(bsort2 ? bsort2.lib : data);
632
                                }
661
                                }
633
                            }
662
                            }
634
663
Lines 638-645 Link Here
638
                                "searchable": true,
667
                                "searchable": true,
639
                                "orderable": true,
668
                                "orderable": true,
640
                                "render": function( data, type, row, meta ) {
669
                                "render": function( data, type, row, meta ) {
641
                                    let bsort1_lib = av_bsort1.get( data.toString() ) || data;
670
                                    let bsort1 = av_bsort1_map[data.toString()];
642
                                    return escape_str( bsort1_lib );
671
                                    return escape_str(bsort1 ? bsort1.lib : data);
643
                                }
672
                                }
644
                            }
673
                            }
645
674
646
- 

Return to bug 34608