From 5bed51ebfbdef455fcaa6f53d3011bf72d2a334c Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 12 Nov 2024 17:50:10 +0000 Subject: [PATCH] Bug 38428: Use links for stock rotation action buttons This patch converts the action buttons on the stock rotation rota manage items page to be links to avoid repeating form values (CSRF tokens, etc) It moves the confirmation for removal from a rota to be a confirm and not a full page reload. It also moves the fetch of a transfer into a shared variable. Lastly, there is some chomping added to remove extra whitespace. To test: 1 - Enable SotckRotation 2 - Create a rota 3 - Add some stages 4 - Add items to the rota 5 - Test the buttons to advance stage, add 'in demand' and remove 6 - Apply patch 7 - Confirm all buttons continue to function 8 - Sign off --- .../prog/en/modules/tools/stockrotation.tt | 105 +++++++----------- 1 file changed, 38 insertions(+), 67 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt index de37867206a..99cd8985785 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/stockrotation.tt @@ -378,22 +378,6 @@ - [% ELSIF (op == 'confirm_remove_from_rota') %] - -
-

Are you sure you wish to remove this item from its rota

-

-

- [% INCLUDE 'csrf-token.inc' %] - - - - - -
- No -

-
[% ELSIF (op == 'confirm_delete_rota') %]
@@ -512,12 +496,13 @@ [% FOREACH sritem IN sritems %] + [%- SET transfer = sritem.item.get_transfer -%] [% sritem.item.barcode | html %] [% sritem.item.biblio.title | html %] [% sritem.item.biblio.author | html %] [% sritem.item.itemcallnumber | html %] - [% IF ( transfer = sritem.item.get_transfer) %] + [% IF ( transfer ) %] [% IF (transfer.reason.match('Stockrotation.*')) %] [% IF (transfer.datesent) %] In transit from [% Branches.GetName( transfer.frombranch ) | html %] to [% Branches.GetName( transfer.tobranch ) | html %] since [% transfer.datesent | $KohaDates %] @@ -528,62 +513,47 @@ [% END %] - [% FOREACH this_stage IN stages %] - [% IF this_stage.stage_id == sritem.stage.stage_id %] + [%- FOREACH this_stage IN stages -%] + [%- IF this_stage.stage_id == sritem.stage.stage_id -%] - [% ELSE %] + [%- ELSE -%] - [% END %] - [% Branches.GetName(this_stage.branchcode_id) | html %] ([% this_stage.duration | html %]) - - » - [% END %] - [% IF stages.size > 0 %] + [%- END -%] + [%- Branches.GetName(this_stage.branchcode_id) | html -%] ([%- this_stage.duration | html -%]) + » + [%- END -%] + [%- IF stages.size > 0 -%] [% rota.cyclical ? 'START' : 'END' | html %] - [% END %] + [%- END -%] - [% in_transit = sritem.item.get_transfer %] - [% IF stages.size < 2 %] + [%- IF stages.size < 2 -%] - [% ELSE %] -
- [% INCLUDE 'csrf-token.inc' %] - - - - - [% IF !in_transit %] - - [% ELSE %] - - [% END %] -
- [% END %] - - [% IF !in_transit %] -
- [% INCLUDE 'csrf-token.inc' %] - - - - - [% IF sritem.indemand %] - - [% ELSE %] - - [% END %] -
- [% END %] - - [% IF !in_transit %] -
- [% ELSE %] - - [% END %] - - Remove from rota - + [%- ELSE -%] + [%- IF !transfer -%] + + [%- ELSE -%] + + [%- END -%] + Move to next stage + [%- END -%] + + [%- IF !transfer -%] + + [%- IF sritem.indemand -%] + Remove "In demand" + [%- ELSE -%] + Add "In demand" + [%- END -%] + + [%- END -%] + + [%- IF !transfer -%] + + [%- ELSE -%] + + [%- END -%] + Remove from rota [% END %] @@ -697,6 +667,7 @@ [% INCLUDE 'columns_settings.inc' %] [% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %] [% Asset.js("js/pages/stockrotation.js") | $raw %] + [% Asset.js("js/form-submit.js") | $raw %]