Bug 22669: Fix item editing on receiving an order
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Wed, 24 Apr 2019 03:48:35 +0000 (23:48 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 26 Apr 2019 10:17:21 +0000 (10:17 +0000)
Since
  commit 1253975389975a8ff11a9bb2ef84582aeb6bd08b
  Bug 21091: Move add item template JavaScript to a separate file

items cannot longer be edited when receiving an order.
When moving the code to the JS file, the JS variable "opisadd" was
always set to "true":
  var opisadd = '[% opisadd | html %]';
Even if the TT variable is 0, opisadd will be "0", which is evaluated to
true in Javascript

To clean the situation it is easier to remove this variable and use "op"
instead.

Test plan:
- Make sure acqcreateitem is set to "when placing an order"
- Create a basket with some orders
- Close the basket
- Go to your vendor and receive an order
- On the receive page, try to edit your item
=> Without the patch, the pop up page will open and then close, not allowing the item to be edited.
=> With this patch applied you will see the item edit form. Save and
confirm that the parent window is updated with the new value (actually
it's refreshed)

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

cataloguing/additem.pl
koha-tmpl/intranet-tmpl/prog/en/includes/str/cataloging_additem.inc
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt
koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js

index 48417aa..062d335 100755 (executable)
@@ -931,7 +931,6 @@ $template->param(
     itemtagfield     => $itemtagfield,
     itemtagsubfield  => $itemtagsubfield,
     op      => $nextop,
-    opisadd => ($nextop eq "saveitem") ? 0 : 1,
     popup => scalar $input->param('popup') ? 1: 0,
     C4::Search::enabled_staff_search_views,
 );
index 0a14c10..97cadb9 100644 (file)
@@ -4,7 +4,7 @@
     var biblionumber = '[% biblionumber | html %]';
     var frameworkcode = '[% frameworkcode | html %]';
     var popup = '[% popup | html %]';
-    var opisadd = '[% opisadd | html %]';
+    var op = '[% op | html %]';
     var LABEL_EDIT_ITEM = _("Edit item");
     var LABEL_DELETE_ITEM = _("Delete item");
     var MSG_FORM_NOT_SUBMITTED = _("Form not submitted because of the following problem(s)");
index 4782d23..121ffc6 100644 (file)
         <input type="hidden" name="popup" value="1" />
     [% END %]
     <input type="hidden" name="biblionumber" value="[% biblionumber | html %]" />
-    [% IF ( opisadd ) %]
+    [% IF op != 'saveitem' %]
         <h2 id="additema">Add item [% IF (circborrowernumber) %]<em>(fast cataloging)</em>[% END %]</h2>
     [% ELSE %]
         <h2 id="edititem">Edit Item #[% itemnumber | html %][% IF ( barcode ) %] / Barcode [% barcode | html %][% END %]</h2>
     <input type="hidden" name="indicator" value=" " />
     <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
 
-<fieldset class="action">    [% IF ( opisadd ) %]
+<fieldset class="action">    [% IF op != 'saveitem' %]
     <input type="submit" name="phony_submit" value="phony_submit" id="phony_submit" style="display:none;" onclick="return false;" />
     <!-- Note : We use here a false submit button because we have several submit buttons and we don't want the user to believe they validated the adding of multiple items
                when pressing the enter key, while in fact it is the first submit button that is validated, in our case the "add (single) item" button.
index f4a5dc1..8c28e83 100644 (file)
@@ -1,4 +1,4 @@
-/* global KOHA searchid biblionumber frameworkcode popup opisadd LABEL_EDIT_ITEM LABEL_DELETE_ITEM MSG_FORM_NOT_SUBMITTED MSG_MANDATORY_FIELDS_EMPTY MSG_ADD_MULTIPLE_ITEMS MSG_ENTER_NUM_ITEMS MSG_CONFIRM_DELETE_ITEM MSG_CONFIRM_ADD_ITEM columns_settings CheckMandatorySubfields CheckMultipleAdd */
+/* global KOHA searchid biblionumber frameworkcode popup op LABEL_EDIT_ITEM LABEL_DELETE_ITEM MSG_FORM_NOT_SUBMITTED MSG_MANDATORY_FIELDS_EMPTY MSG_ADD_MULTIPLE_ITEMS MSG_ENTER_NUM_ITEMS MSG_CONFIRM_DELETE_ITEM MSG_CONFIRM_ADD_ITEM columns_settings CheckMandatorySubfields CheckMultipleAdd */
 
 var browser = KOHA.browser(searchid, parseInt(biblionumber, 10));
 browser.show();
@@ -9,10 +9,8 @@ $(document).ready(function(){
     // otherwise the deletion confirmation will not work correctly
     $('a[href*="biblionumber="]').off('click');
 
-    if( popup ){
-        if( opisadd ){
-            window.close();
-        }
+    if( popup && op != 'saveitem' ){
+        window.close();
     }
 
     $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit");
@@ -116,4 +114,4 @@ function Dopop(link,i) {
 
 function confirm_deletion() {
     return confirm( MSG_CONFIRM_DELETE_ITEM );
-}
\ No newline at end of file
+}