LP#1010027: more internal options for xul lists
authorJason Etheridge <jason@esilibrary.com>
Mon, 1 Oct 2012 20:46:56 +0000 (16:46 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 27 Aug 2014 05:01:24 +0000 (01:01 -0400)
specifically, give fm_columns a sort_headers flag for alphabetizing the columns
returned by label; and delete_me flag for omitting a column definition entirely

Not all xul lists are using fm_columns yet

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Signed-off-by: Jennifer Pringle <jpringle@sitka.bclibraries.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/xul/staff_client/chrome/content/util/list.js

index 0eba98b..f9a962f 100644 (file)
@@ -2059,6 +2059,7 @@ util.list.prototype = {
         var obj = this;
         var columns = [];
         if (!prefix) { prefix = ''; }
+        var sort_headers = false;
         try {
             // requires the dojo library fieldmapper.autoIDL
             if (typeof fieldmapper == 'undefined') { throw 'fieldmapper undefined'; }
@@ -2164,6 +2165,9 @@ util.list.prototype = {
                                 def.remove_me = true;
                             }
                         }
+                        if (column_extras['*']['sort_headers']) {
+                            sort_headers = true;
+                        }
                     }
                     if (column_extras[col_id]) {
                         for (var attr in column_extras[col_id]) {
@@ -2172,6 +2176,9 @@ util.list.prototype = {
                         if (column_extras[col_id]['keep_me']) {
                             def.remove_me = false;
                         }
+                        if (column_extras[col_id]['remove_me']) {
+                            def.remove_me = true;
+                        }
                         if (column_extras[col_id]['label_prefix']) {
                             def.label = column_extras[col_id]['label_prefix'] + def.label;
                         }
@@ -2194,6 +2201,16 @@ util.list.prototype = {
                 }
             }
 
+            if (sort_headers) {
+                columns.sort(
+                    function(a,b) {
+                        if (a.label > b.label) { return 1; }
+                        if (a.label < b.label) { return -1; }
+                        return 0;
+                    }
+                );
+            }
+
         } catch(E) {
             obj.error.standard_unexpected_error_alert('fm_columns()',E);
         }