From: phasefx Date: Fri, 11 Aug 2006 18:02:54 +0000 (+0000) Subject: column persistence X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=330d1772742e863e06c60d4b4773a7ca5a12b289;p=evergreen%2Fpines.git column persistence git-svn-id: svn://svn.open-ils.org/ILS/trunk@5473 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 fbe7536703..20820af61e 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -124,6 +124,8 @@ util.list.prototype = { slider.addEventListener('scroll',function(){alert('slider scroll');},false); */ this.node.addEventListener('scroll',function(){ obj.auto_retrieve(); },false); + + this.restores_columns(params); }, '_init_listbox' : function (params) { @@ -148,6 +150,87 @@ util.list.prototype = { } }, + 'save_columns' : function (params) { + var obj = this; + switch (this.node.nodeName) { + case 'tree' : this._save_columns_tree(params); break; + default: throw('NYI: Need .save_columns() for ' + this.node.nodeName); break; + } + }, + + '_save_columns_tree' : function (params) { + var obj = this; + try { + var id = obj.node.getAttribute('id'); if (!id) { + alert("FIXME: The columns for this list cannot be saved because the list has no id."); + return; + } + var my_cols = {}; + var nl = obj.node.getElementsByTagName('treecol'); + for (var i = 0; i < nl.length; i++) { + var col = nl[i]; + var col_id = col.getAttribute('id'); + if (!col_id) { + alert('FIXME: A column in this list does not have an id and cannot be saved'); + continue; + } + var col_hidden = col.getAttribute('hidden'); + var col_width = col.getAttribute('width'); + var col_ordinal = col.getAttribute('ordinal'); + my_cols[ col_id ] = { 'hidden' : col_hidden, 'width' : col_width, 'ordinal' : col_ordinal }; + } + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id)); + file.set_object(my_cols); + file.close(); + alert('Columns saved.'); + } catch(E) { + obj.error.standard_unexpected_error_alert('_save_columns_tree',E); + } + }, + + 'restores_columns' : function (params) { + var obj = this; + switch (this.node.nodeName) { + case 'tree' : this._restores_columns_tree(params); break; + default: throw('NYI: Need .restores_columns() for ' + this.node.nodeName); break; + } + }, + + '_restores_columns_tree' : function (params) { + var obj = this; + try { + var id = obj.node.getAttribute('id'); if (!id) { + alert("FIXME: The columns for this list cannot be restored because the list has no id."); + return; + } + + netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); + JSAN.use('util.file'); var file = new util.file('tree_columns_for_'+window.escape(id)); + if (file._file.exists()) { + var my_cols = file.get_object(); file.close(); + var nl = obj.node.getElementsByTagName('treecol'); + for (var i = 0; i < nl.length; i++) { + var col = nl[i]; + var col_id = col.getAttribute('id'); + if (!col_id) { + alert('FIXME: A column in this list does not have an id and cannot be saved'); + continue; + } + if (typeof my_cols[col_id] != 'undefined') { + col.setAttribute('hidden',my_cols[col_id].hidden); + col.setAttribute('width',my_cols[col_id].width); + col.setAttribute('ordinal',my_cols[col_id].ordinal); + } else { + alert('FIXME: Column ' + col_id + ' did not have a saved state.'); + } + } + } + } catch(E) { + obj.error.standard_unexpected_error_alert('_restore_columns_tree',E); + } + }, + 'clear' : function (params) { var obj = this; switch (this.node.nodeName) {