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

(-)a/Koha/REST/V1/Items.pm (-13 / +19 lines)
Lines 289-323 sub add_to_bundle { Link Here
289
            return $c->render(
289
            return $c->render(
290
                status  => 409,
290
                status  => 409,
291
                openapi => {
291
                openapi => {
292
                    error => 'Item is already bundled',
292
                    error      => 'Item is already bundled',
293
                    key   => $_->duplicate_id
293
                    error_code => 'already_bundled',
294
                    key        => $_->duplicate_id
294
                }
295
                }
295
            );
296
            );
296
        }
297
        }
297
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
298
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut' )
299
        {
298
            return $c->render(
300
            return $c->render(
299
                status => 400,
301
                status  => 409,
300
                openapi => {
302
                openapi => {
301
                    error => 'Bundles cannot be nested'
303
                    error      => 'Item is checked out',
304
                    error_code => 'checked_out'
302
                }
305
                }
303
            );
306
            );
304
        } elsif (ref($_) eq 'Koha::Exceptions::Item::Bundle::ItemIsCheckedOut') {
307
        }
308
        elsif ( ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin' ) {
305
            return $c->render(
309
            return $c->render(
306
                status  => 409,
310
                status  => 409,
307
                openapi => {
311
                openapi => {
308
                    error => 'Item is checked out',
312
                    error      => 'Item cannot be checked in',
309
                    key   => 'checked_out'
313
                    error_code => 'failed_checkin'
310
                }
314
                }
311
            );
315
            );
312
        } elsif (ref($_) eq 'Koha::Exceptions::Checkin::FailedCheckin') {
316
        }
317
        elsif ( ref($_) eq 'Koha::Exceptions::Item::Bundle::IsBundle' ) {
313
            return $c->render(
318
            return $c->render(
314
                status  => 409,
319
                status  => 400,
315
                openapi => {
320
                openapi => {
316
                    error => 'Item cannot be checked in',
321
                    error      => 'Bundles cannot be nested',
317
                    key   => 'failed_checkin'
322
                    error_code => 'failed_nesting'
318
                }
323
                }
319
            );
324
            );
320
        } else {
325
        }
326
        else {
321
            $c->unhandled_exception($_);
327
            $c->unhandled_exception($_);
322
        }
328
        }
323
    };
329
    };
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-5 / +4 lines)
Lines 1779-1787 Note that permanent location is a code, and location may be an authval. Link Here
1779
                  posting.fail(function(data) {
1779
                  posting.fail(function(data) {
1780
                      if ( data.status === 409 ) {
1780
                      if ( data.status === 409 ) {
1781
                          var response = data.responseJSON;
1781
                          var response = data.responseJSON;
1782
                          if ( response.key === "PRIMARY" ) {
1782
                          if ( response.error_code === 'already_bundled' ) {
1783
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1783
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-warning">'+_("Warning: Item '%s' already attached").format(barcode)+'</div>');
1784
                          } else if (response.key === 'checked_out') {
1784
                          } else if (response.error_code === 'checked_out') {
1785
                              const button = $('<button type="button">')
1785
                              const button = $('<button type="button">')
1786
                                .addClass('btn btn-xs')
1786
                                .addClass('btn btn-xs')
1787
                                .text(__('Check in and add to bundle'))
1787
                                .text(__('Check in and add to bundle'))
Lines 1793-1799 Note that permanent location is a code, and location may be an authval. Link Here
1793
                                .attr('class', 'alert alert-warning')
1793
                                .attr('class', 'alert alert-warning')
1794
                                .append(__x('Warning: Item {barcode} is checked out', { barcode }))
1794
                                .append(__x('Warning: Item {barcode} is checked out', { barcode }))
1795
                                .append(' ', button);
1795
                                .append(' ', button);
1796
                          } else if (response.key === 'failed_checkin') {
1796
                          } else if (response.error_code === 'failed_checkin') {
1797
                              $('#addResult')
1797
                              $('#addResult')
1798
                                .empty()
1798
                                .empty()
1799
                                .attr('class', 'alert alert-danger')
1799
                                .attr('class', 'alert alert-danger')
Lines 1805-1811 Note that permanent location is a code, and location may be an authval. Link Here
1805
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1805
                          $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' not found").format(barcode)+'</div>');
1806
                      } else if ( data.status === 400 ) {
1806
                      } else if ( data.status === 400 ) {
1807
                          var response = data.responseJSON;
1807
                          var response = data.responseJSON;
1808
                          if ( response.error === "Bundles cannot be nested" ) {
1808
                          if ( response.error_code === "failed_nesting" ) {
1809
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1809
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Item '%s' is a bundle and bundles cannot be nested").format(barcode)+'</div>');
1810
                          } else {
1810
                          } else {
1811
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1811
                              $('#addResult').replaceWith('<div id="addResult" class="alert alert-danger">'+_("Failure: Check the logs for details")+'</div>');
1812
- 

Return to bug 32121