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 182-187 Link Here
182
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
182
            <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a>
183
        </li>
183
        </li>
184
    [% END %]
184
    [% END %]
185
[% IF Koha.Preference('EnableVolumes') %]<li><a href="#volumes">Volumes</a></li>[% END %]
185
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
186
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %]
186
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
187
[% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %]
187
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
188
[% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %]
Lines 475-480 Note that permanent location is a code, and location may be an authval. Link Here
475
    </table>
476
    </table>
476
[% END %][%# end of block items_table %]
477
[% END %][%# end of block items_table %]
477
478
479
[% IF Koha.Preference('EnableVolumes') %]
480
    <div id="volumes">
481
        <div class="volumes_table_table_controls">
482
            <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a>
483
        </div>
484
        <table class="volumes-table" id="volumes-table">
485
            <thead>
486
                <tr>
487
                    <td>Display Order</td>
488
                    <td>Description</td>
489
                    <td>&nbsp;</td>
490
                </tr>
491
            </thead>
492
        </table>
493
    </div>
494
[% END %]
495
478
<div id="holdings">
496
<div id="holdings">
479
497
480
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
498
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 816-821 Note that permanent location is a code, and location may be an authval. Link Here
816
834
817
[% END %]
835
[% END %]
818
836
837
<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
838
    <div class="modal-dialog">
839
        <div class="modal-content">
840
            <div class="modal-header">
841
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
842
                <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3>
843
            </div>
844
            <form id="modal-volume-create-form" class="validated">
845
                <div class="modal-body">
846
                    <fieldset>
847
                        <p>
848
                            <label for="volume_description" class="required">Name: </label>
849
                            <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" />
850
                            <span class="required">Required</span>
851
                        </p>
852
                        <p>
853
                            <label for="volume_display_order" class="required">Display order: </label>
854
                            <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" />
855
                            <span class="required">Required</span>
856
                            <br/>
857
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
858
                        </p>
859
                    </fieldset>
860
                </div>
861
                <div class="modal-footer">
862
                    <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
863
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
864
                </div>
865
            </form>
866
        </div>
867
    </div>
868
</div>
869
870
<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label">
871
    <div class="modal-dialog">
872
        <div class="modal-content">
873
            <div class="modal-header">
874
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
875
                <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3>
876
            </div>
877
            <form id="modal-volume-edit-form" class="validated">
878
                <div class="modal-body">
879
                    <fieldset>
880
                        <p>
881
                            <label for="volume_description" class="required">Name: </label>
882
                            <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" />
883
                            <span class="required">Required</span>
884
                        </p>
885
                        <p>
886
                            <label for="volume_display_order" class="required">Sort order: </label>
887
                            <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" />
888
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
889
                        </p>
890
                    </fieldset>
891
                </div>
892
                <div class="modal-footer">
893
                    <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
894
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
895
                </div>
896
            </form>
897
        </div>
898
    </div>
899
</div>
900
901
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
902
    <div class="modal-dialog">
903
        <div class="modal-content">
904
            <div class="modal-header">
905
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
906
                <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3>
907
            </div>
908
            <div class="modal-body">
909
                Are you sure you want to delete this volume?
910
            </div>
911
            <div class="modal-footer">
912
                <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
913
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
914
            </div>
915
        </div>
916
    </div>
917
</div>
918
819
[% MACRO jsinclude BLOCK %]
919
[% MACRO jsinclude BLOCK %]
820
    [% INCLUDE 'catalog-strings.inc' %]
920
    [% INCLUDE 'catalog-strings.inc' %]
821
    [% Asset.js("js/catalog.js") | $raw %]
921
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1066-1071 Note that permanent location is a code, and location may be an authval. Link Here
1066
                }, columns_settings);
1166
                }, columns_settings);
1067
            [% END %]
1167
            [% END %]
1068
        });
1168
        });
1169
1170
        [% IF Koha.Preference('EnableVolumes') %]
1171
            // Load volumes table
1172
            var volumesTable = KohaTable("volumes-table", {
1173
                "bAutoWidth": false,
1174
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1175
                "aoColumns": [
1176
                    {
1177
                        "mDataProp": function( oObj ) {
1178
                            return oObj.display_order;
1179
                        },
1180
                    },
1181
                    {
1182
                        "mDataProp": function( oObj ) {
1183
                            return oObj.description;
1184
                        },
1185
                    },
1186
                    {
1187
                        "mDataProp": function( oObj ) {
1188
                            return `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1189
                                <i class='fa fa-edit'></i> ${_('Edit')}
1190
                            </button>`
1191
                            + '&nbsp'
1192
                            + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1193
                                <i class='fa fa-trash'></i> ${('Delete')}
1194
                            </button>`;
1195
                        },
1196
                    },
1197
                ],
1198
                "bPaginate": false,
1199
                "bProcessing": true,
1200
                "bServerSide": false,
1201
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes`,
1202
                "sAjaxDataProp": "",
1203
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1204
                    $.getJSON( sSource, aoData, function (json) {
1205
                        fnCallback(json)
1206
                    } );
1207
                },
1208
            });
1209
1210
            // Create new volumes
1211
            $('.volume-create').on('click', function(){
1212
                $('#modal-volume-create-form-description').val("");
1213
                $('#modal-volume-create-submit').removeAttr('disabled');
1214
                $('#modal-volume-create').modal('show');
1215
            });
1216
1217
            $("#modal-volume-create-form").validate({
1218
                submitHandler: function(form) {
1219
                    $.ajax({
1220
                        url: `/api/v1/biblios/${biblionumber}/volumes`,
1221
                        headers: { "x-koha-embed": "items" },
1222
                        success: function(volumes){
1223
                            $('#modal-volume-create-submit').attr('disabled', 'disabled');
1224
1225
                            var settings = {
1226
                              "url": `/api/v1/biblios/${biblionumber}/volumes`,
1227
                              "method": "POST",
1228
                              "headers": {
1229
                                "Content-Type": "application/json"
1230
                              },
1231
                              "data": JSON.stringify(
1232
                                  {
1233
                                      "description": $("#modal-volume-create-form-description").val(),
1234
                                      "display_order": $("#modal-volume-create-form-display_order").val(),
1235
                                  }
1236
                              ),
1237
                            };
1238
1239
                            $.ajax(settings)
1240
                            .done(function (response) {
1241
                                $('#volume-add-form-select').append($('<option>', {
1242
                                    value: response.volume_id,
1243
                                    text: response.description
1244
                                }));
1245
1246
                                $('#modal-volume-create').modal('hide');
1247
                                if ( volumes.length == 0 ) {
1248
                                    // This bib has no previous volumes, reload the page
1249
                                    window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1250
                                } else {
1251
                                    // Has other volumes, just reload the table
1252
                                    volumesTable.api().ajax.reload();
1253
                                }
1254
                            })
1255
                            .fail(function(err) {
1256
                                var message = err.responseJSON.error;
1257
                                alert(message);
1258
                            });
1259
                        }
1260
                    });
1261
                }
1262
            });
1263
1264
            $('#modal-volume-create').on('shown.bs.modal', function () {
1265
                $('#modal-volume-create-form-description').focus();
1266
            })
1267
1268
            // Edit existing volumes
1269
            $('body').on( 'click', '.volume-edit', function(){
1270
                const volume_id = $(this).data('volume-id');
1271
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1272
                $.get( url, function( data ) {
1273
                    $('#modal-volume-edit-form-description').val( data.description );
1274
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1275
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1276
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1277
                    $('#modal-volume-edit').modal('show');
1278
                });
1279
            });
1280
1281
            $("#modal-volume-edit-form").validate({
1282
                submitHandler: function(form) {
1283
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1284
1285
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1286
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1287
1288
                    var settings = {
1289
                      "url": url,
1290
                      "method": "PUT",
1291
                      "headers": {
1292
                        "Content-Type": "application/json"
1293
                      },
1294
                      "data": JSON.stringify(
1295
                          {
1296
                              "description": $("#modal-volume-edit-form-description").val(),
1297
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1298
                          }
1299
                      ),
1300
                    };
1301
1302
                    $.ajax(settings)
1303
                    .done(function (response) {
1304
                        $('#modal-volume-edit').modal('hide');
1305
                        volumesTable.api().ajax.reload();
1306
                    })
1307
                    .fail(function(err) {
1308
                        var message = err.responseJSON.error;
1309
                        alert(message);
1310
                    });
1311
                }
1312
            });
1313
1314
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1315
                $('#modal-volume-edit-form-description').focus();
1316
            })
1317
1318
            // Delete existing volumes
1319
            $('body').on( 'click', '.volume-delete', function(){
1320
                const volume_id = $(this).data('volume-id');
1321
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1322
                $('#modal-volume-delete-submit').removeAttr('disabled');
1323
                $('#modal-volume-delete').modal('show');
1324
            });
1325
            $("#modal-volume-delete-submit").on('click', function(){
1326
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1327
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1328
1329
                $.ajax({
1330
                    url: `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1331
                    headers: { "x-koha-embed": "items" },
1332
                    success: function(volume_data){
1333
                        $.ajax({
1334
                          "url": `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`,
1335
                          "method": "DELETE",
1336
                        })
1337
                        .done(function (response) {
1338
                            $('#modal-volume-delete').modal('hide');
1339
                            $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1340
                            if ( volume_data.items === null ) {
1341
                                // No items for this volume, we can just refresh the table
1342
                                volumesTable.api().ajax.reload();
1343
                            } else {
1344
                                // This volume had items attached to it, we need to reload the page
1345
                                window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`);
1346
                            }
1347
                        })
1348
                        .fail(function(err) {
1349
                            var message = err.responseJSON.error;
1350
                            alert(message);
1351
                        });
1352
                    }
1353
                });
1354
            });
1355
        [% END %]
1069
    </script>
1356
    </script>
1070
[% END %]
1357
[% END %]
1071
[% INCLUDE 'intranet-bottom.inc' %]
1358
[% INCLUDE 'intranet-bottom.inc' %]
1072
- 

Return to bug 24857