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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +268 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
                    $('#modal-volume-create-submit').attr('disabled', 'disabled');
1220
1221
                    const url = `/api/v1/biblios/${biblionumber}/volumes`;
1222
1223
                    var settings = {
1224
                      "url": `/api/v1/biblios/${biblionumber}/volumes`,
1225
                      "method": "POST",
1226
                      "headers": {
1227
                        "Content-Type": "application/json"
1228
                      },
1229
                      "data": JSON.stringify(
1230
                          {
1231
                              "description": $("#modal-volume-create-form-description").val(),
1232
                              "display_order": $("#modal-volume-create-form-display_order").val(),
1233
                          }
1234
                      ),
1235
                    };
1236
1237
                    $.ajax(settings)
1238
                    .done(function (response) {
1239
                        $('#volume-add-form-select').append($('<option>', {
1240
                            value: response.volume_id,
1241
                            text: response.description
1242
                        }));
1243
1244
                        $('#modal-volume-create').modal('hide');
1245
                        volumesTable.api().ajax.reload();
1246
                    })
1247
                    .fail(function(err) {
1248
                        var message = err.responseJSON.error;
1249
                        alert(message);
1250
                    });
1251
                }
1252
            });
1253
1254
            $('#modal-volume-create').on('shown.bs.modal', function () {
1255
                $('#modal-volume-create-form-description').focus();
1256
            })
1257
1258
            // Edit existing volumes
1259
            $('body').on( 'click', '.volume-edit', function(){
1260
                const volume_id = $(this).data('volume-id');
1261
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1262
                $.get( url, function( data ) {
1263
                    $('#modal-volume-edit-form-description').val( data.description );
1264
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1265
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1266
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1267
                    $('#modal-volume-edit').modal('show');
1268
                });
1269
            });
1270
1271
            $("#modal-volume-edit-form").validate({
1272
                submitHandler: function(form) {
1273
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1274
1275
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1276
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1277
1278
                    var settings = {
1279
                      "url": url,
1280
                      "method": "PUT",
1281
                      "headers": {
1282
                        "Content-Type": "application/json"
1283
                      },
1284
                      "data": JSON.stringify(
1285
                          {
1286
                              "description": $("#modal-volume-edit-form-description").val(),
1287
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1288
                          }
1289
                      ),
1290
                    };
1291
1292
                    $.ajax(settings)
1293
                    .done(function (response) {
1294
                        $('#modal-volume-edit').modal('hide');
1295
                        volumesTable.api().ajax.reload();
1296
                    })
1297
                    .fail(function(err) {
1298
                        var message = err.responseJSON.error;
1299
                        alert(message);
1300
                    });
1301
                }
1302
            });
1303
1304
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1305
                $('#modal-volume-edit-form-description').focus();
1306
            })
1307
1308
            // Delete existing volumes
1309
            $('body').on( 'click', '.volume-delete', function(){
1310
                const volume_id = $(this).data('volume-id');
1311
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1312
                $('#modal-volume-delete-submit').removeAttr('disabled');
1313
                $('#modal-volume-delete').modal('show');
1314
            });
1315
            $("#modal-volume-delete-submit").on('click', function(){
1316
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1317
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1318
                let url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1319
1320
                var settings = {
1321
                  "url": url,
1322
                  "method": "DELETE",
1323
                };
1324
1325
                $.ajax(settings)
1326
                .done(function (response) {
1327
                    $('#modal-volume-delete').modal('hide');
1328
                    $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1329
                    volumesTable.api().ajax.reload();
1330
                })
1331
                .fail(function(err) {
1332
                    var message = err.responseJSON.error;
1333
                    alert(message);
1334
                });
1335
            });
1336
        [% END %]
1069
    </script>
1337
    </script>
1070
[% END %]
1338
[% END %]
1071
[% INCLUDE 'intranet-bottom.inc' %]
1339
[% INCLUDE 'intranet-bottom.inc' %]
1072
- 

Return to bug 24857