Bugzilla – Attachment 124028 Details for
Bug 24857
Add ability to group items for records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24857: Add volume management to detail.pl
Bug-24857-Add-volume-management-to-detailpl.patch (text/plain), 16.17 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-08-23 15:10:41 UTC
(
hide
)
Description:
Bug 24857: Add volume management to detail.pl
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-08-23 15:10:41 UTC
Size:
16.17 KB
patch
obsolete
>From 054700898043a48131648191a8be1fb1b429e22d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >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 <andrew@bywatersolutions.com> > >Signed-off-by: Rebecca Coert <rcoert@arlingtonva.us> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../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 7c2b961d6c..10596b14e7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -273,6 +273,7 @@ > <a href="#holdings">Holdings ([% itemloop.size() || 0 | html %])</a> > </li> > [% END %] >+[% IF Koha.Preference('EnableVolumes') %]<li><a href="#volumes">Volumes</a></li>[% END %] > [% IF ( MARCNOTES || notes ) %]<li><a href="#description">Descriptions ([% ( MARCNOTES.size || 1 ) | html %])</a></li>[% END %] > [% IF ( subscriptionsnumber ) %]<li><a href="#subscriptions">Subscriptions</a></li>[% END %] > [% IF Koha.Preference('AcquisitionDetails') %]<li><a href="#acq_details">Acquisition details</a></li>[% END %] >@@ -602,6 +603,23 @@ Note that permanent location is a code, and location may be an authval. > > [% END %][%# end of block items_table %] > >+[% IF Koha.Preference('EnableVolumes') %] >+ <div id="volumes"> >+ <div class="volumes_table_table_controls"> >+ <a href="#" class="volume-create btn btn-default btn-xs"><i class="fa fa-plus"></i> Create new</a> >+ </div> >+ <table class="volumes-table" id="volumes-table"> >+ <thead> >+ <tr> >+ <td>Display Order</td> >+ <td>Description</td> >+ <td> </td> >+ </tr> >+ </thead> >+ </table> >+ </div> >+[% END %] >+ > <div id="holdings"> > > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && Koha.Preference('NovelistSelectStaffView') == 'above' ) %] >@@ -1020,6 +1038,88 @@ Note that permanent location is a code, and location may be an authval. > > [% END %] > >+<div class="modal fade" id="modal-volume-create" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-volume-create-label"><i class="fa fa-plus"></i> Create a new volume</h3> >+ </div> >+ <form id="modal-volume-create-form" class="validated"> >+ <div class="modal-body"> >+ <fieldset> >+ <p> >+ <label for="volume_description" class="required">Name: </label> >+ <input name="description" id="modal-volume-create-form-description" type="text" size="30" required="required" class="required" /> >+ <span class="required">Required</span> >+ </p> >+ <p> >+ <label for="volume_display_order" class="required">Display order: </label> >+ <input name="display_order" id="modal-volume-create-form-display_order" value="0" type="number" size="5" required="required" class="required" /> >+ <span class="required">Required</span> >+ <br/> >+ <span class="hint">Numbers only, volumes will be displayed in counting order</span> >+ </p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-volume-create-submit" class="btn btn-default"><i class="fa fa-plus"></i> Submit</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-volume-edit" tabindex="-1" role="dialog" aria-labelledby="modal-volume-edit-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-volume-edit-label"><i class='fa fa-edit'></i> Edit volume</h3> >+ </div> >+ <form id="modal-volume-edit-form" class="validated"> >+ <div class="modal-body"> >+ <fieldset> >+ <p> >+ <label for="volume_description" class="required">Name: </label> >+ <input name="description" id="modal-volume-edit-form-description" type="text" size="30" required="required" class="required" /> >+ <span class="required">Required</span> >+ </p> >+ <p> >+ <label for="volume_display_order" class="required">Sort order: </label> >+ <input name="display_order" id="modal-volume-edit-form-display_order" type="number" size="5" /> >+ <span class="hint">Numbers only, volumes will be displayed in counting order</span> >+ </p> >+ </fieldset> >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-volume-edit-submit" class="btn btn-default"><i class='fa fa-edit'></i> Submit</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </form> >+ </div> >+ </div> >+</div> >+ >+<div class="modal fade" id="modal-volume-delete" tabindex="-1" role="dialog" aria-labelledby="modal-volume-create-label"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="modal-volume-delete-label"><i class='fa fa-trash'></i> Delete volume</h3> >+ </div> >+ <div class="modal-body"> >+ Are you sure you want to delete this volume? >+ </div> >+ <div class="modal-footer"> >+ <button id="modal-volume-delete-submit" class="btn btn-danger"><i class='fa fa-trash'></i> Delete</button> >+ <button class="btn btn-link" data-dismiss="modal" aria-hidden="true">Cancel</button> >+ </div> >+ </div> >+ </div> >+</div> >+ > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'catalog-strings.inc' %] > [% Asset.js("js/catalog.js") | $raw %] >@@ -1368,6 +1468,193 @@ Note that permanent location is a code, and location may be an authval. > if ( search_index ){ $('#cat-search-block select.advsearch').val(search_index)}; > if ( search_value ){ $('#cat-search-block #search-form').val(search_value)}; > }); >+ >+ [% 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 `<button class='volume-edit btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'> >+ <i class='fa fa-edit'></i> ${_('Edit')} >+ </button>` >+ + ' ' >+ + `<button class='volume-delete btn btn-default btn-xs' data-volume-id='${oObj.volume_id}'> >+ <i class='fa fa-trash'></i> ${('Delete')} >+ </button>`; >+ }, >+ }, >+ ], >+ "bPaginate": false, >+ "bProcessing": true, >+ "bServerSide": false, >+ "sAjaxSource": `/api/v1/biblios/${biblionumber}/volumes?_per_page=-1`, >+ "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($('<option>', { >+ value: response.volume_id, >+ text: response.description >+ })); >+ >+ $('#modal-volume-create').modal('hide'); >+ if ( volumes.length == 0 ) { >+ // This bib has no previous volumes, reload the page >+ window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`); >+ } else { >+ // Has other volumes, just reload the table >+ 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'); >+ >+ $.ajax({ >+ url: `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`, >+ headers: { "x-koha-embed": "items" }, >+ success: function(volume_data){ >+ $.ajax({ >+ "url": `/api/v1/biblios/${biblionumber}/volumes/${volume_id}`, >+ "method": "DELETE", >+ }) >+ .done(function (response) { >+ $('#modal-volume-delete').modal('hide'); >+ $(`#volume-add-form-select option[value='${volume_id}']`).remove(); >+ if ( volume_data.items === null ) { >+ // No items for this volume, we can just refresh the table >+ volumesTable.api().ajax.reload(); >+ } else { >+ // This volume had items attached to it, we need to reload the page >+ window.location.replace(`/cgi-bin/koha/catalogue/detail.pl?biblionumber=${biblionumber}`); >+ } >+ }) >+ .fail(function(err) { >+ var message = err.responseJSON.error; >+ alert(message); >+ }); >+ } >+ }); >+ }); >+ [% END %] > </script> > [% END %] > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24857
:
100652
|
100653
|
100654
|
100655
|
100656
|
100657
|
100658
|
100659
|
100660
|
100661
|
100662
|
101637
|
101638
|
101639
|
101640
|
101641
|
101642
|
101643
|
101644
|
101645
|
101646
|
101647
|
101648
|
101650
|
101651
|
101652
|
101653
|
101654
|
101655
|
101656
|
101657
|
101658
|
101659
|
101660
|
101661
|
101670
|
101671
|
101672
|
101673
|
101674
|
101675
|
101676
|
101677
|
101678
|
101679
|
101680
|
101681
|
101730
|
101731
|
101732
|
101733
|
101734
|
101735
|
101736
|
101737
|
101738
|
101739
|
101740
|
101741
|
101752
|
101753
|
101754
|
101755
|
101756
|
101757
|
101758
|
101759
|
101760
|
101761
|
101762
|
101763
|
104952
|
104953
|
104954
|
104955
|
104956
|
104957
|
104958
|
104959
|
104960
|
104961
|
104962
|
104963
|
104964
|
104966
|
106728
|
106729
|
106730
|
106731
|
106732
|
106733
|
106734
|
106735
|
106736
|
106737
|
106738
|
106739
|
106740
|
106741
|
108443
|
108444
|
108445
|
108446
|
108447
|
108448
|
108449
|
108450
|
108451
|
108452
|
108453
|
108454
|
108455
|
108456
|
108666
|
108667
|
108668
|
108669
|
108670
|
108671
|
108672
|
108673
|
108674
|
108675
|
108676
|
108677
|
108678
|
108679
|
108680
|
108681
|
108682
|
108683
|
108684
|
108685
|
108686
|
109074
|
109075
|
109076
|
109077
|
109078
|
109079
|
109080
|
109081
|
109082
|
109083
|
109084
|
109085
|
109086
|
109087
|
109088
|
109089
|
109090
|
109091
|
109092
|
109093
|
109094
|
109795
|
109796
|
109797
|
109798
|
109799
|
109800
|
109801
|
109802
|
109803
|
109804
|
109805
|
109806
|
109807
|
109808
|
109809
|
109810
|
109811
|
109812
|
109813
|
109814
|
109815
|
109894
|
109901
|
109902
|
109903
|
109904
|
109905
|
109906
|
109907
|
109908
|
109909
|
109910
|
109911
|
109912
|
109913
|
109914
|
109915
|
109916
|
109917
|
109918
|
109919
|
109920
|
109921
|
109922
|
109923
|
113136
|
113137
|
113138
|
113139
|
113140
|
113141
|
113142
|
113143
|
113144
|
113145
|
113146
|
113147
|
113148
|
113149
|
113150
|
113151
|
113152
|
113153
|
113154
|
113155
|
113156
|
113157
|
113158
|
113159
|
113160
|
113168
|
113169
|
113170
|
113171
|
113172
|
113173
|
113174
|
113175
|
113176
|
113177
|
113178
|
113179
|
113180
|
113181
|
113182
|
113183
|
113184
|
113185
|
113186
|
113187
|
113188
|
113189
|
113190
|
113191
|
120495
|
120496
|
120497
|
120498
|
120499
|
120500
|
120501
|
120502
|
120503
|
120504
|
120505
|
120506
|
120507
|
120508
|
120509
|
120510
|
120511
|
120512
|
120513
|
120514
|
120515
|
120516
|
120517
|
120518
|
122808
|
122809
|
122810
|
122811
|
122812
|
122813
|
122814
|
122815
|
122816
|
122817
|
122818
|
122819
|
122820
|
122821
|
122822
|
122823
|
122824
|
122825
|
122826
|
122827
|
122828
|
122829
|
122830
|
122831
|
123882
|
123883
|
123884
|
123885
|
123886
|
123887
|
123888
|
123889
|
123890
|
123891
|
123892
|
123893
|
123894
|
123895
|
123896
|
123897
|
123898
|
123899
|
123900
|
123901
|
123902
|
123903
|
123904
|
123905
|
123906
|
123907
|
123908
|
123909
|
123910
|
123912
|
124021
|
124022
|
124023
|
124024
|
124025
|
124026
|
124027
|
124028
|
124029
|
124030
|
124031
|
124032
|
124033
|
124034
|
124035
|
124036
|
124037
|
124038
|
124039
|
124040
|
124041
|
124042
|
124043
|
124044
|
124045
|
124046
|
124047
|
124048
|
124049
|
124050
|
124051
|
124052
|
124053
|
124331
|
124332
|
124333
|
124334
|
124335
|
124336
|
124337
|
124338
|
124339
|
124340
|
124341
|
124342
|
124343
|
124344
|
124345
|
124346
|
124347
|
124348
|
124349
|
124351
|
124352
|
124353
|
124354
|
124355
|
124356
|
124357
|
124358
|
124359
|
124360
|
124361
|
124362
|
124363
|
124421
|
124463
|
124583
|
124584
|
124585
|
124586
|
124587
|
124588
|
124589
|
124590
|
124591
|
124592
|
124593
|
124594
|
124595
|
124596
|
124597
|
124598
|
124599
|
124600
|
124601
|
124602
|
124603
|
124604
|
124605
|
124606
|
124607
|
124608
|
124609
|
124610
|
124611
|
124612
|
124613
|
124614
|
124615
|
131449
|
131450
|
131451
|
131452
|
131453
|
131454
|
131455
|
131456
|
134288
|
134289
|
134290
|
134291
|
134292
|
134293
|
134294
|
134295
|
134296
|
135590
|
135591
|
135592
|
135593
|
135594
|
135595
|
135596
|
135597
|
135598
|
135599
|
135600
|
135601
|
135602
|
135603
|
135604
|
135605
|
135606
|
135607
|
135608
|
135609
|
135610
|
135614
|
135615
|
135616
|
135617
|
135618
|
135619
|
135620
|
135621
|
135622
|
135623
|
135624
|
135625
|
135626
|
135627
|
135628
|
135629
|
137259
|
137260
|
137261
|
137262
|
137263
|
137264
|
137265
|
137266
|
137267
|
137268
|
137311
|
137314
|
137315
|
137316
|
137317
|
137318
|
137319
|
137320
|
137321
|
137322
|
137323
|
137441
|
137442
|
137443
|
137608
|
138933