webstaff: implement prediction deletion action
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 21:44:06 +0000 (17:44 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 5 May 2017 21:44:06 +0000 (17:44 -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 cecf908..c0ad70d 100644 (file)
@@ -56,6 +56,7 @@
         <button class="btn btn-default" ng-click="openPatternEditorDialog(pred)">[% l('Edit Pattern') %]</button>
     </div>
     <div>
+        <button type="submit" class="btn btn-default" ng-click="deleteScap(pred)">[% l('Delete') %]</button>
         <button type="submit" class="btn btn-primary" ng-disabled="!pred.predform.$dirty" ng-click="updateScap(pred)">[% l('Save') %]</button>
     </div>
     </form>
index 02f735e..8066cbf 100644 (file)
@@ -51,6 +51,19 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider ,
             });
         });
     }
+    $scope.deleteScap = function(pred) {
+        var scap = egCore.idl.fromTypedHash(pred);
+        // TODO ask to confirm
+        // TODO check whether there are linked issuances
+        egCore.pcrud.remove(scap).then(function() {
+            // completely reset the model in order to reset the
+            // forms; causes a blink, alas
+            $scope.predictions = [];
+            egSerialsCoreSvc.fetch($scope.bibId).then(function() {
+                reload($scope.ssubId);
+            });
+        });
+    }
 
     $scope.startNewScap = function() {
         $scope.new_prediction = egCore.idl.toTypedHash(new egCore.idl.scap());