490 """This is a specific renderer for entity's form inlined into another |
490 """This is a specific renderer for entity's form inlined into another |
491 entity's form. |
491 entity's form. |
492 """ |
492 """ |
493 __regid__ = 'inline' |
493 __regid__ = 'inline' |
494 |
494 |
|
495 def render_title(self, w, form, values): |
|
496 w(u'<span>%(title)s</span> ' |
|
497 '#<span class="icounter">%(counter)s</span> ' % values) |
|
498 if values['removejs']: |
|
499 values['removemsg'] = self._cw._('remove-inlined-entity-form') |
|
500 w(u'[<a href="javascript: %(removejs)s;$.noop();">%(removemsg)s</a>]' |
|
501 % values) |
|
502 |
495 def render(self, w, form, values): |
503 def render(self, w, form, values): |
496 form.add_media() |
504 form.add_media() |
497 try: |
505 try: |
498 w(u'<div id="div-%(divid)s" onclick="%(divonclick)s">' % values) |
506 w(u'<div id="div-%(divid)s" onclick="%(divonclick)s">' % values) |
499 except KeyError: |
507 except KeyError: |
501 else: |
509 else: |
502 w(u'<div id="notice-%s" class="notice">%s</div>' % ( |
510 w(u'<div id="notice-%s" class="notice">%s</div>' % ( |
503 values['divid'], self._cw._('click on the box to cancel the deletion'))) |
511 values['divid'], self._cw._('click on the box to cancel the deletion'))) |
504 w(u'<div class="iformBody">') |
512 w(u'<div class="iformBody">') |
505 eschema = form.edited_entity.e_schema |
513 eschema = form.edited_entity.e_schema |
506 if values['removejs']: |
514 w(u'<div class="iformTitle">') |
507 values['removemsg'] = self._cw._('remove-inlined-entity-form') |
515 self.render_title(w, form, values) |
508 w(u'<div class="iformTitle"><span>%(title)s</span> ' |
516 w(u'</div>') |
509 '#<span class="icounter">%(counter)s</span> ' |
|
510 '[<a href="javascript: %(removejs)s;$.noop();">%(removemsg)s</a>]</div>' |
|
511 % values) |
|
512 else: |
|
513 w(u'<div class="iformTitle"><span>%(title)s</span> ' |
|
514 '#<span class="icounter">%(counter)s</span></div>' |
|
515 % values) |
|
516 # XXX that stinks |
517 # XXX that stinks |
517 # cleanup values |
518 # cleanup values |
518 for key in ('title', 'removejs', 'removemsg'): |
519 for key in ('title', 'removejs', 'removemsg'): |
519 values.pop(key, None) |
520 values.pop(key, None) |
520 self.render_fields(w, form, values) |
521 self.render_fields(w, form, values) |