From da4b0b9f3f90618eec2f02d641ae691497f9dd27 Mon Sep 17 00:00:00 2001 From: Josh Stompro Date: Mon, 10 Feb 2020 10:15:02 -0600 Subject: [PATCH] LP#1862235 - Create MARC Record - focus on item add and call number This change sets the focus on the "Add Item" checkbox when the marc editor is opened with fast item add enabled. This allows the user to just press space to enable Add item. When the add item checkbox is enabled, the focus is moved to the call number field. This adds a directive to app.js called focusOnShow that makes it easy to mark an element to have focus when it becomes visible when using ng-show. I had to add in a bit of redundancy in t_marcedit.tt2, the Add Item checkbox needs to have it's own ng-show directive for the focus-on-show to work. Signed-off-by: Josh Stompro --- .../src/templates/staff/cat/share/t_marcedit.tt2 | 4 ++-- .../web/js/ui/default/staff/cat/catalog/app.js | 27 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 index 5ba785945b..e52e7f1067 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 @@ -1,10 +1,10 @@
- +
- +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js index c3ecb1750d..ad7f57e1c2 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/catalog/app.js @@ -283,6 +283,33 @@ function($scope , $routeParams , $location , $window , $q , egCore) { }; }) +.directive('focusOnShow', function($timeout) { + return { + restrict: 'A', + link: function($scope, $element, $attr) { + if ($attr.ngShow){ + $scope.$watch($attr.ngShow, function(newValue){ + if(newValue){ + $timeout(function(){ + $element[0].focus(); + }, 0); + } + }) + } + if ($attr.ngHide){ + $scope.$watch($attr.ngHide, function(newValue){ + if(!newValue){ + $timeout(function(){ + $element[0].focus(); + }, 0); + } + }) + } + + } + }; +}) + .controller('CatalogCtrl', ['$scope','$routeParams','$location','$window','$q','egCore','egHolds','egCirc','egConfirmDialog','ngToast', 'egGridDataProvider','egHoldGridActions','egProgressDialog','$timeout','$uibModal','holdingsSvc','egUser','conjoinedSvc', -- 2.11.0