Author: eallen
Date: 2008-10-20 15:00:15 -0400 (Mon, 20 Oct 2008)
New Revision: 2661
Modified:
mgmt/trunk/cumin/python/cumin/broker.py
mgmt/trunk/cumin/python/cumin/broker.strings
Log:
Changed more button to type="button" so it wouldn't submit when Enter is
pressed.
Added javascript to submit the form when the more button is clicked.
Modified: mgmt/trunk/cumin/python/cumin/broker.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/broker.py 2008-10-20 18:58:34 UTC (rev 2660)
+++ mgmt/trunk/cumin/python/cumin/broker.py 2008-10-20 19:00:15 UTC (rev 2661)
@@ -611,13 +611,20 @@
self.field_tmpl = Template(self, "field_html")
self.group_tmpl = Template(self, "group_html")
- self.more = self.MoreEntries(app, "more")
- self.add_child(self.more)
+ self.more_button = self.MoreEntries(app, "more_button")
+ self.add_child(self.more_button)
+
+ self.more = self.More(app, "more")
+ self.add_parameter(self.more)
class Errors(Attribute):
def get_default(self, session):
return dict()
+ class More(Parameter):
+ def get_default(self, session):
+ return ""
+
def process_display(self, session):
if self.more.get(session):
self.fields.set(session, self.fields.get(session) + 3)
@@ -681,6 +688,12 @@
if groups[index] and group.id == groups[index].id:
return "selected=\"selected\""
+ def render_more_id(self, session):
+ return self.more_button.path
+
+ def render_more_name(self, session):
+ return self.more.path
+
class MoreEntries(FormButton):
def render_content(self, session):
return "More Entries"
@@ -688,6 +701,9 @@
def render_class(self, session):
return "more"
+ def render_type(self, session):
+ return "button"
+
class BrokerSetAdd(BrokerSetForm):
def process_cancel(self, session):
branch = session.branch()
@@ -701,9 +717,10 @@
addrs = self.addrs.get(session)
names = self.names.get(session)
groups = self.groups.get(session)
-
+ fields = self.fields.get(session)
+
if self.validate(session, addrs, names, groups):
- for i in range(0, len(addrs)):
+ for i in range(0, fields):
addr = addrs[i]
if addr:
@@ -729,8 +746,9 @@
def validate(self, session, addrs, names, groups):
nerrs = self.name_errors.get(session)
aerrs = self.addr_errors.get(session)
+ fields = self.fields.get(session)
- for i in range(0, len(addrs)):
+ for i in range(0, fields):
addr, name = addrs[i], names[i]
if not addr and not name:
Modified: mgmt/trunk/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/broker.strings 2008-10-20 18:58:34 UTC (rev 2660)
+++ mgmt/trunk/cumin/python/cumin/broker.strings 2008-10-20 19:00:15 UTC (rev 2661)
@@ -206,7 +206,7 @@
{fields}
</table>
- {more}
+ {more_button}<input type="hidden" name="{more_name}"
value="" />
</fieldset>
{hidden_inputs}
@@ -219,13 +219,21 @@
</form>
<script type="text/javascript" defer="defer">
<![CDATA[
+function attach_more_id() {
+ var oMore = document.getElementById("{more_id}");
+ if (oMore) {
+ oMore.onclick = function() { document.forms[0].elements["{more_name}"].value
= "t"; document.forms[0].submit(); }
+ }
+}
(function() {
var elem = wooly.doc().elembyid("{id}").node.elements[1];
elem.focus();
elem.select();
}())
+addEvent(window, "load", attach_more_id);
]]>
</script>
+
[BrokerSetForm.field_html]
<tr>