+<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"
<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>
$scope.initTab('messages', $routeParams.id);
var usr_id = $routeParams.id;
+ $scope.activeRevision = 0;
+ $scope.activeSort = ['set_date'];
$scope.activeQuery = function() {
return {
usr : usr_id,
]
}
};
- $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),
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++;
+ });
+ }
+
+
}])