webstaff: improvements to creating prediction from pattern template
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 16 May 2017 19:42:02 +0000 (15:42 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 30 May 2017 16:06:45 +0000 (12:06 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_prediction_manager.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/prediction_manager.js

index 68e47d9..e2e403a 100644 (file)
@@ -7,7 +7,7 @@
     <button class="btn btn-warning" ng-click="startNewScap()">[% l('Add New') %]</button>
     <button class="btn btn-warning" ng-click="importScapFromBibRecord()">[% l('Import from Bibliographic and/or MFHD Records') %]</button>
     <button class="btn btn-warning" ng-click="importScapFromSpt()">[% l('Create from Template') %]</button>
-    <select ng-model="active_pattern_template.id" ng-options="spt as spt.name for spt in pattern_templates track by spt.id"> 
+    <select ng-model="active_pattern_template.id" ng-options="spt.id as spt.name for spt in pattern_templates | orderBy:'name'"> 
     </select>
   </div>
   <div class="row" ng-if="new_prediction">
index d0ed636..1a0b461 100644 (file)
@@ -11,9 +11,9 @@ angular.module('egSerialsAppDep')
         templateUrl: './serials/t_prediction_manager',
         controller:
        ['$scope','$q','egSerialsCoreSvc','egCore','egGridDataProvider',
-        '$uibModal',
+        '$uibModal','$timeout',
 function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
-                     $uibModal) {
+         $uibModal , $timeout) {
 
     egSerialsCoreSvc.fetch($scope.bibId).then(function() {
         reload($scope.ssubId);
@@ -99,6 +99,11 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
                 break;
             }
         }
+        // Mark form dirty because, when it's created from a template,
+        // it can be immediately saved if the user so chooses. The
+        // $timeout() allows this to happen after the form is bound
+        // is bound to $scope.new_prediction.
+        $timeout(function() { $scope.new_prediction.predform.$setDirty() });
     }
 
     $scope.openPatternEditorDialog = function(pred) {