From 39f15482ebfdb7933701d9ce9db8d1e64d4d2184 Mon Sep 17 00:00:00 2001
From: Jason Stephenson <jason@sigio.com>
Date: Tue, 18 Dec 2018 09:26:11 -0500
Subject: [PATCH] Lp 1752968: Select content when focusing on the barcode
 field.

To reproduce the reported behavior:

 1. Find a title in the staff client catalog.
 2. Click on Add Holdings.
 3. See that the Barcode field does not have cursor focus.
 4. Repeat step 1.
 5. Click on edit next to one of the barcoded items in the list of
    holdings.
 6. Click Show Holdings Details and see that the Barcode field does
     not have focus and the content is not selected.

To test this branch:

 1. Find a title in the staff client catalog.
 2. Click on Add Holdings.
 3. See that the Barcode field has cursor focus, i.e. the cursor is in
    the field and blinking.
 4. Repeat step 1.
 5. Click on edit next to one of the barcoded items in the list of
    holdings.
 6. Click Show Holdings Details and see that the Barcode field has
     cursor focus and the content is selected/highlighted.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Janet Schrader <jschrader@cwmars.org>
---
 Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js
index 8eda695b3b..507c4cbb10 100644
--- a/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js
+++ b/Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js
@@ -489,7 +489,7 @@ function(egCore , $q) {
                     '<input id="{{callNumber.id()}}_{{copy.id()}}"'+
                     ' eg-enter="nextBarcode(copy.id())" class="form-control"'+
                     ' type="text" ng-model="barcode" ng-change="updateBarcode()"'+
-                    ' autofocus/>'+
+                    ' ng-focus="selectOnFocus($event)" autofocus/>'+
                     '<div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>'+
                     '<div class="label label-danger" ng-if="empty_barcode">{{empty_barcode_string}}</div>'+
                 '</div>'+
@@ -509,6 +509,11 @@ function(egCore , $q) {
 
                 if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true;
 
+                $scope.selectOnFocus = function($event) {
+                    if (!$scope.copy.empty_barcode)
+                        $event.target.select();
+                }
+
                 $scope.nextBarcode = function (i) {
                     $scope.focusNext(i, $scope.barcode);
                 }
-- 
2.11.0