236 entity = self._entity() |
236 entity = self._entity() |
237 divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % ( |
237 divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % ( |
238 self.peid, self.rtype, entity.eid) |
238 self.peid, self.rtype, entity.eid) |
239 self.render_form(i18nctx, divonclick=divonclick, **kwargs) |
239 self.render_form(i18nctx, divonclick=divonclick, **kwargs) |
240 |
240 |
|
241 def _get_removejs(self): |
|
242 """ |
|
243 Don't display the remove link in edition form if the |
|
244 cardinality is 1. Handled in InlineEntityCreationFormView for |
|
245 creation form. |
|
246 """ |
|
247 entity = self._entity() |
|
248 if isinstance(self.peid, int): |
|
249 pentity = self._cw.entity_from_eid(self.peid) |
|
250 petype = pentity.e_schema.type |
|
251 rdef = entity.e_schema.rdef(self.rtype, neg_role(self.role), petype) |
|
252 card= rdef.role_cardinality(self.role) |
|
253 if card == '1': # don't display remove link |
|
254 return None |
|
255 return self.removejs and self.removejs % ( |
|
256 self.peid, self.rtype, entity.eid) |
|
257 |
241 def render_form(self, i18nctx, **kwargs): |
258 def render_form(self, i18nctx, **kwargs): |
242 """fetch and render the form""" |
259 """fetch and render the form""" |
243 entity = self._entity() |
260 entity = self._entity() |
244 divid = '%s-%s-%s' % (self.peid, self.rtype, entity.eid) |
261 divid = '%s-%s-%s' % (self.peid, self.rtype, entity.eid) |
245 title = self.form_title(entity, i18nctx) |
262 title = self.form_title(entity, i18nctx) |
246 removejs = self.removejs and self.removejs % ( |
263 removejs = self._get_removejs() |
247 self.peid, self.rtype, entity.eid) |
|
248 countkey = '%s_count' % self.rtype |
264 countkey = '%s_count' % self.rtype |
249 try: |
265 try: |
250 self._cw.data[countkey] += 1 |
266 self._cw.data[countkey] += 1 |
251 except KeyError: |
267 except KeyError: |
252 self._cw.data[countkey] = 1 |
268 self._cw.data[countkey] = 1 |