[reledit] allow composite edition if the composite is object stable
authorAurelien Campeas <aurelien.campeas@logilab.fr>
Thu, 09 Jul 2009 19:59:41 +0200
branchstable
changeset 2365 9f5e911eab07
parent 2364 fa16d36d60cb
child 2366 e4229723b824
[reledit] allow composite edition if the composite is object
web/views/editforms.py
--- a/web/views/editforms.py	Thu Jul 09 19:40:45 2009 +0200
+++ b/web/views/editforms.py	Thu Jul 09 19:59:41 2009 +0200
@@ -90,8 +90,8 @@
 
     # FIXME editableField class could be toggleable from userprefs
 
-    _onclick = "showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
-    _defaultlandingzone = u'<img title="%s" src="data/file.gif"/>'
+    _onclick = u"showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
+    _defaultlandingzone = u'<img title="%(msg)s" src="data/file.gif" alt="%(msg)s"/>'
     _landingzonemsg = _('click to edit this field')
     # default relation vids according to cardinality
     _one_rvid = 'incontext'
@@ -138,8 +138,8 @@
                                                            toeid=entity.eid):
                 return self.w(value)
             elif get_schema_property(entity.e_schema,
-                                   entity.schema.rschema(rtype),
-                                   role, 'composite'):
+                                     entity.schema.rschema(rtype),
+                                     role, 'composite') == role:
                 return self.w(value)
             form = self._build_relation_form(entity, value, rtype, role, reload, row, col,
                                              rvid, default, landing_zone)
@@ -151,9 +151,12 @@
                                       display_progress_div=False)
         self.w(form.form_render(renderer=renderer))
 
+    def _build_landing_zone(self, lzone):
+        return lzone or self._defaultlandingzone % {'msg' : self.req._(self._landingzonemsg)}
+
     def _build_relation_form(self, entity, value, rtype, role, row, col, reload, rvid,
                              default, lzone):
-        lzone = lzone or self._defaultlandingzone % self.req._(self._landingzonemsg)
+        lzone = self._build_landing_zone(lzone)
         value = lzone + value
         divid = 'd%s' % make_uid('%s-%s' % (rtype, entity.eid))
         event_data = {'divid' : divid, 'eid' : entity.eid, 'rtype' : rtype, 'vid' : rvid,