[rhmessaging-commits] rhmessaging commits: r2491 - mgmt/trunk/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Sep 17 14:07:44 EDT 2008


Author: eallen
Date: 2008-09-17 14:07:44 -0400 (Wed, 17 Sep 2008)
New Revision: 2491

Modified:
   mgmt/trunk/cumin/python/cumin/widgets.py
   mgmt/trunk/cumin/python/cumin/widgets.strings
Log:
Adding "orig" to EditableProperties to allow determining which values have changed

Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py	2008-09-17 16:07:31 UTC (rev 2490)
+++ mgmt/trunk/cumin/python/cumin/widgets.py	2008-09-17 18:07:44 UTC (rev 2491)
@@ -303,6 +303,7 @@
             ["path"] is required and should be the DictParameter path to prepend to the name
             ["error"] is optional and should be the error text to display for that item
             ["property"] is optional and should be a dictionary of item properties
+            ["orig"] is optional and should be the original value of the item before user edits
     """
     def __init__(self, widget, template_key):
         super(EditablePropertyRenderer, self).__init__(widget, template_key)
@@ -312,6 +313,7 @@
         self.__bigstring_template = Template(self, "bigstring_html")
         self.__number_template = Template(self, "number_html")
         self.__readonly_template = Template(self, "readonly_html")
+        self.__orig_template = Template(self, "orig_html")
 
     def render_title(self, session, item):
         title = item["name"]
@@ -353,10 +355,24 @@
     def render_ptype_name(self, session, item):
         return DictParameter.sep().join(
                 (item["path"], escape_entity(item["name"]), "type"))
-        
+
     def render_ptype_value(self, session, item):
         return item["type"]
         
+    def render_orig_value(self, session, item):
+        if "orig" in item:
+            writer = Writer()
+            self.__orig_template.render(writer, session, item)
+            return writer.to_string()
+        
+    def render_porig_name(self, session, item):
+        return DictParameter.sep().join(
+            (item["path"], escape_entity(item["name"]), "orig"))
+        
+    def render_porig_value(self, session, item):
+        value = item["orig"]
+        return escape_entity(str(value))
+        
     def render_val(self, session, item):
         value = self.get_val(session, item)
         return escape_entity(str(value))

Modified: mgmt/trunk/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.strings	2008-09-17 16:07:31 UTC (rev 2490)
+++ mgmt/trunk/cumin/python/cumin/widgets.strings	2008-09-17 18:07:44 UTC (rev 2491)
@@ -323,22 +323,29 @@
 <input class="edit_bool" id="{pname}.true" type="radio" name="{pname}" value="TRUE" {true_selected} /> <label for="{pname}.true">True</label>
 <input class="edit_bool" id="{pname}.false" type="radio" name="{pname}" value="FALSE" {false_selected} /> <label for="{pname}.false">False</label>
 <input type="hidden" name="{ptype_name}" value="{ptype_value}"/>
+{orig_value}
 
 [EditablePropertyRenderer.string_html]
 <input class="edit_string" type="text" name="{pname}" value="{val}" />
 <input type="hidden" name="{ptype_name}" value="{ptype_value}"/>
+{orig_value}
 
 [EditablePropertyRenderer.bigstring_html]
 <textarea class="edit_bigstring" name="{pname}" rows="4" cols="40">{val}</textarea>
 <input type="hidden" name="{ptype_name}" value="{ptype_value}"/>
+{orig_value}
 
 [EditablePropertyRenderer.number_html]
 <input class="{edit_number_class}" type="text" name="{pname}" value="{val}" />{error}
 <input type="hidden" name="{ptype_name}" value="{ptype_value}"/>
+{orig_value}
 
 [EditablePropertyRenderer.readonly_html]
 <span class="edit_readonly">{display_val}</span><input type="hidden" name="{ptype_name}" value="{ptype_value}"/><input type="hidden" name="{pname}" value="{val}"/>
 
+[EditablePropertyRenderer.orig_html]
+<input type="hidden" name="{porig_name}" value="{porig_value}"/>
+
 [StateSwitch.item_html]
 <li>{item_link}</li>
 




More information about the rhmessaging-commits mailing list