Author: eallen
Date: 2008-10-03 14:52:27 -0400 (Fri, 03 Oct 2008)
New Revision: 2592
Modified:
mgmt/trunk/cumin/python/cumin/widgets.py
Log:
Fixup CheckboxStringIdColumn for FormInput
Modified: mgmt/trunk/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-03 18:39:44 UTC (rev 2591)
+++ mgmt/trunk/cumin/python/cumin/widgets.py 2008-10-03 18:52:27 UTC (rev 2592)
@@ -779,6 +779,30 @@
return t % (name, id, attr, disa)
+class CheckboxStringIdColumn(FormInput, SqlTableColumn):
+ def __init__(self, app, name):
+ super(CheckboxStringIdColumn, self).__init__(app, name, None)
+
+ self.header_class = CheckboxIdColumnHeader
+
+ param = Parameter(app, "param")
+ self.add_parameter(param)
+
+ self.param = ListParameter(app, "id", param)
+ self.add_parameter(self.param)
+
+ def clear(self, session):
+ self.param.set(session, list())
+
+ def do_render(self, session, data, disabled=False):
+ name = self.param.path
+ id = data[self.name]
+ attr = id in self.param.get(session) and
"checked=\"checked\"" or ""
+ disa = disabled and "disabled=\"disabled\"" or ""
+ t = "<td><input type=\"checkbox\" name=\"%s\"
value=\"%s\" %s %s/></td>"
+
+ return t % (name, id, attr, disa)
+
class CheckboxIdColumnHeader(ItemTableColumnHeader):
def render_form_id(self, session, *args):
return self.column.form.path
@@ -798,34 +822,6 @@
return super(FilteredCheckboxIdColumn, self).do_render(session, data,
disabled=disabled)
-class CheckboxStringIdColumn(SqlTableColumn):
- def __init__(self, app, name):
- super(CheckboxStringIdColumn, self).__init__(app, name)
-
- self.header_class = CheckboxIdColumnHeader
-
- param = Parameter(app, "param")
- self.add_parameter(param)
-
- self.ids = ListParameter(app, "id", param)
- self.add_parameter(self.ids)
-
- def get(self, session):
- return self.ids.get(session)
-
- def clear(self, session):
- self.ids.set(session, list())
-
- def do_render(self, session, data, disabled=False):
- name = self.ids.path
- id = data[self.name]
- attr = id in self.ids.get(session) and "checked=\"checked\""
or ""
- disa = disabled and "disabled=\"disabled\"" or ""
- t = "<td><input type=\"checkbox\" name=\"%s\"
value=\"%s\" %s %s/></td>"
-
- return t % (name, id, attr, disa)
-
-
class NameField(StringField):
def __init__(self, app, name):
super(NameField, self).__init__(app, name)