452 """ |
452 """ |
453 rset = self.rset |
453 rset = self.rset |
454 for i in xrange(len(rset)): |
454 for i in xrange(len(rset)): |
455 self.wview(self.id, rset, row=i, **kwargs) |
455 self.wview(self.id, rset, row=i, **kwargs) |
456 |
456 |
457 def cell_call(self, row, col, peid, rtype, role='subject', **kwargs): |
457 def cell_call(self, row, col, peid, rtype, role, i18nctx, **kwargs): |
458 """ |
458 """ |
459 :param peid: the parent entity's eid hosting the inline form |
459 :param peid: the parent entity's eid hosting the inline form |
460 :param rtype: the relation bridging `etype` and `peid` |
460 :param rtype: the relation bridging `etype` and `peid` |
461 :param role: the role played by the `peid` in the relation |
461 :param role: the role played by the `peid` in the relation |
462 """ |
462 """ |
463 entity = self.entity(row, col) |
463 entity = self.entity(row, col) |
464 divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype, |
464 divonclick = "restoreInlinedEntity('%s', '%s', '%s')" % (peid, rtype, |
465 entity.eid) |
465 entity.eid) |
466 self.render_form(entity, peid, rtype, role, divonclick=divonclick) |
466 self.render_form(entity, peid, rtype, role, i18nctx, |
467 |
467 divonclick=divonclick) |
468 def render_form(self, entity, peid, rtype, role, **kwargs): |
468 |
|
469 def render_form(self, entity, peid, rtype, role, i18nctx, **kwargs): |
469 """fetch and render the form""" |
470 """fetch and render the form""" |
470 form = self.vreg['forms'].select('edition', self.req, entity=entity, |
471 form = self.vreg['forms'].select('edition', self.req, entity=entity, |
471 form_renderer_id='inline', |
472 form_renderer_id='inline', |
472 mainform=False, copy_nav_params=False) |
473 mainform=False, copy_nav_params=False) |
473 self.add_hiddens(form, entity, peid, rtype, role) |
474 self.add_hiddens(form, entity, peid, rtype, role) |
474 divid = '%s-%s-%s' % (peid, rtype, entity.eid) |
475 divid = '%s-%s-%s' % (peid, rtype, entity.eid) |
475 title = self.schema.rschema(rtype).display_name(self.req, role) |
476 title = self.req.pgettext(i18nctx, 'This %s' % entity.e_schema) |
476 removejs = self.removejs % (peid, rtype,entity.eid) |
477 removejs = self.removejs % (peid, rtype, entity.eid) |
477 countkey = '%s_count' % rtype |
478 countkey = '%s_count' % rtype |
478 try: |
479 try: |
479 self.req.data[countkey] += 1 |
480 self.req.data[countkey] += 1 |
480 except: |
481 except: |
481 self.req.data[countkey] = 1 |
482 self.req.data[countkey] = 1 |
482 self.w(form.form_render(divid=divid, title=title, removejs=removejs, |
483 self.w(form.form_render(divid=divid, title=title, removejs=removejs, |
|
484 i18nctx=i18nctx, |
483 counter=self.req.data[countkey], **kwargs)) |
485 counter=self.req.data[countkey], **kwargs)) |
484 |
486 |
485 def add_hiddens(self, form, entity, peid, rtype, role): |
487 def add_hiddens(self, form, entity, peid, rtype, role): |
486 # to ease overriding (see cubes.vcsfile.views.forms for instance) |
488 # to ease overriding (see cubes.vcsfile.views.forms for instance) |
487 if self.keep_entity(form, entity, peid, rtype): |
489 if self.keep_entity(form, entity, peid, rtype): |
509 id = 'inline-creation' |
511 id = 'inline-creation' |
510 __select__ = (match_kwargs('peid', 'rtype') |
512 __select__ = (match_kwargs('peid', 'rtype') |
511 & specified_etype_implements('Any')) |
513 & specified_etype_implements('Any')) |
512 removejs = "removeInlineForm('%s', '%s', '%s')" |
514 removejs = "removeInlineForm('%s', '%s', '%s')" |
513 |
515 |
514 def call(self, etype, peid, rtype, role='subject', **kwargs): |
516 def call(self, etype, peid, rtype, role, i18nctx, **kwargs): |
515 """ |
517 """ |
516 :param etype: the entity type being created in the inline form |
518 :param etype: the entity type being created in the inline form |
517 :param peid: the parent entity's eid hosting the inline form |
519 :param peid: the parent entity's eid hosting the inline form |
518 :param rtype: the relation bridging `etype` and `peid` |
520 :param rtype: the relation bridging `etype` and `peid` |
519 :param role: the role played by the `peid` in the relation |
521 :param role: the role played by the `peid` in the relation |