@@ -, +, @@
---
.../prog/en/modules/catalogue/detail.tt | 272 ++++++++++++++++++
1 file changed, 272 insertions(+)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -182,6 +182,7 @@
Holdings ([% itemloop.size() || 0 | html %])
[% END %]
+[% IF Koha.Preference('EnableVolumes') %]
[% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %]
@@ -804,6 +822,88 @@ Note that permanent location is a code, and location may be an authval.
[% END %]
+
+
+
+
+
+
+
+
+
+ Are you sure you want to delete this volume?
+
+
+
+
+
+
[% MACRO jsinclude BLOCK %]
[% INCLUDE 'catalog-strings.inc' %]
[% Asset.js("js/catalog.js") | $raw %]
@@ -1054,6 +1154,178 @@ Note that permanent location is a code, and location may be an authval.
}, columns_settings);
[% END %]
});
+
+ [% IF Koha.Preference('EnableVolumes') %]
+ // Load volumes table
+ var volumesTable = KohaTable("volumes-table", {
+ "oLanguage": {
+ "sEmptyTable" : MSG_DT_LOADING_RECORDS,
+ "sProcessing": MSG_DT_LOADING_RECORDS,
+ },
+ "bAutoWidth": false,
+ 'sDom': '<"top pager"ilp>t<"bottom pager"ip>r',
+ "aoColumns": [
+ {
+ "mDataProp": function( oObj ) {
+ return oObj.display_order;
+ },
+ },
+ {
+ "mDataProp": function( oObj ) {
+ return oObj.description;
+ },
+ },
+ {
+ "mDataProp": function( oObj ) {
+ return `
+ ${_('Edit')}
+ `
+ + ' '
+ + `
+ ${('Delete')}
+ `;
+ },
+ },
+ ],
+ "bPaginate": false,
+ "bProcessing": true,
+ "bServerSide": false,
+ "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes`,
+ "sAjaxDataProp": "",
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ $.getJSON( sSource, aoData, function (json) {
+ fnCallback(json)
+ } );
+ },
+ });
+
+ // Create new volumes
+ $('.volume-create').on('click', function(){
+ $('#modal-volume-create-form-description').val("");
+ $('#modal-volume-create-submit').removeAttr('disabled');
+ $('#modal-volume-create').modal('show');
+ });
+
+ $("#modal-volume-create-form").validate({
+ submitHandler: function(form) {
+ $('#modal-volume-create-submit').attr('disabled', 'disabled');
+
+ const url = `/api/v1/biblios/${biblionumber}/volumes`;
+
+ var settings = {
+ "url": `/api/v1/biblios/${biblionumber}/volumes`,
+ "method": "POST",
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "data": JSON.stringify(
+ {
+ "description": $("#modal-volume-create-form-description").val(),
+ "display_order": $("#modal-volume-create-form-display_order").val(),
+ }
+ ),
+ };
+
+ $.ajax(settings)
+ .done(function (response) {
+ $('#volume-add-form-select').append($('
', {
+ value: response.volume_id,
+ text: response.description
+ }));
+
+ $('#modal-volume-create').modal('hide');
+ volumesTable.api().ajax.reload();
+ })
+ .fail(function(err) {
+ var message = err.responseJSON.error;
+ alert(message);
+ });
+ }
+ });
+
+ $('#modal-volume-create').on('shown.bs.modal', function () {
+ $('#modal-volume-create-form-description').focus();
+ })
+
+ // Edit existing volumes
+ $('body').on( 'click', '.volume-edit', function(){
+ const volume_id = $(this).data('volume-id');
+ const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
+ $.get( url, function( data ) {
+ $('#modal-volume-edit-form-description').val( data.description );
+ $('#modal-volume-edit-form-display_order').val( data.display_order );
+ $('#modal-volume-edit-submit').data('volume-id', volume_id );
+ $('#modal-volume-edit-submit').removeAttr('disabled');
+ $('#modal-volume-edit').modal('show');
+ });
+ });
+
+ $("#modal-volume-edit-form").validate({
+ submitHandler: function(form) {
+ $('#modal-volume-edit-submit').attr('disabled', 'disabled');
+
+ const volume_id = $('#modal-volume-edit-submit').data('volume-id');
+ const url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
+
+ var settings = {
+ "url": url,
+ "method": "PUT",
+ "headers": {
+ "Content-Type": "application/json"
+ },
+ "data": JSON.stringify(
+ {
+ "description": $("#modal-volume-edit-form-description").val(),
+ "display_order": $("#modal-volume-edit-form-display_order").val(),
+ }
+ ),
+ };
+
+ $.ajax(settings)
+ .done(function (response) {
+ $('#modal-volume-edit').modal('hide');
+ volumesTable.api().ajax.reload();
+ })
+ .fail(function(err) {
+ var message = err.responseJSON.error;
+ alert(message);
+ });
+ }
+ });
+
+ $('#modal-volume-edit').on('shown.bs.modal', function () {
+ $('#modal-volume-edit-form-description').focus();
+ })
+
+ // Delete existing volumes
+ $('body').on( 'click', '.volume-delete', function(){
+ const volume_id = $(this).data('volume-id');
+ $('#modal-volume-delete-submit').data('volume-id', volume_id );
+ $('#modal-volume-delete-submit').removeAttr('disabled');
+ $('#modal-volume-delete').modal('show');
+ });
+ $("#modal-volume-delete-submit").on('click', function(){
+ $('#modal-volume-delete-submit').attr('disabled', 'disabled');
+ const volume_id = $("#modal-volume-delete-submit").data('volume-id');
+ let url = `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`;
+
+ var settings = {
+ "url": url,
+ "method": "DELETE",
+ };
+
+ $.ajax(settings)
+ .done(function (response) {
+ $('#modal-volume-delete').modal('hide');
+ $(`#volume-add-form-select option[value='${volume_id}']`).remove();
+ volumesTable.api().ajax.reload();
+ })
+ .fail(function(err) {
+ var message = err.responseJSON.error;
+ alert(message);
+ });
+ });
+ [% END %]
[% END %]
[% INCLUDE 'intranet-bottom.inc' %]
--