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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-10 / +23 lines)
Lines 1183-1188 Link Here
1183
                });
1183
                });
1184
            [% END %]
1184
            [% END %]
1185
1185
1186
            function display_pickup_location (state) {
1187
                var $text;
1188
                if ( state.needs_override === true ) {
1189
                    $text = $(
1190
                        '<span>' + state.text + '</span> <span style="float:right;" title="' +
1191
                        _("This pickup location is not allowed according to circulation rules") +
1192
                        '"><i class="fa fa-exclamation-circle" aria-hidden="true"></i></span>'
1193
                    );
1194
                }
1195
                else {
1196
                    $text = $('<span>'+state.text+'</span>');
1197
                }
1198
1199
                return $text;
1200
            };
1201
1186
            $(".pickup_location_dropdown").each( function () {
1202
            $(".pickup_location_dropdown").each( function () {
1187
                var this_dropdown = $(this);
1203
                var this_dropdown = $(this);
1188
                var hold_id = $(this).data('hold_id');
1204
                var hold_id = $(this).data('hold_id');
Lines 1190-1223 Link Here
1190
                this_dropdown.select2({
1206
                this_dropdown.select2({
1191
                    allowClear: false,
1207
                    allowClear: false,
1192
                    ajax: {
1208
                    ajax: {
1193
                      [%- IF Koha.Preference('AllowHoldPolicyOverride') -%]
1194
                        url: '/api/v1/libraries',
1195
                      [%- ELSE -%]
1196
                        url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations',
1209
                        url: '/api/v1/holds/' + encodeURIComponent(hold_id) + '/pickup_locations',
1197
                      [%- END -%]
1198
                        delay: 300, // wait 300 milliseconds before triggering the request
1210
                        delay: 300, // wait 300 milliseconds before triggering the request
1199
                        dataType: 'json',
1211
                        dataType: 'json',
1200
                        data: function (params) {
1212
                        data: function (params) {
1201
                            var search_term = (params.term === undefined) ? '' : params.term;
1213
                            var search_term = (params.term === undefined) ? '' : params.term;
1202
                            var query = {
1214
                            var query = {
1203
                                "q": JSON.stringify({"name":{"-like":search_term+'%'},"pickup_location":1}),
1215
                                "q": JSON.stringify({"name":{"-like":search_term+'%'}}),
1204
                                "_order_by": "name"
1216
                                "_order_by": "name"
1205
                            };
1217
                            };
1206
                            return query;
1218
                            return query;
1207
                        },
1219
                        },
1208
                        processResults: function (data) {
1220
                        processResults: function (data) {
1209
                            var results = [];
1221
                            var results = [];
1210
                            data.forEach( function ( library ) {
1222
                            data.forEach( function ( pickup_location ) {
1211
                                results.push(
1223
                                results.push(
1212
                                    {
1224
                                    {
1213
                                        "id": library.library_id.escapeHtml(),
1225
                                        "id": pickup_location.library_id.escapeHtml(),
1214
                                        "text": library.name.escapeHtml()
1226
                                        "text": pickup_location.name.escapeHtml(),
1227
                                        "needs_override": pickup_location.needs_override
1215
                                    }
1228
                                    }
1216
                                );
1229
                                );
1217
                            });
1230
                            });
1218
                            return { "results": results };
1231
                            return { "results": results };
1219
                        }
1232
                        }
1220
                    }
1233
                    },
1234
                    templateResult: display_pickup_location
1221
                });
1235
                });
1222
            });
1236
            });
1223
        });
1237
        });
1224
- 

Return to bug 27894