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

(-)a/Koha/REST/V1/Items.pm (-13 / +19 lines)
Lines 290-324 sub add_to_bundle { Link Here
290
            return $c->render(
290
            return $c->render(
291
                status  => 409,
291
                status  => 409,
292
                openapi => {
292
                openapi => {
293
                    error => 'Item is already bundled',
293
                    error      => 'Item is already bundled',
294
                    key   => $_->duplicate_id
294
                    error_code => 'already_bundled',
295
                    key        => $_->duplicate_id
295
                }
296
                }
296
            );
297
            );
297
        }
298
        }
298
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
299
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut' )
300
        {
299
            return $c->render(
301
            return $c->render(
300
                status => 400,
302
                status  => 409,
301
                openapi => {
303
                openapi => {
302
                    error => 'Bundles cannot be nested'
304
                    error      => 'Item is checked out',
305
                    error_code => 'checked_out'
303
                }
306
                }
304
            );
307
            );
305
        } elsif (ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut') {
308
        }
309
        elsif ( ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin' ) {
306
            return $c->render(
310
            return $c->render(
307
                status  => 409,
311
                status  => 409,
308
                openapi => {
312
                openapi => {
309
                    error => 'Item is checked out',
313
                    error      => 'Item cannot be checked in',
310
                    key   => 'checked_out'
314
                    error_code => 'failed_checkin'
311
                }
315
                }
312
            );
316
            );
313
        } elsif (ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin') {
317
        }
318
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
314
            return $c->render(
319
            return $c->render(
315
                status  => 409,
320
                status  => 400,
316
                openapi => {
321
                openapi => {
317
                    error => 'Item cannot be checked in',
322
                    error      => 'Bundles cannot be nested',
318
                    key   => 'failed_checkin'
323
                    error_code => 'failed_nesting'
319
                }
324
                }
320
            );
325
            );
321
        } else {
326
        }
327
        else {
322
            $c->unhandled_exception($_);
328
            $c->unhandled_exception($_);
323
        }
329
        }
324
    };
330
    };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-5 / +4 lines)
Lines 1957-1965 Note that permanent location is a code, and location may be an authval. Link Here
1957
                  posting.fail(function(data) {
1957
                  posting.fail(function(data) {
1958
                      if ( data.status === 409 ) {
1958
                      if ( data.status === 409 ) {
1959
                          var response = data.responseJSON;
1959
                          var response = data.responseJSON;
1960
                          if ( response.key === "PRIMARY" ) {
1960
                          if ( response.error_code === 'already_bundled' ) {
1961
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1961
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1962
                          } else if (response.key === 'checked_out') {
1962
                          } else if (response.error_code === 'checked_out') {
1963
                              const button = $('<button type="button">')
1963
                              const button = $('<button type="button">')
1964
                                .addClass('btn btn-xs')
1964
                                .addClass('btn btn-xs')
1965
                                .text(__('Check in and add to bundle'))
1965
                                .text(__('Check in and add to bundle'))
Lines 1971-1977 Note that permanent location is a code, and location may be an authval. Link Here
1971
                                .attr('class', 'alert alert-warning')
1971
                                .attr('class', 'alert alert-warning')
1972
                                .append(__x('Warning: Item {barcode} is checked out', { barcode }))
1972
                                .append(__x('Warning: Item {barcode} is checked out', { barcode }))
1973
                                .append(' ', button);
1973
                                .append(' ', button);
1974
                          } else if (response.key === 'failed_checkin') {
1974
                          } else if (response.error_code === 'failed_checkin') {
1975
                              $('#addResult')
1975
                              $('#addResult')
1976
                                .empty()
1976
                                .empty()
1977
                                .attr('class', 'alert alert-danger')
1977
                                .attr('class', 'alert alert-danger')
Lines 1983-1989 Note that permanent location is a code, and location may be an authval. Link Here
1983
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1983
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1984
                      } else if ( data.status === 400 ) {
1984
                      } else if ( data.status === 400 ) {
1985
                          var response = data.responseJSON;
1985
                          var response = data.responseJSON;
1986
                          if ( response.error === "Bundles cannot be nested" ) {
1986
                          if ( response.error_code === "failed_nesting" ) {
1987
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1987
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1988
                          } else {
1988
                          } else {
1989
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1989
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1990
- 

Return to bug 32121