From 0889df4dd70a8df0f5ce6bab0b7005673b340df3 Mon Sep 17 00:00:00 2001 From: phasefx Date: Sun, 21 Sep 2008 05:52:34 +0000 Subject: [PATCH] the util.widgets.load/save_attributes is an attempt at rolling our own 'persist' for elements. For menulists, we shouldn't force a value that doesn't actually exist as a menuitem git-svn-id: svn://svn.open-ils.org/ILS/trunk@10662 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../chrome/content/util/widgets.js | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) 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 29cf4f29f0..259add0084 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/widgets.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/widgets.js @@ -351,19 +351,31 @@ util.widgets.load_attributes = function (file) { for (var element_id in blob) { for (var attribute in blob[ element_id ]) { var x = document.getElementById( element_id ); - if (x) { - x.setAttribute(attribute, blob[ element_id ][ attribute ]); - } else { - dump('Error in util.widgets.load_attributes('+file._file.path+'):\n'); - dump('\telement_id = ' + element_id + '\n'); - dump('\tattribute = ' + attribute + '\n'); - dump('\tblob[id][attr] = ' + blob[element_id][attribute] + '\n'); - } + if (x) { + if (x.nodeName == 'menulist' && attribute == 'value') { + var popup = x.firstChild; + var children = popup.childNodes; + for (var i = 0; i < children.length; i++) { + if (children[i].getAttribute('value') == blob[ element_id ][ attribute ]) { + dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n' ); + x.setAttribute(attribute, blob[ element_id ][ attribute ]); + } + } + } else { + dump('setting ' + x.nodeName + ' ' + element_id + ' @value to ' + blob[ element_id ][ attribute ] + '\n'); + x.setAttribute(attribute, blob[ element_id ][ attribute ]); + } + } else { + dump('Error in util.widgets.load_attributes('+file._file.path+'):\n'); + dump('\telement_id = ' + element_id + '\n'); + dump('\tattribute = ' + attribute + '\n'); + dump('\tblob[id][attr] = ' + blob[element_id][attribute] + '\n'); + } } } - return blob; + return blob; } - return {}; + return {}; } catch(E) { alert('Error loading preferences: ' + E); } -- 2.43.2