From a5efef24fe8b1ce9d7586451f275594b8191553b Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 26 Sep 2007 17:18:22 +0000 Subject: [PATCH] sticky prefs for stat cat library filter in item editor.. not finished, just commiting for convenience git-svn-id: svn://svn.open-ils.org/ILS/trunk@7837 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/widgets.js | 2 ++ Open-ILS/xul/staff_client/server/cat/copy_editor.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js index 57f9e7a436..de9c1690fd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js @@ -347,7 +347,9 @@ util.widgets.load_attributes = function (file) { document.getElementById( element_id ).setAttribute(attribute, blob[ element_id ][ attribute ]); } } + return blob; } + return {}; } catch(E) { alert('Error loading preferences: ' + E); } diff --git a/Open-ILS/xul/staff_client/server/cat/copy_editor.js b/Open-ILS/xul/staff_client/server/cat/copy_editor.js index 96eb6c1da3..ae4107ceff 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_editor.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_editor.js @@ -966,6 +966,7 @@ g.render = function() { JSAN.use('util.widgets'); util.widgets.remove_children(x); for (var i = 0; i < sc_libs2.length; i++) { var menuitem = document.createElement('menuitem'); + menuitem.setAttribute('id','filter_'+sc_libs2[i][1]); menuitem.setAttribute('type','checkbox'); menuitem.setAttribute('checked','true'); menuitem.setAttribute('label',sc_libs2[i][0]); @@ -974,6 +975,17 @@ g.render = function() { x.appendChild(menuitem); } + JSAN.use('util.file'); + var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned); + g.copy_editor_prefs = util.widgets.load_attributes(file); + for (var i in g.copy_editor_prefs) { + if (i.match(/filter_/) && g.copy_editor_prefs[i].checked == '') { + try { + g.toggle_stat_cat_display( document.getElementById(i) ); + } catch(E) { alert(E); } + } + } + /******************************************************************************************************/ /* Prepare the panes */ @@ -1197,6 +1209,14 @@ g.toggle_stat_cat_display = function(el) { nl[n].setAttribute('hidden','true'); } } + g.copy_editor_prefs[ el.getAttribute('id') ] = { 'checked' : visible }; + JSAN.use('util.widgets'); JSAN.use('util.file'); var file = new util.file('copy_editor_prefs.'+g.data.server_unadorned); + var what_to_save = {}; + for (var i in g.copy_editor_prefs) { + what_to_save[i] = []; + for (var j in g.copy_editor_prefs[i]) what_to_save[i].push(j); + } + util.widgets.save_attributes(file, what_to_save ); } /******************************************************************************************************/ -- 2.11.0