From 5f9c4b529209504b5148874d7ee3a7a163a19226 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 24 Feb 2020 12:06:17 -0500 Subject: [PATCH] Bug 24857: Add volume management to detail.pl Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Rebecca Coert --- .../prog/en/modules/catalogue/detail.tt | 287 ++++++++++++++++++ 1 file changed, 287 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 7b22f2c36d..28000f3336 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -242,6 +242,7 @@ Holdings ([% itemloop.size() || 0 | html %]) [% END %] +[% IF Koha.Preference('EnableVolumes') %]
  • Volumes
  • [% END %] [% IF ( MARCNOTES || notes ) %]
  • Descriptions ([% ( MARCNOTES.size || 1 ) | html %])
  • [% END %] [% IF ( subscriptionsnumber ) %]
  • Subscriptions
  • [% END %] [% IF Koha.Preference('AcquisitionDetails') %]
  • Acquisition details
  • [% END %] @@ -543,6 +544,23 @@ Note that permanent location is a code, and location may be an authval. [% END %][%# end of block items_table %] +[% IF Koha.Preference('EnableVolumes') %] +
    + + + + + + + + + +
    Display OrderDescription 
    +
    +[% END %] +
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %] @@ -959,6 +977,88 @@ Note that permanent location is a code, and location may be an authval. [% END %] + + + + + + [% MACRO jsinclude BLOCK %] [% INCLUDE 'catalog-strings.inc' %] [% Asset.js("js/catalog.js") | $raw %] @@ -1270,6 +1370,193 @@ Note that permanent location is a code, and location may be an authval. })); [% END %] }); + + [% IF Koha.Preference('EnableVolumes') %] + // Load volumes table + var volumesTable = KohaTable("volumes-table", { + "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 `` + + ' ' + + ``; + }, + }, + ], + "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) { + $.ajax({ + url: `/api/v1/biblios/${biblionumber}/volumes`, + headers: { "x-koha-embed": "items" }, + success: function(volumes){ + $('#modal-volume-create-submit').attr('disabled', 'disabled'); + + 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($('