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 277-282 Link Here
277
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
277
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
278
        </li>
278
        </li>
279
    [% END %]
279
    [% END %]
280
[% IF Koha.Preference('EnableVolumes') %]<li><a href="#volumes">Volumes</a></li>[% END %]
280
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
281
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
281
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
282
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
282
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
283
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
Lines 606-611 Note that permanent location is a code, and location may be an authval. Link Here
606
607
607
[% END %][%# end of block items_table %]
608
[% END %][%# end of block items_table %]
608
609
610
[% IF Koha.Preference('EnableVolumes') %]
611
    <div id="volumes">
612
        <div class="volumes_table_table_controls">
613
            <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a>
614
        </div>
615
        <table class="volumes-table" id="volumes-table">
616
            <thead>
617
                <tr>
618
                    <td>Display Order</td>
619
                    <td>Description</td>
620
                    <td>&nbsp;</td>
621
                </tr>
622
            </thead>
623
        </table>
624
    </div>
625
[% END %]
626
609
<div id="holdings">
627
<div id="holdings">
610
628
611
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
629
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 1024-1029 Note that permanent location is a code, and location may be an authval. Link Here
1024
1042
1025
[% END %]
1043
[% END %]
1026
1044
1045
<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1046
    <div class="modal-dialog">
1047
        <div class="modal-content">
1048
            <div class="modal-header">
1049
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1050
                <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3>
1051
            </div>
1052
            <form id="modal-volume-create-form" class="validated">
1053
                <div class="modal-body">
1054
                    <fieldset>
1055
                        <p>
1056
                            <label for="volume_description" class="required">Name: </label>
1057
                            <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" />
1058
                            <span class="required">Required</span>
1059
                        </p>
1060
                        <p>
1061
                            <label for="volume_display_order" class="required">Display order: </label>
1062
                            <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" />
1063
                            <span class="required">Required</span>
1064
                            <br/>
1065
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
1066
                        </p>
1067
                    </fieldset>
1068
                </div>
1069
                <div class="modal-footer">
1070
                    <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
1071
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1072
                </div>
1073
            </form>
1074
        </div>
1075
    </div>
1076
</div>
1077
1078
<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label">
1079
    <div class="modal-dialog">
1080
        <div class="modal-content">
1081
            <div class="modal-header">
1082
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1083
                <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3>
1084
            </div>
1085
            <form id="modal-volume-edit-form" class="validated">
1086
                <div class="modal-body">
1087
                    <fieldset>
1088
                        <p>
1089
                            <label for="volume_description" class="required">Name: </label>
1090
                            <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" />
1091
                            <span class="required">Required</span>
1092
                        </p>
1093
                        <p>
1094
                            <label for="volume_display_order" class="required">Sort order: </label>
1095
                            <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" />
1096
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
1097
                        </p>
1098
                    </fieldset>
1099
                </div>
1100
                <div class="modal-footer">
1101
                    <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1102
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1103
                </div>
1104
            </form>
1105
        </div>
1106
    </div>
1107
</div>
1108
1109
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1110
    <div class="modal-dialog">
1111
        <div class="modal-content">
1112
            <div class="modal-header">
1113
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1114
                <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3>
1115
            </div>
1116
            <div class="modal-body">
1117
                Are you sure you want to delete this volume?
1118
            </div>
1119
            <div class="modal-footer">
1120
                <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1121
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1122
            </div>
1123
        </div>
1124
    </div>
1125
</div>
1126
1027
[% MACRO jsinclude BLOCK %]
1127
[% MACRO jsinclude BLOCK %]
1028
    [% INCLUDE 'catalog-strings.inc' %]
1128
    [% INCLUDE 'catalog-strings.inc' %]
1029
    [% Asset.js("js/catalog.js") | $raw %]
1129
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1372-1377 Note that permanent location is a code, and location may be an authval. Link Here
1372
            if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)};
1472
            if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)};
1373
            if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1473
            if ( search_value ){ $('#cat-search-block #search-form').val(search_value)};
1374
        });
1474
        });
1475
1476
        [% IF Koha.Preference('EnableVolumes') %]
1477
            // Load volumes table
1478
            var volumesTable = KohaTable("volumes-table", {
1479
                "bAutoWidth": false,
1480
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1481
                "aoColumns": [
1482
                    {
1483
                        "mDataProp": function( oObj ) {
1484
                            return oObj.display_order;
1485
                        },
1486
                    },
1487
                    {
1488
                        "mDataProp": function( oObj ) {
1489
                            return oObj.description;
1490
                        },
1491
                    },
1492
                    {
1493
                        "mDataProp": function( oObj ) {
1494
                            return `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1495
                                <i class='fa fa-edit'></i> ${_('Edit')}
1496
                            </button>`
1497
                            + '&nbsp'
1498
                            + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1499
                                <i class='fa fa-trash'></i> ${('Delete')}
1500
                            </button>`;
1501
                        },
1502
                    },
1503
                ],
1504
                "bPaginate": false,
1505
                "bProcessing": true,
1506
                "bServerSide": false,
1507
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes?_per_page=-1`,
1508
                "sAjaxDataProp": "",
1509
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1510
                    $.getJSON( sSource, aoData, function (json) {
1511
                        fnCallback(json)
1512
                    } );
1513
                },
1514
            });
1515
1516
            // Create new volumes
1517
            $('.volume-create').on('click', function(){
1518
                $('#modal-volume-create-form-description').val("");
1519
                $('#modal-volume-create-submit').removeAttr('disabled');
1520
                $('#modal-volume-create').modal('show');
1521
            });
1522
1523
            $("#modal-volume-create-form").validate({
1524
                submitHandler: function(form) {
1525
                    $.ajax({
1526
                        url: `/api/v1/biblios/${biblionumber}/volumes`,
1527
                        headers: { "x-koha-embed": "items" },
1528
                        success: function(volumes){
1529
                            $('#modal-volume-create-submit').attr('disabled', 'disabled');
1530
1531
                            var settings = {
1532
                              "url": `/api/v1/biblios/${biblionumber}/volumes`,
1533
                              "method": "POST",
1534
                              "headers": {
1535
                                "Content-Type": "application/json"
1536
                              },
1537
                              "data": JSON.stringify(
1538
                                  {
1539
                                      "description": $("#modal-volume-create-form-description").val(),
1540
                                      "display_order": $("#modal-volume-create-form-display_order").val(),
1541
                                  }
1542
                              ),
1543
                            };
1544
1545
                            $.ajax(settings)
1546
                            .done(function (response) {
1547
                                $('#volume-add-form-select').append($('<option>', {
1548
                                    value: response.volume_id,
1549
                                    text: response.description
1550
                                }));
1551
1552
                                $('#modal-volume-create').modal('hide');
1553
                                if ( volumes.length == 0 ) {
1554
                                    // This bib has no previous volumes, reload the page
1555
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1556
                                } else {
1557
                                    // Has other volumes, just reload the table
1558
                                    volumesTable.api().ajax.reload();
1559
                                }
1560
                            })
1561
                            .fail(function(err) {
1562
                                var message = err.responseJSON.error;
1563
                                alert(message);
1564
                            });
1565
                        }
1566
                    });
1567
                }
1568
            });
1569
1570
            $('#modal-volume-create').on('shown.bs.modal', function () {
1571
                $('#modal-volume-create-form-description').focus();
1572
            })
1573
1574
            // Edit existing volumes
1575
            $('body').on( 'click', '.volume-edit', function(){
1576
                const volume_id = $(this).data('volume-id');
1577
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1578
                $.get( url, function( data ) {
1579
                    $('#modal-volume-edit-form-description').val( data.description );
1580
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1581
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1582
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1583
                    $('#modal-volume-edit').modal('show');
1584
                });
1585
            });
1586
1587
            $("#modal-volume-edit-form").validate({
1588
                submitHandler: function(form) {
1589
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1590
1591
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1592
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1593
1594
                    var settings = {
1595
                      "url": url,
1596
                      "method": "PUT",
1597
                      "headers": {
1598
                        "Content-Type": "application/json"
1599
                      },
1600
                      "data": JSON.stringify(
1601
                          {
1602
                              "description": $("#modal-volume-edit-form-description").val(),
1603
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1604
                          }
1605
                      ),
1606
                    };
1607
1608
                    $.ajax(settings)
1609
                    .done(function (response) {
1610
                        $('#modal-volume-edit').modal('hide');
1611
                        volumesTable.api().ajax.reload();
1612
                    })
1613
                    .fail(function(err) {
1614
                        var message = err.responseJSON.error;
1615
                        alert(message);
1616
                    });
1617
                }
1618
            });
1619
1620
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1621
                $('#modal-volume-edit-form-description').focus();
1622
            })
1623
1624
            // Delete existing volumes
1625
            $('body').on( 'click', '.volume-delete', function(){
1626
                const volume_id = $(this).data('volume-id');
1627
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1628
                $('#modal-volume-delete-submit').removeAttr('disabled');
1629
                $('#modal-volume-delete').modal('show');
1630
            });
1631
            $("#modal-volume-delete-submit").on('click', function(){
1632
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1633
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1634
1635
                $.ajax({
1636
                    url: `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1637
                    headers: { "x-koha-embed": "items" },
1638
                    success: function(volume_data){
1639
                        $.ajax({
1640
                          "url": `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1641
                          "method": "DELETE",
1642
                        })
1643
                        .done(function (response) {
1644
                            $('#modal-volume-delete').modal('hide');
1645
                            $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1646
                            if ( volume_data.items === null ) {
1647
                                // No items for this volume, we can just refresh the table
1648
                                volumesTable.api().ajax.reload();
1649
                            } else {
1650
                                // This volume had items attached to it, we need to reload the page
1651
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1652
                            }
1653
                        })
1654
                        .fail(function(err) {
1655
                            var message = err.responseJSON.error;
1656
                            alert(message);
1657
                        });
1658
                    }
1659
                });
1660
            });
1661
        [% END %]
1375
    </script>
1662
    </script>
1376
[% END %]
1663
[% END %]
1377
[% INCLUDE 'intranet-bottom.inc' %]
1664
[% INCLUDE 'intranet-bottom.inc' %]
1378
- 

Return to bug 24857