webstaff: improve focus management of subscription manager
authorGalen Charlton <gmc@equinoxinitiative.org>
Thu, 6 Jul 2017 21:14:36 +0000 (17:14 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Thu, 6 Jul 2017 21:15:18 +0000 (17:15 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js

index 3743d16..8f61045 100644 (file)
@@ -12,7 +12,7 @@
             <label class="pull-right">[% l('Start Date') %]</label>
           </div>
           <div class="form-group col-lg-6">
-            <div class="pull-left"><eg-date-input ng-model="ssub.start_date"></eg-date-input></div>
+            <div class="pull-left"><eg-date-input ng-model="ssub.start_date" focus-me="ssub._focus_me"></eg-date-input></div>
           </div>
         </div>
       </div>
@@ -33,7 +33,7 @@
         <input class="form-control" type="text" ng-model="ssub.expected_date_offset"></input>
       </div>
       <div class="form-group col-sm-1">
-        <button class="btn btn-sm btn-warning" ng-click="add_distribution(ssub)">[% l('Add distribution') %]</button>
+        <button class="btn btn-sm btn-warning" ng-click="add_distribution(ssub, true)">[% l('Add distribution') %]</button>
       </div>
     </div>
     <div class="row form-inline pad-vert" ng-repeat="sdist in ssub.distributions">
@@ -49,7 +49,7 @@
         </div>
         <div class="col-sm-3">
           <label>[% l('Label') %]</label>
-          <input class="form-control" type="text" required ng-model="sdist.label"></input>
+          <input class="form-control" type="text" required ng-model="sdist.label" focus-me="sdist._focus_me"></input>
         </div>
         <div class="col-sm-2">
           <label>[% l('OPAC Display') %]
@@ -68,7 +68,7 @@
           </select>
         </div>
         <div class="col-sm-1" style="padding-left:0"><!-- Yes, it's terrible. But, nested grid alignment... -->
-          <button class="btn btn-sm btn-info" ng-click="add_stream(sdist)">[% l('Add copy stream') %]</button>
+          <button class="btn btn-sm btn-info" ng-click="add_stream(sdist, true)">[% l('Add copy stream') %]</button>
         </div>
       </div>
       <div class="row form-inline pad-vert">
@@ -81,7 +81,7 @@
           </div>
           <div class="col-sm-8">
             <label>[% l('Send to') %]</label>
-            <eg-basic-combo-box list="localStreamNames" on-select="dirtyForm" selected="sstr.routing_label"></eg-basic-combo-box>
+            <eg-basic-combo-box list="localStreamNames" on-select="dirtyForm" selected="sstr.routing_label" focus-me="sstr._focus_me"></eg-basic-combo-box>
           </div>
         </div>
       </div>
index 8756bc7..9f0d049 100644 (file)
@@ -63,16 +63,21 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
         var new_ssub = egCore.idl.toTypedHash(new egCore.idl.ssub());
         new_ssub._isnew = true;
         new_ssub.record_entry = $scope.bibId;
+        new_ssub._focus_me = true;
         $scope.subscriptions.push(new_ssub);
         $scope.add_distribution(new_ssub); // since we know we want at least one distribution
     }
-    $scope.add_distribution = function(ssub) {
+    $scope.add_distribution = function(ssub, grab_focus) {
         var new_sdist = egCore.idl.toTypedHash(new egCore.idl.sdist());
         new_sdist._isnew = true;
         new_sdist.subscription = ssub.id;
         if (!angular.isArray(ssub.distributions)){
             ssub.distributions = [];
         }
+        if (grab_focus) {
+            new_sdist._focus_me = true;
+            ssub._focus_me = false;
+        }
         ssub.distributions.push(new_sdist);
         $scope.add_stream(new_sdist); // since we know we want at least one stream
     }
@@ -88,10 +93,14 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
             ssub.distributions.splice(to_remove, 1);
         }
     }
-    $scope.add_stream = function(sdist) {
+    $scope.add_stream = function(sdist, grab_focus) {
         var new_sstr = egCore.idl.toTypedHash(new egCore.idl.sstr());
         new_sstr.distribution = sdist.id;
         new_sstr._isnew = true;
+        if (grab_focus) {
+            new_sstr._focus_me = true;
+            sdist._has_focus = false; // and take focus away from a newly created sdist
+        }
         if (!angular.isArray(sdist.streams)){
             sdist.streams = [];
         }