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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-1 / +272 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</a></li>[% END %]
186
[% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions</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 463-468 Note that permanent location is a code, and location may be an authval. Link Here
463
    </table>
464
    </table>
464
[% END %][%# end of block items_table %]
465
[% END %][%# end of block items_table %]
465
466
467
[% IF Koha.Preference('EnableVolumes') %]
468
    <div id="volumes">
469
        <div class="volumes_table_table_controls">
470
            <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a>
471
        </div>
472
        <table class="volumes-table" id="volumes-table">
473
            <thead>
474
                <tr>
475
                    <td>Display Order</td>
476
                    <td>Description</td>
477
                    <td>&nbsp;</td>
478
                </tr>
479
            </thead>
480
        </table>
481
    </div>
482
[% END %]
483
466
<div id="holdings">
484
<div id="holdings">
467
485
468
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
486
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
Lines 804-809 Note that permanent location is a code, and location may be an authval. Link Here
804
822
805
[% END %]
823
[% END %]
806
824
825
<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
826
    <div class="modal-dialog">
827
        <div class="modal-content">
828
            <div class="modal-header">
829
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
830
                <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3>
831
            </div>
832
            <form id="modal-volume-create-form" class="validated">
833
                <div class="modal-body">
834
                    <fieldset>
835
                        <p>
836
                            <label for="volume_description" class="required">Name: </label>
837
                            <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" />
838
                            <span class="required">Required</span>
839
                        </p>
840
                        <p>
841
                            <label for="volume_display_order" class="required">Display order: </label>
842
                            <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" />
843
                            <span class="required">Required</span>
844
                            <br/>
845
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
846
                        </p>
847
                    </fieldset>
848
                </div>
849
                <div class="modal-footer">
850
                    <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button>
851
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
852
                </div>
853
            </form>
854
        </div>
855
    </div>
856
</div>
857
858
<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label">
859
    <div class="modal-dialog">
860
        <div class="modal-content">
861
            <div class="modal-header">
862
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
863
                <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3>
864
            </div>
865
            <form id="modal-volume-edit-form" class="validated">
866
                <div class="modal-body">
867
                    <fieldset>
868
                        <p>
869
                            <label for="volume_description" class="required">Name: </label>
870
                            <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" />
871
                            <span class="required">Required</span>
872
                        </p>
873
                        <p>
874
                            <label for="volume_display_order" class="required">Sort order: </label>
875
                            <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" />
876
                            <span class="hint">Numbers only, volumes will be displayed in counting order</span>
877
                        </p>
878
                    </fieldset>
879
                </div>
880
                <div class="modal-footer">
881
                    <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button>
882
                    <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
883
                </div>
884
            </form>
885
        </div>
886
    </div>
887
</div>
888
889
<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label">
890
    <div class="modal-dialog">
891
        <div class="modal-content">
892
            <div class="modal-header">
893
                <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
894
                <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3>
895
            </div>
896
            <div class="modal-body">
897
                Are you sure you want to delete this volume?
898
            </div>
899
            <div class="modal-footer">
900
                <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button>
901
                <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button>
902
            </div>
903
        </div>
904
    </div>
905
</div>
906
807
[% MACRO jsinclude BLOCK %]
907
[% MACRO jsinclude BLOCK %]
808
    [% INCLUDE 'catalog-strings.inc' %]
908
    [% INCLUDE 'catalog-strings.inc' %]
809
    [% Asset.js("js/catalog.js") | $raw %]
909
    [% Asset.js("js/catalog.js") | $raw %]
Lines 1054-1059 Note that permanent location is a code, and location may be an authval. Link Here
1054
                }, columns_settings);
1154
                }, columns_settings);
1055
            [% END %]
1155
            [% END %]
1056
        });
1156
        });
1157
1158
        [% IF Koha.Preference('EnableVolumes') %]
1159
            // Load volumes table
1160
            var volumesTable = KohaTable("volumes-table", {
1161
                "oLanguage": {
1162
                    "sEmptyTable" : MSG_DT_LOADING_RECORDS,
1163
                    "sProcessing": MSG_DT_LOADING_RECORDS,
1164
                },
1165
                "bAutoWidth": false,
1166
                'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
1167
                "aoColumns": [
1168
                    {
1169
                        "mDataProp": function( oObj ) {
1170
                            return oObj.display_order;
1171
                        },
1172
                    },
1173
                    {
1174
                        "mDataProp": function( oObj ) {
1175
                            return oObj.description;
1176
                        },
1177
                    },
1178
                    {
1179
                        "mDataProp": function( oObj ) {
1180
                            return `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1181
                                <i class='fa fa-edit'></i> ${_('Edit')}
1182
                            </button>`
1183
                            + '&nbsp'
1184
                            + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'>
1185
                                <i class='fa fa-trash'></i> ${('Delete')}
1186
                            </button>`;
1187
                        },
1188
                    },
1189
                ],
1190
                "bPaginate": false,
1191
                "bProcessing": true,
1192
                "bServerSide": false,
1193
                "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes`,
1194
                "sAjaxDataProp": "",
1195
                "fnServerData": function ( sSource, aoData, fnCallback ) {
1196
                    $.getJSON( sSource, aoData, function (json) {
1197
                        fnCallback(json)
1198
                    } );
1199
                },
1200
            });
1201
1202
            // Create new volumes
1203
            $('.volume-create').on('click', function(){
1204
                $('#modal-volume-create-form-description').val("");
1205
                $('#modal-volume-create-submit').removeAttr('disabled');
1206
                $('#modal-volume-create').modal('show'); 
1207
            });
1208
1209
            $("#modal-volume-create-form").validate({
1210
                submitHandler: function(form) {
1211
                    $('#modal-volume-create-submit').attr('disabled', 'disabled');
1212
1213
                    const url = `/api/v1/biblios/${biblionumber}/volumes`;
1214
1215
                    var settings = {
1216
                      "url": `/api/v1/biblios/${biblionumber}/volumes`,
1217
                      "method": "POST",
1218
                      "headers": {
1219
                        "Content-Type": "application/json"
1220
                      },
1221
                      "data": JSON.stringify(
1222
                          {
1223
                              "description": $("#modal-volume-create-form-description").val(),
1224
                              "display_order": $("#modal-volume-create-form-display_order").val(),
1225
                          }
1226
                      ),
1227
                    };
1228
1229
                    $.ajax(settings)
1230
                    .done(function (response) {
1231
                        $('#volume-add-form-select').append($('<option>', {
1232
                            value: response.volume_id,
1233
                            text: response.description
1234
                        }));
1235
1236
                        $('#modal-volume-create').modal('hide'); 
1237
                        volumesTable.api().ajax.reload();
1238
                    })
1239
                    .fail(function(err) {
1240
                        var message = err.responseJSON.error;
1241
                        alert(message);
1242
                    });
1243
                }
1244
            });
1245
1246
            $('#modal-volume-create').on('shown.bs.modal', function () {
1247
                $('#modal-volume-create-form-description').focus();
1248
            })
1249
1250
            // Edit existing volumes
1251
            $('body').on( 'click', '.volume-edit', function(){
1252
                const volume_id = $(this).data('volume-id');
1253
                const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1254
                $.get( url, function( data ) {
1255
                    $('#modal-volume-edit-form-description').val( data.description );
1256
                    $('#modal-volume-edit-form-display_order').val( data.display_order );
1257
                    $('#modal-volume-edit-submit').data('volume-id', volume_id );
1258
                    $('#modal-volume-edit-submit').removeAttr('disabled');
1259
                    $('#modal-volume-edit').modal('show'); 
1260
                });
1261
            });
1262
1263
            $("#modal-volume-edit-form").validate({
1264
                submitHandler: function(form) {
1265
                    $('#modal-volume-edit-submit').attr('disabled', 'disabled');
1266
1267
                    const volume_id = $('#modal-volume-edit-submit').data('volume-id');
1268
                    const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1269
1270
                    var settings = {
1271
                      "url": url,
1272
                      "method": "PUT",
1273
                      "headers": {
1274
                        "Content-Type": "application/json"
1275
                      },
1276
                      "data": JSON.stringify(
1277
                          {
1278
                              "description": $("#modal-volume-edit-form-description").val(),
1279
                              "display_order": $("#modal-volume-edit-form-display_order").val(),
1280
                          }
1281
                      ),
1282
                    };
1283
1284
                    $.ajax(settings)
1285
                    .done(function (response) {
1286
                        $('#modal-volume-edit').modal('hide'); 
1287
                        volumesTable.api().ajax.reload();
1288
                    })
1289
                    .fail(function(err) {
1290
                        var message = err.responseJSON.error;
1291
                        alert(message);
1292
                    });
1293
                }
1294
            });
1295
1296
            $('#modal-volume-edit').on('shown.bs.modal', function () {
1297
                $('#modal-volume-edit-form-description').focus();
1298
            })
1299
1300
            // Delete existing volumes
1301
            $('body').on( 'click', '.volume-delete', function(){
1302
                const volume_id = $(this).data('volume-id');
1303
                $('#modal-volume-delete-submit').data('volume-id', volume_id );
1304
                $('#modal-volume-delete-submit').removeAttr('disabled');
1305
                $('#modal-volume-delete').modal('show'); 
1306
            });
1307
            $("#modal-volume-delete-submit").on('click', function(){
1308
                $('#modal-volume-delete-submit').attr('disabled', 'disabled');
1309
                const volume_id = $("#modal-volume-delete-submit").data('volume-id');
1310
                let url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
1311
1312
                var settings = {
1313
                  "url": url,
1314
                  "method": "DELETE",
1315
                };
1316
1317
                $.ajax(settings)
1318
                .done(function (response) {
1319
                    $('#modal-volume-delete').modal('hide'); 
1320
                    $(`#volume-add-form-select option[value='${volume_id}']`).remove();
1321
                    volumesTable.api().ajax.reload();
1322
                })
1323
                .fail(function(err) {
1324
                    var message = err.responseJSON.error;
1325
                    alert(message);
1326
                });
1327
            });
1328
        [% END %]
1057
    </script>
1329
    </script>
1058
[% END %]
1330
[% END %]
1059
[% INCLUDE 'intranet-bottom.inc' %]
1331
[% INCLUDE 'intranet-bottom.inc' %]
1060
- 

Return to bug 24857