patron messages cont.
authorBill Erickson <berick@esilibrary.com>
Thu, 5 Jun 2014 21:31:42 +0000 (17:31 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 5 Jun 2014 21:31:42 +0000 (17:31 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_messages.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/app.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 3a91292..71347e5 100644 (file)
@@ -1,6 +1,7 @@
 
+<div class="strong-text-2">[% l('Staff-Generated Penalties / Messages') %]</div>
+<div class="pad-vert"></div>
 <eg-grid
-  label="[% l('Staff-Generated Penalties / Messages') %]"
   idl-class="ausp"
   query="activeQuery"
   sort="activeSort"
   <eg-grid-field path="standing_penalty.label"></eg-grid-field>
   <eg-grid-field path="org_unit.shortname" label="[% l('Library') %]"></eg-grid-field>
   <eg-grid-field path="note"></eg-grid-field>
+  <eg-grid-field path="id" required hidden></eg-grid-field>
   <eg-grid-field path="standing_penalty.block_list" required hidden></eg-grid-field>
   <eg-grid-field path="standing_penalty.*" hidden></eg-grid-field>
 
 </eg-grid>
 
+<div class="pad-vert"><hr/></div>
+
+<div class="strong-text-2">[% l('Archived Penalties / Messages') %]</div>
+<div class="pad-vert"></div>
 <eg-grid
-  label="[% l('Archived Penalties / Messages') %]"
   idl-class="ausp"
   query="archiveQuery"
   sort="archiveSort"
@@ -36,6 +41,7 @@
   <eg-grid-field path="standing_penalty.label"></eg-grid-field>
   <eg-grid-field path="org_unit.shortname" label="[% l('Library') %]"></eg-grid-field>
   <eg-grid-field path="note"></eg-grid-field>
+  <eg-grid-field path="id" required hidden></eg-grid-field>
   <eg-grid-field path="standing_penalty.block_list" required hidden></eg-grid-field>
   <eg-grid-field path="standing_penalty.*" hidden></eg-grid-field>
 
index fc748ab..4d49211 100644 (file)
@@ -735,6 +735,8 @@ function($scope,  $routeParams,  egCore) {
     $scope.initTab('messages', $routeParams.id);
     var usr_id = $routeParams.id;
 
+    $scope.activeRevision = 0;
+    $scope.activeSort = ['set_date'];
     $scope.activeQuery = function() {
         return {
             usr : usr_id,
@@ -744,18 +746,12 @@ function($scope,  $routeParams,  egCore) {
             ]
         }
     };
-    $scope.activeSort = ['set_date'];
-    $scope.activeRevision = 0;
 
+    $scope.archiveRevision = 0;
+    $scope.archiveSort = ['set_date'];
     $scope.archiveQuery = function() {
-        return {
-            usr : usr_id,
-            stop_date : {'<=' : 'now'}
-        }
+        return {usr : usr_id, stop_date : {'<=' : 'now'}}
     };
-    $scope.archiveSort = ['set_date'];
-    $scope.archiveRevision = 0;
-
 
     var start = new Date(); // now - 1 year
     start.setFullYear(start.getFullYear() - 1),
@@ -772,6 +768,45 @@ function($scope,  $routeParams,  egCore) {
         return [start, end];
     }
 
+    $scope.removePenalty = function(selected) {
+        // the grid stores flattened penalties.  Fetch penalty objects first
+
+        var ids = selected.map(function(s){ return s.id });
+        egCore.pcrud.search('ausp', 
+            {id : ids}, {}, 
+            {atomic : true, authoritative : true}
+
+        // then delete them
+        ).then(function(penalties) {
+            return egCore.pcrud.remove(penalties);
+
+        // then refresh the grid
+        }).then(function() {
+            $scope.activeRevision++; 
+        });
+    }
+
+    $scope.archivePenalty = function(selected) {
+        // the grid stores flattened penalties.  Fetch penalty objects first
+
+        var ids = selected.map(function(s){ return s.id });
+        egCore.pcrud.search('ausp', 
+            {id : ids}, {}, 
+            {atomic : true, authoritative : true}
+
+        // then delete them
+        ).then(function(penalties) {
+            angular.forEach(penalties, function(p){ p.stop_date('now') });
+            return egCore.pcrud.update(penalties);
+
+        // then refresh the grid
+        }).then(function() {
+            $scope.activeRevision++; 
+            $scope.archiveRevision++; 
+        });
+    }
+
+
 }])
 
 
index e7101c2..82f5a30 100644 (file)
@@ -207,6 +207,7 @@ angular.module('egGridMod',
 
                     grid.selfManagedData = true;
                     grid.dataProvider = egGridFlatDataProvider.instance({
+                        indexField : grid.indexField,
                         idlClass : grid.idlClass,
                         columnsProvider : grid.columnsProvider,
                         query : $scope.query