From 684448217c0017ea1251f57364f9cfb719605c8c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Mon, 7 Nov 2016 14:10:41 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 17566: Change initial focus in item editor depending on last action If you have saved an existing item or added a new one, it would be nice to have the focus in the search box. In other cases, at the start of adding or editing an item, it would be good to have focus in the item fields already. This patch sets the focus in the second case on the first item input field, since focus on the first select (combo box) does not show up. Test plan: [1] From staff detail view, click Edit items in the menu. Focus should go to item fields. [2] Save this new item. Focus on search box? [3] Click to edit this item. Focus on item fields? [4] Save again. Focus on search box again? [5] Delete this item. Focus on search box again? Signed-off-by: Josef Moravec --- cataloguing/additem.pl | 4 +++- koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 9f0f146..a9f3cb5 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -635,7 +635,7 @@ if ($op eq "additem") { # check that there is no issue on this item before deletion. $error = &DelItemCheck( $biblionumber,$itemnumber); if($error == 1){ - print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid"); + print $input->redirect("additem.pl?biblionumber=$biblionumber&frameworkcode=$frameworkcode&searchid=$searchid&last_action=delitem"); }else{ push @errors,$error; $nextop="additem"; @@ -926,6 +926,8 @@ $template->param( barcode => GetBarcodeFromItemnumber($itemnumber), itemtagfield => $itemtagfield, itemtagsubfield => $itemtagsubfield, + # last_action determines focus on form + last_action => $op // $input->param('last_action') // '', op => $nextop, opisadd => ($nextop eq "saveitem") ? 0 : 1, popup => scalar $input->param('popup') ? 1: 0, diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt index db83ef8..1b90ee9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt @@ -82,6 +82,13 @@ $(document).ready(function(){ addSingleBlock.toggle(); multiCopyControl.toggle(); }); + [% IF last_action == "additem" || last_action == "saveitem" || last_action == "delitem" %] + $("input:text:visible:first").focus(); + [% ELSE %] + $("fieldset.rows input:visible:first").focus(); + // FIXME: The first input gets focus. Note that focus on the first + // select does not show properly. + [% END %] }); function Check(f) { -- 2.1.4