From bc1da674ee28813f40256e0dd6465b5981d9e6c1 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 1 Oct 2012 16:46:56 -0400 Subject: [PATCH] more internal options for xul lists 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 --- Open-ILS/xul/staff_client/chrome/content/util/list.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index 9b37385d6c..e3da5a947b 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -2005,6 +2005,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'; } @@ -2110,6 +2111,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]) { @@ -2118,6 +2122,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; } @@ -2140,6 +2147,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); } -- 2.11.0