From b0bef283df9945874fc09237d8409e7f8d1635fe Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 5 Jun 2014 17:31:42 -0400 Subject: [PATCH] patron messages cont. Signed-off-by: Bill Erickson --- .../src/templates/staff/circ/patron/t_messages.tt2 | 10 +++- .../web/js/ui/default/staff/circ/patron/app.js | 53 ++++++++++++++++++---- Open-ILS/web/js/ui/default/staff/services/grid.js | 1 + 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 index 3a912929d4..71347e5465 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_messages.tt2 @@ -1,6 +1,7 @@ +
[% l('Staff-Generated Penalties / Messages') %]
+
+ +

+ +
[% l('Archived Penalties / Messages') %]
+
+ diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index fc748ab022..4d49211a27 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -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++; + }); + } + + }]) diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index e7101c2101..82f5a303f0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -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 -- 2.11.0