webstaff: Apply date filter range on command in billing xact history
authorBill Erickson <berickxx@gmail.com>
Wed, 11 Feb 2015 15:54:22 +0000 (10:54 -0500)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:11 +0000 (13:39 -0400)
Adds an Apply button for apply changes to the date filter to the grid.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index 6739d7e..aef6084 100644 (file)
@@ -21,6 +21,7 @@
       <div>[% l('Selected Paid:') %]</div>
       <div>{{totals.selected_paid() | currency}}</div>
       <div class="flex-cell"></div>
+      <div><button class="btn btn-default" ng-click="actions.apply_date_range()">[% l('Apply') %]</button></div>
       <div>[% l('Start Date:') %]</div>
       <div><input eg-date-input class="form-control" ng-model="dates.xact_start"/></div>
       <div>[% l('End Date:') %]</div>
index 1d6f371..1546edc 100644 (file)
@@ -612,6 +612,9 @@ function($scope,  $q , $routeParams , egCore , patronSvc , billSvc , egPromptDia
     $scope.bill_tab = $routeParams.history_tab;
     $scope.totals = {};
 
+    // link page controller actions defined by sub-controllers here
+    $scope.actions = {};
+
     var start = new Date(); // now - 1 year
     start.setFullYear(start.getFullYear() - 1),
     $scope.dates = {
@@ -633,24 +636,31 @@ function($scope,  $q , $routeParams , egCore , patronSvc , billSvc , egPromptDia
        ['$scope','$q','egCore','patronSvc','billSvc','egPromptDialog','$location','egBilling',
 function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location , egBilling) {
 
+    // generate a grid query with the current date widget values.
+    function current_grid_query() {
+        return {
+            '-or' : [
+                {'summary.balance_owed' : {'<>' : 0}},
+                {'summary.last_payment_ts' : {'<>' : null}}
+            ],
+            xact_start : {between : $scope.date_range()},
+            usr : billSvc.userId
+        }
+    }
+
     $scope.gridControls = {
         selectedItems : function(){return []},
         activateItem : function(item) {
             $scope.showFullDetails([item]);
         },
-        setQuery : function() {
-            // open-ils.actor.user.transactions.history.have_bill_or_payment
-            return {
-                '-or' : [
-                    {'summary.balance_owed' : {'<>' : 0}},
-                    {'summary.last_payment_ts' : {'<>' : null}}
-                ],
-                xact_start : {between : $scope.date_range()},
-                usr : billSvc.userId
-            }
-        }
+        // this sets the query on page load
+        setQuery : current_grid_query
     }
 
+    $scope.actions.apply_date_range = function() {
+        // tells the grid to re-draw itself with the new query
+        $scope.gridControls.setQuery(current_grid_query());
+    }
 
     // TODO; move me to service
     function selected_payment_info() {