web/views/editforms.py
branchstable
changeset 2365 9f5e911eab07
parent 2361 8f00836580f1
child 2370 1e8ce077b62a
child 2371 76bf522c27be
equal deleted inserted replaced
2364:fa16d36d60cb 2365:9f5e911eab07
    88     id = 'reledit'
    88     id = 'reledit'
    89     __select__ = non_final_entity() & match_kwargs('rtype')
    89     __select__ = non_final_entity() & match_kwargs('rtype')
    90 
    90 
    91     # FIXME editableField class could be toggleable from userprefs
    91     # FIXME editableField class could be toggleable from userprefs
    92 
    92 
    93     _onclick = "showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
    93     _onclick = u"showInlineEditionForm(%(eid)s, '%(rtype)s', '%(divid)s')"
    94     _defaultlandingzone = u'<img title="%s" src="data/file.gif"/>'
    94     _defaultlandingzone = u'<img title="%(msg)s" src="data/file.gif" alt="%(msg)s"/>'
    95     _landingzonemsg = _('click to edit this field')
    95     _landingzonemsg = _('click to edit this field')
    96     # default relation vids according to cardinality
    96     # default relation vids according to cardinality
    97     _one_rvid = 'incontext'
    97     _one_rvid = 'incontext'
    98     _many_rvid = 'csv'
    98     _many_rvid = 'csv'
    99 
    99 
   136                 return self.w(value)
   136                 return self.w(value)
   137             elif role == 'object' and not rschema.has_perm(self.req, 'add',
   137             elif role == 'object' and not rschema.has_perm(self.req, 'add',
   138                                                            toeid=entity.eid):
   138                                                            toeid=entity.eid):
   139                 return self.w(value)
   139                 return self.w(value)
   140             elif get_schema_property(entity.e_schema,
   140             elif get_schema_property(entity.e_schema,
   141                                    entity.schema.rschema(rtype),
   141                                      entity.schema.rschema(rtype),
   142                                    role, 'composite'):
   142                                      role, 'composite') == role:
   143                 return self.w(value)
   143                 return self.w(value)
   144             form = self._build_relation_form(entity, value, rtype, role, reload, row, col,
   144             form = self._build_relation_form(entity, value, rtype, role, reload, row, col,
   145                                              rvid, default, landing_zone)
   145                                              rvid, default, landing_zone)
   146         renderer = self.vreg.select_object('formrenderers', 'base', self.req,
   146         renderer = self.vreg.select_object('formrenderers', 'base', self.req,
   147                                       entity=entity,
   147                                       entity=entity,
   149                                       display_fields=[(rtype, role)],
   149                                       display_fields=[(rtype, role)],
   150                                       table_class='', button_bar_class='buttonbar',
   150                                       table_class='', button_bar_class='buttonbar',
   151                                       display_progress_div=False)
   151                                       display_progress_div=False)
   152         self.w(form.form_render(renderer=renderer))
   152         self.w(form.form_render(renderer=renderer))
   153 
   153 
       
   154     def _build_landing_zone(self, lzone):
       
   155         return lzone or self._defaultlandingzone % {'msg' : self.req._(self._landingzonemsg)}
       
   156 
   154     def _build_relation_form(self, entity, value, rtype, role, row, col, reload, rvid,
   157     def _build_relation_form(self, entity, value, rtype, role, row, col, reload, rvid,
   155                              default, lzone):
   158                              default, lzone):
   156         lzone = lzone or self._defaultlandingzone % self.req._(self._landingzonemsg)
   159         lzone = self._build_landing_zone(lzone)
   157         value = lzone + value
   160         value = lzone + value
   158         divid = 'd%s' % make_uid('%s-%s' % (rtype, entity.eid))
   161         divid = 'd%s' % make_uid('%s-%s' % (rtype, entity.eid))
   159         event_data = {'divid' : divid, 'eid' : entity.eid, 'rtype' : rtype, 'vid' : rvid,
   162         event_data = {'divid' : divid, 'eid' : entity.eid, 'rtype' : rtype, 'vid' : rvid,
   160                       'reload' : reload, 'default' : default, 'role' : role,
   163                       'reload' : reload, 'default' : default, 'role' : role,
   161                       'lzone' : lzone}
   164                       'lzone' : lzone}