LP#1705524: Use the new grid configuration for date format in the bills list
authorMike Rylander <mrylander@gmail.com>
Thu, 20 Jul 2017 21:52:38 +0000 (17:52 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 11 Aug 2017 18:17:54 +0000 (14:17 -0400)
The bills list in the patron interface predated any grid date formatting, so
we bring it into the modern world.

This also enhances the grid autoformatting for dates to support both flattened
and dot-pathed item layout.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Tina Ji <tji@sitka.bclibraries.ca>
Open-ILS/src/templates/staff/circ/patron/t_bills_list.tt2
Open-ILS/web/js/ui/default/staff/services/grid.js

index 3d4863c..840b83d 100644 (file)
     path='grocery.billing_location.shortname' required hidden> </eg-grid-field>
   <eg-grid-field path='circulation.circ_lib' required hidden></eg-grid-field>
   <eg-grid-field path='circulation.duration' required hidden></eg-grid-field>
     path='grocery.billing_location.shortname' required hidden> </eg-grid-field>
   <eg-grid-field path='circulation.circ_lib' required hidden></eg-grid-field>
   <eg-grid-field path='circulation.duration' required hidden></eg-grid-field>
-  <eg-grid-field path='circulation.due_date' required hidden>
-    {{ circulation.due_date | egDueDate:$root.egDateAndTimeFormat:circulation.circ_lib:circulation.duration}}
-  </eg-grid-field>
+  <eg-grid-field path='circulation.due_date' dateonlyinterval="circulation.duration" datecontext="circulation.circ_lib" required hidden></eg-grid-field>
   <eg-grid-field path='circulation.*' hidden> </eg-grid-field>
   <eg-grid-field label="[% l('Checkout / Renewal Library') %]"
     path='circulation.circ_lib.shortname' required hidden> </eg-grid-field>
   <eg-grid-field path='circulation.*' hidden> </eg-grid-field>
   <eg-grid-field label="[% l('Checkout / Renewal Library') %]"
     path='circulation.circ_lib.shortname' required hidden> </eg-grid-field>
index 41e2d98..27344c0 100644 (file)
@@ -1936,6 +1936,15 @@ angular.module('egGridMod',
  * Others likely to follow...
  */
 .filter('egGridValueFilter', ['$filter','egCore', function($filter,egCore) {
  * Others likely to follow...
  */
 .filter('egGridValueFilter', ['$filter','egCore', function($filter,egCore) {
+    function traversePath(obj,path) {
+        var list = path.split('.');
+        for (var part in path) {
+            if (obj[path]) obj = obj[path]
+            else return undef;
+        }
+        return obj;
+    }
+
     var GVF = function(value, column, item) {
         switch(column.datatype) {
             case 'bool':
     var GVF = function(value, column, item) {
         switch(column.datatype) {
             case 'bool':
@@ -1957,10 +1966,16 @@ angular.module('egGridMod',
                     ? item[column.dateonlyinterval]()
                     : item[column.dateonlyinterval];
 
                     ? item[column.dateonlyinterval]()
                     : item[column.dateonlyinterval];
 
+                if (column.dateonlyinterval && !interval) // try it as a dotted path
+                    interval = traversePath(item, column.dateonlyinterval);
+
                 var context = angular.isFunction(item[column.datecontext])
                     ? item[column.datecontext]()
                     : item[column.datecontext];
 
                 var context = angular.isFunction(item[column.datecontext])
                     ? item[column.datecontext]()
                     : item[column.datecontext];
 
+                if (column.datecontext && !context) // try it as a dotted path
+                    context = traversePath(item, column.datecontext);
+
                 var date_filter = column.datefilter || 'egOrgDateInContext';
 
                 return $filter(date_filter)(value, column.dateformat, context, interval);
                 var date_filter = column.datefilter || 'egOrgDateInContext';
 
                 return $filter(date_filter)(value, column.dateformat, context, interval);