From 2c440e2190d0e8f5d2a5b172f77d41069838b4fb Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Mon, 12 Mar 2012 16:06:51 -0400 Subject: [PATCH] adds a Line# column to all xul lists displays the ordinal position of the row Signed-off-by: Jason Etheridge Signed-off-by: Bill Erickson Signed-off-by: Mike Rylander --- .../xul/staff_client/chrome/content/util/list.js | 56 ++++++++++++++++++++-- .../chrome/locale/en-US/offline.properties | 1 + Open-ILS/xul/staff_client/server/skin/global.css | 7 +++ 3 files changed, 60 insertions(+), 4 deletions(-) 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 1a270c81e3..6dcc3593c6 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -51,7 +51,23 @@ util.list.prototype = { if (typeof params.prebuilt != 'undefined') obj.prebuilt = params.prebuilt; if (typeof params.columns == 'undefined') throw('util.list.init: No columns'); - obj.columns = []; + obj.columns = [ + { + 'id' : 'lineno', + 'label' : document.getElementById('offlineStrings').getString('list.line_number'), + 'flex' : '0', + 'no_sort' : 'true', + 'properties' : 'ordinal', // column properties for css styling + 'hidden' : 'false', + 'editable' : false, + 'render' : function(my,scratch) { + // special code will handle this based on the attribute we set + // here. All cells for this column need to be updated whenever + // a list adds, removes, or sorts rows + return '_'; + } + } + ]; for (var i = 0; i < params.columns.length; i++) { if (typeof params.columns[i] == 'object') { obj.columns.push( params.columns[i] ); @@ -611,7 +627,7 @@ util.list.prototype = { } catch(E) { } - setTimeout( function() { obj.auto_retrieve(); }, 0 ); + setTimeout( function() { obj.auto_retrieve(); obj.refresh_ordinals(); }, 0 ); params.treeitem_node = treeitem; return params; @@ -773,7 +789,7 @@ util.list.prototype = { } catch(E) { } - setTimeout( function() { obj.auto_retrieve(); }, 0 ); + setTimeout( function() { obj.auto_retrieve(); obj.refresh_ordinals(); }, 0 ); JSAN.use('util.widgets'); util.widgets.dispatch('select',obj.node); @@ -782,6 +798,37 @@ util.list.prototype = { return params; }, + 'refresh_ordinals' : function() { + var obj = this; + try { + setTimeout( // Otherwise we can miss a row just added + function() { + var nl = document.getElementsByAttribute('label','_'); + for (var i = 0; i < nl.length; i++) { + nl[i].setAttribute( + 'ord_col', + 'true' + ); + nl[i].setAttribute( // treecell properties for css styling + 'properties', + 'ordinal' + ); + } + nl = document.getElementsByAttribute('ord_col','true'); + for (var i = 0; i < nl.length; i++) { + nl[i].setAttribute( + 'label', + // we could just use 'i' here if we trust the order of elements + 1 + obj.node.contentView.getIndexOfItem(nl[i].parentNode.parentNode) // treeitem + ); + } + }, 1000 + ); + } catch(E) { + alert('Error in list.js, refresh_ordinals(): ' + E); + } + }, + 'put_retrieving_label' : function(treerow) { var obj = this; try { @@ -1512,7 +1559,7 @@ util.list.prototype = { '_sort_tree' : function(col,sortDir) { var obj = this; try { - if (obj.node.getAttribute('no_sort')) { + if (obj.node.getAttribute('no_sort') || col.getAttribute('no_sort')) { return; } var col_pos; @@ -1592,6 +1639,7 @@ util.list.prototype = { } catch(E) { obj.error.standard_unexpected_error_alert('sorting',E); } + obj.refresh_ordinals(); } ); } catch(E) { diff --git a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties index eaef4909a4..71485fc991 100644 --- a/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties +++ b/Open-ILS/xul/staff_client/chrome/locale/en-US/offline.properties @@ -224,6 +224,7 @@ list.actions.csv_to_file.accesskey=F list.actions.save_column_configuration.label=Save Column Configuration list.actions.save_column_configuration.accesskey=S list.dump_extended_format.record_separator==-=-= +list.line_number=# menu.cmd_survey_wizard.inadequate_perm=You are lacking the CREATE_SURVEY permission and/or working locations. menu.cmd_local_admin_fonts_and_sounds.tab=Global Font and Sound Settings menu.cmd_local_admin_printer.tab=Printer Settings Editor diff --git a/Open-ILS/xul/staff_client/server/skin/global.css b/Open-ILS/xul/staff_client/server/skin/global.css index 1c9da3e3a8..ee08b6ce68 100644 --- a/Open-ILS/xul/staff_client/server/skin/global.css +++ b/Open-ILS/xul/staff_client/server/skin/global.css @@ -19,6 +19,13 @@ treechildren::-moz-tree-row(selected) { border: thin dashed lightblue ! important; } +treechildren::-moz-tree-column(ordinal) { + background: -moz-dialog ! important; +} + +treechildren::-moz-tree-cell-text(ordinal) { + font-weight: bold ! important; +} /* treechildren::-moz-tree-cell-text(selected,focus) { color: black; -- 2.11.0