[open-ils-commits] r17578 - trunk/Open-ILS/xul/staff_client/chrome/content/util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Sep 10 12:35:48 EDT 2010


Author: phasefx
Date: 2010-09-10 12:35:45 -0400 (Fri, 10 Sep 2010)
New Revision: 17578

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
Log:
Give the ability to duplicate column definitions by prefixing their id's.  Allow the specification of alternate row objects and datafields to render from.  The idea is to let us do such things as list address columns for a patron twice, once for the billing address and again for the mailing address.

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-09-10 16:35:40 UTC (rev 17577)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-09-10 16:35:45 UTC (rev 17578)
@@ -1690,9 +1690,10 @@
     },
 
     // Takes fieldmapper class name and attempts to spit out column definitions suitable for .init
-    'fm_columns' : function(hint,column_extras) {
+    'fm_columns' : function(hint,column_extras,prefix) {
         var obj = this;
         var columns = [];
+        if (!prefix) { prefix = ''; }
         try {
             // requires the dojo library fieldmapper.autoIDL
             if (typeof fieldmapper == 'undefined') { throw 'fieldmapper undefined'; }
@@ -1703,7 +1704,19 @@
             var data = obj.data; data.stash_retrieve();
 
             function col_def(my_field) {
-                var col_id = hint + '_' + my_field.name;
+                var col_id = prefix + hint + '_' + my_field.name;
+                var dataobj = hint;
+                var datafield = my_field.name;
+                if (column_extras) {
+                    if (column_extras[col_id]) {
+                        if (column_extras[col_id]['dataobj']) {
+                            dataobj = column_extras[col_id]['dataobj'];
+                        }
+                        if (column_extras[col_id]['datafield']) {
+                            datafield = column_extras[col_id]['datafield'];
+                        }
+                    }
+                }
                 var def = {
                     'id' : col_id,
                     'label' : my_field.label || my_field.name,
@@ -1716,26 +1729,26 @@
                 // my_field.datatype => bool float id int interval link money number org_unit text timestamp
                 if (my_field.datatype == 'link') {
                     def.render = function(my) { 
-                        return typeof my[hint][my_field.name]() == 'object' ? my[hint][my_field.name]()[my_field.key]() : my[hint][my_field.name](); 
+                        return typeof my[dataobj][datafield]() == 'object' ? my[dataobj][datafield]()[my_field.key]() : my[dataobj][datafield](); 
                     }
                 } else {
-                    def.render = function(my) { return my[hint][my_field.name](); }
+                    def.render = function(my) { return my[dataobj][datafield](); }
                 }
                 if (my_field.datatype == 'timestamp') {
                     JSAN.use('util.date');
                     def.render = function(my) {
-                        return util.date.formatted_date( my[hint][my_field.name](), '%{localized}' );
+                        return util.date.formatted_date( my[dataobj][datafield](), '%{localized}' );
                     }
                 }
                 if (my_field.datatype == 'org_unit') {
                     def.render = function(my) {
-                        return typeof my[hint][my_field.name]() == 'object' ? my[hint][my_field.name]().shortname() : data.hash.aou[ my[hint][my_field.name]() ].shortname();
+                        return typeof my[dataobj][datafield]() == 'object' ? my[dataobj][datafield]().shortname() : data.hash.aou[ my[dataobj][datafield]() ].shortname();
                     }
                 }
                 if (my_field.datatype == 'money') {
                     JSAN.use('util.money');
                     def.render = function(my) {
-                        return util.money.sanitize( my[hint][my_field.name]() );
+                        return util.money.sanitize( my[dataobj][datafield]() );
                     }
                 }
                 if (column_extras) {



More information about the open-ils-commits mailing list