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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +287 lines)
Lines 230-235 Link Here
230
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
230
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
231
        </li>
231
        </li>
232
    [% END %]
232
    [% END %]
233
[% IF Koha.Preference('EnableVolumes') %]<li><a href="#volumes">Volumes</a></li>[% END %]
233
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
234
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
234
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
235
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
235
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
236
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
Lines 531-536 Note that permanent location is a code, and location may be an authval. Link Here
531
    </table>
532
    </table>
532
[% END %][%# end of block items_table %]
533
[% END %][%# end of block items_table %]
533
534
535
[% IF Koha.Preference('EnableVolumes') %]
536
    <div id="volumes">
537
        <div class="volumes_table_table_controls">
538
            <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a>
539
        </div>
540
        <table class="volumes-table" id="volumes-table">
541
            <thead>
542
                <tr>
543
                    <td>Display Order</td>
544
                    <td>Description</td>
545
                    <td>&nbsp;</td>
546
                </tr>
547
            </thead>
548
        </table>
549
    </div>
550
[% END %]
551
534
<div id="holdings">
552
<div id="holdings">
535
553
536
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
554
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 947-952 Note that permanent location is a code, and location may be an authval. Link Here
947
965
948
[% END %]
966
[% END %]
949
967
968
<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
969
    <div class="modal-dialog">
970
        <div class="modal-content">
971
            <div class="modal-header">
972
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
973
                <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3>
974
            </div>
975
            <form id="modal-volume-create-form" class="validated">
976
                <div class="modal-body">
977
                    <fieldset>
978
                        <p>
979
                            <label for="volume_description" class="required">Name: </label>
980
                            <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" />
981
                            <span class="required">Required</span>
982
                        </p>
983
                        <p>
984
                            <label for="volume_display_order" class="required">Display order: </label>
985
                            <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" />
986
                            <span class="required">Required</span>
987
                            <br/>
988
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
989
                        </p>
990
                    </fieldset>
991
                </div>
992
                <div class="modal-footer">
993
                    <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
994
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
995
                </div>
996
            </form>
997
        </div>
998
    </div>
999
</div>
1000
1001
<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label">
1002
    <div class="modal-dialog">
1003
        <div class="modal-content">
1004
            <div class="modal-header">
1005
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1006
                <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3>
1007
            </div>
1008
            <form id="modal-volume-edit-form" class="validated">
1009
                <div class="modal-body">
1010
                    <fieldset>
1011
                        <p>
1012
                            <label for="volume_description" class="required">Name: </label>
1013
                            <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" />
1014
                            <span class="required">Required</span>
1015
                        </p>
1016
                        <p>
1017
                            <label for="volume_display_order" class="required">Sort order: </label>
1018
                            <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" />
1019
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
1020
                        </p>
1021
                    </fieldset>
1022
                </div>
1023
                <div class="modal-footer">
1024
                    <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1025
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1026
                </div>
1027
            </form>
1028
        </div>
1029
    </div>
1030
</div>
1031
1032
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1033
    <div class="modal-dialog">
1034
        <div class="modal-content">
1035
            <div class="modal-header">
1036
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1037
                <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3>
1038
            </div>
1039
            <div class="modal-body">
1040
                Are you sure you want to delete this volume?
1041
            </div>
1042
            <div class="modal-footer">
1043
                <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1044
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1045
            </div>
1046
        </div>
1047
    </div>
1048
</div>
1049
950
[% MACRO jsinclude BLOCK %]
1050
[% MACRO jsinclude BLOCK %]
951
    [% INCLUDE 'catalog-strings.inc' %]
1051
    [% INCLUDE 'catalog-strings.inc' %]
952
    [% Asset.js("js/catalog.js") | $raw %]
1052
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1259-1264 Note that permanent location is a code, and location may be an authval. Link Here
1259
                }));
1359
                }));
1260
            [% END %]
1360
            [% END %]
1261
        });
1361
        });
1362
1363
        [% IF Koha.Preference('EnableVolumes') %]
1364
            // Load volumes table
1365
            var volumesTable = KohaTable("volumes-table", {
1366
                "bAutoWidth": false,
1367
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1368
                "aoColumns": [
1369
                    {
1370
                        "mDataProp": function( oObj ) {
1371
                            return oObj.display_order;
1372
                        },
1373
                    },
1374
                    {
1375
                        "mDataProp": function( oObj ) {
1376
                            return oObj.description;
1377
                        },
1378
                    },
1379
                    {
1380
                        "mDataProp": function( oObj ) {
1381
                            return `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1382
                                <i class='fa fa-edit'></i> ${_('Edit')}
1383
                            </button>`
1384
                            + '&nbsp'
1385
                            + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1386
                                <i class='fa fa-trash'></i> ${('Delete')}
1387
                            </button>`;
1388
                        },
1389
                    },
1390
                ],
1391
                "bPaginate": false,
1392
                "bProcessing": true,
1393
                "bServerSide": false,
1394
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes`,
1395
                "sAjaxDataProp": "",
1396
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1397
                    $.getJSON( sSource, aoData, function (json) {
1398
                        fnCallback(json)
1399
                    } );
1400
                },
1401
            });
1402
1403
            // Create new volumes
1404
            $('.volume-create').on('click', function(){
1405
                $('#modal-volume-create-form-description').val("");
1406
                $('#modal-volume-create-submit').removeAttr('disabled');
1407
                $('#modal-volume-create').modal('show');
1408
            });
1409
1410
            $("#modal-volume-create-form").validate({
1411
                submitHandler: function(form) {
1412
                    $.ajax({
1413
                        url: `/api/v1/biblios/${biblionumber}/volumes`,
1414
                        headers: { "x-koha-embed": "items" },
1415
                        success: function(volumes){
1416
                            $('#modal-volume-create-submit').attr('disabled', 'disabled');
1417
1418
                            var settings = {
1419
                              "url": `/api/v1/biblios/${biblionumber}/volumes`,
1420
                              "method": "POST",
1421
                              "headers": {
1422
                                "Content-Type": "application/json"
1423
                              },
1424
                              "data": JSON.stringify(
1425
                                  {
1426
                                      "description": $("#modal-volume-create-form-description").val(),
1427
                                      "display_order": $("#modal-volume-create-form-display_order").val(),
1428
                                  }
1429
                              ),
1430
                            };
1431
1432
                            $.ajax(settings)
1433
                            .done(function (response) {
1434
                                $('#volume-add-form-select').append($('<option>', {
1435
                                    value: response.volume_id,
1436
                                    text: response.description
1437
                                }));
1438
1439
                                $('#modal-volume-create').modal('hide');
1440
                                if ( volumes.length == 0 ) {
1441
                                    // This bib has no previous volumes, reload the page
1442
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1443
                                } else {
1444
                                    // Has other volumes, just reload the table
1445
                                    volumesTable.api().ajax.reload();
1446
                                }
1447
                            })
1448
                            .fail(function(err) {
1449
                                var message = err.responseJSON.error;
1450
                                alert(message);
1451
                            });
1452
                        }
1453
                    });
1454
                }
1455
            });
1456
1457
            $('#modal-volume-create').on('shown.bs.modal', function () {
1458
                $('#modal-volume-create-form-description').focus();
1459
            })
1460
1461
            // Edit existing volumes
1462
            $('body').on( 'click', '.volume-edit', function(){
1463
                const volume_id = $(this).data('volume-id');
1464
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1465
                $.get( url, function( data ) {
1466
                    $('#modal-volume-edit-form-description').val( data.description );
1467
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1468
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1469
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1470
                    $('#modal-volume-edit').modal('show');
1471
                });
1472
            });
1473
1474
            $("#modal-volume-edit-form").validate({
1475
                submitHandler: function(form) {
1476
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1477
1478
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1479
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1480
1481
                    var settings = {
1482
                      "url": url,
1483
                      "method": "PUT",
1484
                      "headers": {
1485
                        "Content-Type": "application/json"
1486
                      },
1487
                      "data": JSON.stringify(
1488
                          {
1489
                              "description": $("#modal-volume-edit-form-description").val(),
1490
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1491
                          }
1492
                      ),
1493
                    };
1494
1495
                    $.ajax(settings)
1496
                    .done(function (response) {
1497
                        $('#modal-volume-edit').modal('hide');
1498
                        volumesTable.api().ajax.reload();
1499
                    })
1500
                    .fail(function(err) {
1501
                        var message = err.responseJSON.error;
1502
                        alert(message);
1503
                    });
1504
                }
1505
            });
1506
1507
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1508
                $('#modal-volume-edit-form-description').focus();
1509
            })
1510
1511
            // Delete existing volumes
1512
            $('body').on( 'click', '.volume-delete', function(){
1513
                const volume_id = $(this).data('volume-id');
1514
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1515
                $('#modal-volume-delete-submit').removeAttr('disabled');
1516
                $('#modal-volume-delete').modal('show');
1517
            });
1518
            $("#modal-volume-delete-submit").on('click', function(){
1519
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1520
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1521
1522
                $.ajax({
1523
                    url: `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1524
                    headers: { "x-koha-embed": "items" },
1525
                    success: function(volume_data){
1526
                        $.ajax({
1527
                          "url": `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1528
                          "method": "DELETE",
1529
                        })
1530
                        .done(function (response) {
1531
                            $('#modal-volume-delete').modal('hide');
1532
                            $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1533
                            if ( volume_data.items === null ) {
1534
                                // No items for this volume, we can just refresh the table
1535
                                volumesTable.api().ajax.reload();
1536
                            } else {
1537
                                // This volume had items attached to it, we need to reload the page
1538
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1539
                            }
1540
                        })
1541
                        .fail(function(err) {
1542
                            var message = err.responseJSON.error;
1543
                            alert(message);
1544
                        });
1545
                    }
1546
                });
1547
            });
1548
        [% END %]
1262
    </script>
1549
    </script>
1263
[% END %]
1550
[% END %]
1264
[% INCLUDE 'intranet-bottom.inc' %]
1551
[% INCLUDE 'intranet-bottom.inc' %]
1265
- 

Return to bug 24857