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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-1 / +35 lines)
Lines 19-24 Link Here
19
</head>
19
</head>
20
20
21
<body id="circ_request" class="catalog">
21
<body id="circ_request" class="catalog">
22
<script>
23
    var select2Width = "100%";
24
</script>
22
[% INCLUDE 'header.inc' %]
25
[% INCLUDE 'header.inc' %]
23
[% INCLUDE 'circ-search.inc' %]
26
[% INCLUDE 'circ-search.inc' %]
24
27
Lines 985-991 Link Here
985
    [% INCLUDE 'columns_settings.inc' %]
988
    [% INCLUDE 'columns_settings.inc' %]
986
    [% Asset.js("lib/hc-sticky.js") | $raw %]
989
    [% Asset.js("lib/hc-sticky.js") | $raw %]
987
    [% Asset.js("js/circ-patron-search-results.js") | $raw %]
990
    [% Asset.js("js/circ-patron-search-results.js") | $raw %]
988
    [% Asset.js("js/holds.js") | $raw %]
991
    [% INCLUDE 'select2.inc' %]
989
    <script>
992
    <script>
990
        var Sticky;
993
        var Sticky;
991
        var biblionumber = "[% biblionumber | $raw %]";
994
        var biblionumber = "[% biblionumber | $raw %]";
Lines 1150-1155 Link Here
1150
                });
1153
                });
1151
            [% END %]
1154
            [% END %]
1152
1155
1156
            $(".pickup_location_dropdown").each( function () {
1157
                var this_dropdown = $(this);
1158
                var hold_id = $(this).data('hold_id');
1159
1160
                this_dropdown.select2({
1161
                    ajax: {
1162
                        url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations',
1163
                        allowClear: false,
1164
                        dataType: 'json',
1165
                        data: function (params) {
1166
                            var search_term = (params.term === undefined) ? '' : params.term;
1167
                            var query = {
1168
                                "q": JSON.stringify({"name":{"-like":search_term+'%'}})
1169
                            };
1170
                            return query;
1171
                        },
1172
                        processResults: function (data) {
1173
                            var results = [];
1174
                            data.forEach( function ( library ) {
1175
                                results.push(
1176
                                    {
1177
                                        "id": library.library_id.escapeHtml(),
1178
                                        "text": library.name.escapeHtml()
1179
                                    }
1180
                                );
1181
                            });
1182
                            return { "results": results };
1183
                        }
1184
                    }
1185
                });
1186
            });
1153
        });
1187
        });
1154
1188
1155
        function check() {
1189
        function check() {
(-)a/koha-tmpl/intranet-tmpl/prog/js/holds.js (-32 lines)
Lines 301-335 $(document).ready(function() { Link Here
301
          }
301
          }
302
        });
302
        });
303
    });
303
    });
304
305
    $(".pickup_location_dropdown").on( "focus",function(){
306
        var this_dropdown = $(this);
307
        if(this_dropdown.data('loaded')===1){ return true};
308
        var hold_id = $(this).data('hold_id');
309
        $(".loading_"+hold_id).show();
310
        var preselected = $(this).data('selected');
311
        var api_url = '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations';
312
        $.ajax({
313
            method: "GET",
314
            url: api_url,
315
            success: function( data ){
316
                var dropdown = "";
317
                $.each(data, function(index,library) {
318
                    if( preselected == library.library_id ){
319
                        selected = ' selected="selected" ';
320
                    } else { selected = ""; }
321
                    dropdown += '<option value="' + library.library_id.escapeHtml() + '"' + selected + '>' + library.name.escapeHtml() + '</option>';
322
                });
323
                this_dropdown.html(dropdown);
324
                this_dropdown.data("loaded",1);
325
                $(".loading_"+hold_id).hide();
326
            },
327
            error: function( jqXHR, textStatus, errorThrown) {
328
                alert('There was an error:'+textStatus+" "+errorThrown);
329
                $(".loading_"+hold_id).hide();
330
            },
331
        });
332
    });
333
334
335
});
304
});
336
- 

Return to bug 27016