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 241-246 Link Here
241
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
241
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
242
        </li>
242
        </li>
243
    [% END %]
243
    [% END %]
244
[% IF Koha.Preference('EnableVolumes') %]<li><a href="#volumes">Volumes</a></li>[% END %]
244
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
245
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
245
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
246
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
246
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
247
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
Lines 571-576 Note that permanent location is a code, and location may be an authval. Link Here
571
572
572
[% END %][%# end of block items_table %]
573
[% END %][%# end of block items_table %]
573
574
575
[% IF Koha.Preference('EnableVolumes') %]
576
    <div id="volumes">
577
        <div class="volumes_table_table_controls">
578
            <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a>
579
        </div>
580
        <table class="volumes-table" id="volumes-table">
581
            <thead>
582
                <tr>
583
                    <td>Display Order</td>
584
                    <td>Description</td>
585
                    <td>&nbsp;</td>
586
                </tr>
587
            </thead>
588
        </table>
589
    </div>
590
[% END %]
591
574
<div id="holdings">
592
<div id="holdings">
575
593
576
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
594
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 989-994 Note that permanent location is a code, and location may be an authval. Link Here
989
1007
990
[% END %]
1008
[% END %]
991
1009
1010
<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1011
    <div class="modal-dialog">
1012
        <div class="modal-content">
1013
            <div class="modal-header">
1014
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1015
                <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3>
1016
            </div>
1017
            <form id="modal-volume-create-form" class="validated">
1018
                <div class="modal-body">
1019
                    <fieldset>
1020
                        <p>
1021
                            <label for="volume_description" class="required">Name: </label>
1022
                            <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" />
1023
                            <span class="required">Required</span>
1024
                        </p>
1025
                        <p>
1026
                            <label for="volume_display_order" class="required">Display order: </label>
1027
                            <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" />
1028
                            <span class="required">Required</span>
1029
                            <br/>
1030
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
1031
                        </p>
1032
                    </fieldset>
1033
                </div>
1034
                <div class="modal-footer">
1035
                    <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
1036
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1037
                </div>
1038
            </form>
1039
        </div>
1040
    </div>
1041
</div>
1042
1043
<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label">
1044
    <div class="modal-dialog">
1045
        <div class="modal-content">
1046
            <div class="modal-header">
1047
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1048
                <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3>
1049
            </div>
1050
            <form id="modal-volume-edit-form" class="validated">
1051
                <div class="modal-body">
1052
                    <fieldset>
1053
                        <p>
1054
                            <label for="volume_description" class="required">Name: </label>
1055
                            <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" />
1056
                            <span class="required">Required</span>
1057
                        </p>
1058
                        <p>
1059
                            <label for="volume_display_order" class="required">Sort order: </label>
1060
                            <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" />
1061
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
1062
                        </p>
1063
                    </fieldset>
1064
                </div>
1065
                <div class="modal-footer">
1066
                    <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
1067
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1068
                </div>
1069
            </form>
1070
        </div>
1071
    </div>
1072
</div>
1073
1074
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
1075
    <div class="modal-dialog">
1076
        <div class="modal-content">
1077
            <div class="modal-header">
1078
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
1079
                <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3>
1080
            </div>
1081
            <div class="modal-body">
1082
                Are you sure you want to delete this volume?
1083
            </div>
1084
            <div class="modal-footer">
1085
                <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
1086
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
1087
            </div>
1088
        </div>
1089
    </div>
1090
</div>
1091
992
[% MACRO jsinclude BLOCK %]
1092
[% MACRO jsinclude BLOCK %]
993
    [% INCLUDE 'catalog-strings.inc' %]
1093
    [% INCLUDE 'catalog-strings.inc' %]
994
    [% Asset.js("js/catalog.js") | $raw %]
1094
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1308-1313 Note that permanent location is a code, and location may be an authval. Link Here
1308
                }));
1408
                }));
1309
            [% END %]
1409
            [% END %]
1310
        });
1410
        });
1411
1412
        [% IF Koha.Preference('EnableVolumes') %]
1413
            // Load volumes table
1414
            var volumesTable = KohaTable("volumes-table", {
1415
                "bAutoWidth": false,
1416
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1417
                "aoColumns": [
1418
                    {
1419
                        "mDataProp": function( oObj ) {
1420
                            return oObj.display_order;
1421
                        },
1422
                    },
1423
                    {
1424
                        "mDataProp": function( oObj ) {
1425
                            return oObj.description;
1426
                        },
1427
                    },
1428
                    {
1429
                        "mDataProp": function( oObj ) {
1430
                            return `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1431
                                <i class='fa fa-edit'></i> ${_('Edit')}
1432
                            </button>`
1433
                            + '&nbsp'
1434
                            + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1435
                                <i class='fa fa-trash'></i> ${('Delete')}
1436
                            </button>`;
1437
                        },
1438
                    },
1439
                ],
1440
                "bPaginate": false,
1441
                "bProcessing": true,
1442
                "bServerSide": false,
1443
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes?_per_page=-1`,
1444
                "sAjaxDataProp": "",
1445
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1446
                    $.getJSON( sSource, aoData, function (json) {
1447
                        fnCallback(json)
1448
                    } );
1449
                },
1450
            });
1451
1452
            // Create new volumes
1453
            $('.volume-create').on('click', function(){
1454
                $('#modal-volume-create-form-description').val("");
1455
                $('#modal-volume-create-submit').removeAttr('disabled');
1456
                $('#modal-volume-create').modal('show');
1457
            });
1458
1459
            $("#modal-volume-create-form").validate({
1460
                submitHandler: function(form) {
1461
                    $.ajax({
1462
                        url: `/api/v1/biblios/${biblionumber}/volumes`,
1463
                        headers: { "x-koha-embed": "items" },
1464
                        success: function(volumes){
1465
                            $('#modal-volume-create-submit').attr('disabled', 'disabled');
1466
1467
                            var settings = {
1468
                              "url": `/api/v1/biblios/${biblionumber}/volumes`,
1469
                              "method": "POST",
1470
                              "headers": {
1471
                                "Content-Type": "application/json"
1472
                              },
1473
                              "data": JSON.stringify(
1474
                                  {
1475
                                      "description": $("#modal-volume-create-form-description").val(),
1476
                                      "display_order": $("#modal-volume-create-form-display_order").val(),
1477
                                  }
1478
                              ),
1479
                            };
1480
1481
                            $.ajax(settings)
1482
                            .done(function (response) {
1483
                                $('#volume-add-form-select').append($('<option>', {
1484
                                    value: response.volume_id,
1485
                                    text: response.description
1486
                                }));
1487
1488
                                $('#modal-volume-create').modal('hide');
1489
                                if ( volumes.length == 0 ) {
1490
                                    // This bib has no previous volumes, reload the page
1491
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1492
                                } else {
1493
                                    // Has other volumes, just reload the table
1494
                                    volumesTable.api().ajax.reload();
1495
                                }
1496
                            })
1497
                            .fail(function(err) {
1498
                                var message = err.responseJSON.error;
1499
                                alert(message);
1500
                            });
1501
                        }
1502
                    });
1503
                }
1504
            });
1505
1506
            $('#modal-volume-create').on('shown.bs.modal', function () {
1507
                $('#modal-volume-create-form-description').focus();
1508
            })
1509
1510
            // Edit existing volumes
1511
            $('body').on( 'click', '.volume-edit', function(){
1512
                const volume_id = $(this).data('volume-id');
1513
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1514
                $.get( url, function( data ) {
1515
                    $('#modal-volume-edit-form-description').val( data.description );
1516
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1517
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1518
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1519
                    $('#modal-volume-edit').modal('show');
1520
                });
1521
            });
1522
1523
            $("#modal-volume-edit-form").validate({
1524
                submitHandler: function(form) {
1525
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1526
1527
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1528
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1529
1530
                    var settings = {
1531
                      "url": url,
1532
                      "method": "PUT",
1533
                      "headers": {
1534
                        "Content-Type": "application/json"
1535
                      },
1536
                      "data": JSON.stringify(
1537
                          {
1538
                              "description": $("#modal-volume-edit-form-description").val(),
1539
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1540
                          }
1541
                      ),
1542
                    };
1543
1544
                    $.ajax(settings)
1545
                    .done(function (response) {
1546
                        $('#modal-volume-edit').modal('hide');
1547
                        volumesTable.api().ajax.reload();
1548
                    })
1549
                    .fail(function(err) {
1550
                        var message = err.responseJSON.error;
1551
                        alert(message);
1552
                    });
1553
                }
1554
            });
1555
1556
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1557
                $('#modal-volume-edit-form-description').focus();
1558
            })
1559
1560
            // Delete existing volumes
1561
            $('body').on( 'click', '.volume-delete', function(){
1562
                const volume_id = $(this).data('volume-id');
1563
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1564
                $('#modal-volume-delete-submit').removeAttr('disabled');
1565
                $('#modal-volume-delete').modal('show');
1566
            });
1567
            $("#modal-volume-delete-submit").on('click', function(){
1568
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1569
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1570
1571
                $.ajax({
1572
                    url: `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1573
                    headers: { "x-koha-embed": "items" },
1574
                    success: function(volume_data){
1575
                        $.ajax({
1576
                          "url": `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1577
                          "method": "DELETE",
1578
                        })
1579
                        .done(function (response) {
1580
                            $('#modal-volume-delete').modal('hide');
1581
                            $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1582
                            if ( volume_data.items === null ) {
1583
                                // No items for this volume, we can just refresh the table
1584
                                volumesTable.api().ajax.reload();
1585
                            } else {
1586
                                // This volume had items attached to it, we need to reload the page
1587
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1588
                            }
1589
                        })
1590
                        .fail(function(err) {
1591
                            var message = err.responseJSON.error;
1592
                            alert(message);
1593
                        });
1594
                    }
1595
                });
1596
            });
1597
        [% END %]
1311
    </script>
1598
    </script>
1312
[% END %]
1599
[% END %]
1313
[% INCLUDE 'intranet-bottom.inc' %]
1600
[% INCLUDE 'intranet-bottom.inc' %]
1314
- 

Return to bug 24857