557 """ |
557 """ |
558 id = 'inline-creation' |
558 id = 'inline-creation' |
559 __select__ = (match_kwargs('peid', 'rtype') |
559 __select__ = (match_kwargs('peid', 'rtype') |
560 & specified_etype_implements('Any')) |
560 & specified_etype_implements('Any')) |
561 _select_attrs = InlineEntityEditionFormView._select_attrs + ('etype',) |
561 _select_attrs = InlineEntityEditionFormView._select_attrs + ('etype',) |
562 removejs = "removeInlineForm('%s', '%s', '%s')" |
562 |
|
563 @property |
|
564 def removejs(self): |
|
565 entity = self._entity() |
|
566 card = entity.e_schema.role_rproperty(neg_role(self.role), self.rtype, 'cardinality') |
|
567 card = card[self.role == 'object'] |
|
568 # when one is adding an inline entity for a relation of a single card, |
|
569 # the 'add a new xxx' link disappears. If the user then cancel the addition, |
|
570 # we have to make this link appears back. This is done by giving add new link |
|
571 # id to removeInlineForm. |
|
572 if card not in '?1': |
|
573 return "removeInlineForm('%s', '%s', '%s')" |
|
574 divid = "addNew%s%s%s:%s" % (self.etype, self.rtype, self.role, self.peid) |
|
575 return "removeInlineForm('%%s', '%%s', '%%s', '%s')" % divid |
563 |
576 |
564 @cached |
577 @cached |
565 def _entity(self): |
578 def _entity(self): |
566 try: |
579 try: |
567 cls = self.vreg['etypes'].etype_class(self.etype) |
580 cls = self.vreg['etypes'].etype_class(self.etype) |