LP#1841089 Apply button in Patron Bill History screen in a confusing location user/dbriem/lp1841089_bill_history_remove_apply_button
authorDan Briem <dbriem@wlsmail.org>
Sat, 24 Aug 2019 17:56:54 +0000 (13:56 -0400)
committerDan Briem <dbriem@wlsmail.org>
Sat, 24 Aug 2019 17:56:54 +0000 (13:56 -0400)
It's possible to miss the apply button for the date range in bill history
because it's located before the datepickers. The interface also allows
invalid date ranges.

This removes the apply button and watches the start and finish dates. If it's
not first init and they are valid date objects in a valid date range, the
grid refreshes with the new date range query. If start > finish they are set
equal to each other to force a valid range.

Signed-off-by: Dan Briem <dbriem@wlsmail.org>
Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index d9c4543..77cd4f9 100644 (file)
         <label>[% l('Selected Paid:') %]</label>
         <span>{{totals.selected_paid() | currency}}</span>
       </div>
-      <div class="col-md-1">
-        <span><button class="btn btn-default" 
-            ng-click="actions.apply_date_range()">[% l('Apply') %]</button></span>
-      </div>
       <div class="col-md-4 flex-row padded">
         <label>[% l('Start Date:') %]</label>
         <div><eg-date-input ng-model="dates.xact_start"></eg-date-input></div>
index 308fb30..1842c9e 100644 (file)
@@ -1010,6 +1010,25 @@ function($scope,  $q , egCore , patronSvc , billSvc , egPromptDialog , $location
         setQuery : current_grid_query
     }
 
+    $scope.$watch('dates.xact_start', function(new_date, old_date) {
+        if (new_date !== old_date && new_date) {
+            if (new_date.getTime() > $scope.dates.xact_finish.getTime()) {
+                $scope.dates.xact_finish = new_date;
+            } else {
+                $scope.actions.apply_date_range();
+            }
+        }
+    });
+    $scope.$watch('dates.xact_finish', function(new_date, old_date) {
+        if (new_date !== old_date && new_date) {
+            if (new_date.getTime() < $scope.dates.xact_start.getTime()) {
+                $scope.dates.xact_start = new_date;
+            } else {
+                $scope.actions.apply_date_range();
+            }
+        }
+    });
+
     $scope.actions.apply_date_range = function() {
         // tells the grid to re-draw itself with the new query
         $scope.gridControls.setQuery(current_grid_query());