serials: Locally remember values given for stream routing destinations
authorMike Rylander <mrylander@gmail.com>
Wed, 5 Jul 2017 19:34:48 +0000 (15:34 -0400)
committerMike Rylander <mrylander@gmail.com>
Wed, 5 Jul 2017 19:34:48 +0000 (15:34 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/templates/staff/serials/t_subscription_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/subscription_manager.js

index b761b08..d96a52d 100644 (file)
@@ -71,7 +71,7 @@
           <div class="col-sm-2"></div>
           <div class="col-sm-8">
             <label>[% l('Send to') %]</label>
-            <input class="form-control" type="text" ng-model="sstr.routing_label"></input>
+            <eg-basic-combo-box list="localStreamNames" on-select="dirtyForm" selected="sstr.routing_label"></eg-basic-combo-box>
           </div>
         </div>
       </div>
index 5fe4077..7bd1d98 100644 (file)
@@ -31,6 +31,12 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
     }
     reload();
 
+    $scope.localStreamNames = [];
+    egCore.hatch.getItem('eg.serials.stream_names')
+    .then(function(list) {
+        if (list) $scope.localStreamNames = list;
+    });
+
     $scope.distStreamGridControls = {
         activateItem : function (item) { } // TODO
     };
@@ -84,6 +90,17 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
         reload();
         form.$setPristine();
     }
+    function updateLocalStreamNames (new_name) {
+        if (new_name && $scope.localStreamNames.filter(function(x){ return x == new_name}).length == 0) {
+            $scope.localStreamNames.push(new_name);
+            egCore.hatch.setItem('eg.serials.stream_names', $scope.localStreamNames)
+        }
+    }
+
+    $scope.dirtyForm = function () {
+        $scope.ssubform.$dirty = true;
+    }
+
     $scope.save_subscriptions = function(form) {
         // traverse through structure and set _ischanged
         // TODO add more granular dirty input detection
@@ -93,6 +110,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                 if (!sdist._isnew) sdist._ischanged = true;
                 angular.forEach(sdist.streams, function(sstr) {
                     if (!sstr._isnew) sstr._ischanged = true;
+                    updateLocalStreamNames(sstr.routing_label);
                 });
             });
         });