LP#1862235 - Create MARC Record - Focus on template on load
authorJosh Stompro <stompro@stompro.org>
Mon, 10 Feb 2020 14:35:31 +0000 (08:35 -0600)
committerJosh Stompro <stompro@stompro.org>
Mon, 10 Feb 2020 14:35:31 +0000 (08:35 -0600)
Focus on the template selector dropdown when interface loads.

This removes the need to use the mouse, and speeds up using the
interface.  Pressing tab, then enter will submit
the form with the default template selected.

If the template needs to be changed, then pressing the first letter
of the template will switch between the different options.

This adds a directive named autoFocus to staff/cat/catalog/app.js,
so adding "auto-focus" to an element will cause that element
to have focus on load.

Signed-off-by: Josh Stompro <stompro@stompro.org>
Open-ILS/src/templates/staff/cat/catalog/t_new_bib.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

index c5ffa77..e183b7e 100644 (file)
@@ -2,7 +2,7 @@
     <div class="col-xs-6">
         <div class="form-group">
             <label for="select-marc-template" class="control-label">[% l('Select MARC template') %]</label>
-            <select id="select-marc-template" class="form-control" ng-model="template_name" ng-options="name as name for name in template_list"></select>
+            <select id="select-marc-template" class="form-control" ng-model="template_name" ng-options="name as name for name in template_list" auto-focus></select>
         </div>
         <button class="btn btn-primary" ng-click="loadTemplate()">[% l('Load') %]</button>
         <button class="btn btn-default" ng-click="setDefaultTemplate()">[% l('Set Workstation Default') %]</button>
index f05c363..ee99fca 100644 (file)
@@ -269,6 +269,18 @@ function($scope , $routeParams , $location , $window , $q , egCore) {
     
 
 }])
+
+.directive('autoFocus', function($timeout) {
+    return {
+        restrict: 'AC',
+        link: function(_scope, _element) {
+            $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',