[reledit] onsubmit event is not common to both cases, move from class stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Wed, 08 Jul 2009 17:22:24 +0200
branchstable
changeset 2327 2aa28ac13d64
parent 2326 05ae71d9a069
child 2328 206735882b8e
[reledit] onsubmit event is not common to both cases, move from class
web/views/editforms.py
--- a/web/views/editforms.py	Wed Jul 08 10:45:31 2009 +0200
+++ b/web/views/editforms.py	Wed Jul 08 17:22:24 2009 +0200
@@ -90,8 +90,6 @@
 
     # FIXME editableField class could be toggleable from userprefs
 
-    onsubmit = ("return inlineValidateAttributeForm('%(divid)s-form', '%(rtype)s', "
-                "'%(eid)s', '%(divid)s', %(reload)s, '%(default)s');")
     ondblclick = "showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
 
     def cell_call(self, row, col, rtype=None, role='subject', reload=False,
@@ -136,7 +134,6 @@
         self.w(form.form_render(renderer=renderer))
 
     def _build_relation_form(self, entity, value, rtype, role, row, col, vid, default):
-        entity = self.entity(row, col)
         divid = 'd%s' % make_uid('%s-%s' % (rtype, entity.eid))
         event_data = {'divid' : divid, 'eid' : entity.eid, 'rtype' : rtype, 'vid' : vid,
                       'default' : default, 'role' : role}
@@ -163,6 +160,8 @@
         divid = 'd%s' % make_uid('%s-%s' % (rtype, eid))
         event_data = {'divid' : divid, 'eid' : eid, 'rtype' : rtype,
                       'reload' : dumps(reload), 'default' : default}
+        onsubmit = ("return inlineValidateAttributeForm('%(divid)s-form', '%(rtype)s', "
+                    "'%(eid)s', '%(divid)s', %(reload)s, '%(default)s');")
         buttons = [SubmitButton(stdmsgs.BUTTON_OK),
                    Button(stdmsgs.BUTTON_CANCEL,
                           onclick="cancelInlineEdit(%s,\'%s\',\'%s\')" % (
@@ -171,7 +170,7 @@
                                        row=row, col=col, form_buttons=buttons,
                                        domid='%s-form' % divid, action='#',
                                        cssstyle='display: none',
-                                       onsubmit=self.onsubmit % event_data)
+                                       onsubmit=onsubmit % event_data)
         self.w(tags.div(value, klass='editableField', id=divid,
                         ondblclick=self.ondblclick % event_data))
         return form