[open-ils-commits] r10662 - trunk/Open-ILS/xul/staff_client/chrome/content/util

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Sep 21 01:52:37 EDT 2008


Author: phasefx
Date: 2008-09-21 01:52:34 -0400 (Sun, 21 Sep 2008)
New Revision: 10662

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/widgets.js
Log:
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

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/widgets.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/widgets.js	2008-09-21 02:18:36 UTC (rev 10661)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/widgets.js	2008-09-21 05:52:34 UTC (rev 10662)
@@ -351,19 +351,31 @@
 			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);
 	}



More information about the open-ils-commits mailing list