diff -r c7c4775a5619 -r 7b88d12b4ee2 web/views/formrenderers.py --- a/web/views/formrenderers.py Thu Sep 17 15:52:46 2009 +0200 +++ b/web/views/formrenderers.py Tue Sep 22 12:11:12 2009 +0200 @@ -475,6 +475,9 @@ w(u'') w(u'') + # NOTE: should_* and display_* method extracted and moved to the form to + # ease overriding + def inline_entities_form(self, w, form): """create a form to edit entity's inlined relations""" if not hasattr(form, 'inlined_relations'): @@ -494,12 +497,10 @@ def inline_relation_form(self, w, form, rschema, targettype, role): entity = form.edited_entity __ = self.req.pgettext + i18nctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role) w(u'
' % rschema) - existant = entity.has_eid() and entity.related(rschema) - if existant: - # display inline-edition view for all existing related entities - w(form.view('inline-edition', existant, rtype=rschema, role=role, - ptype=entity.e_schema, peid=entity.eid)) + existant = form.display_inline_edition_form(w, rschema, targettype, + role, i18nctx) if role == 'subject': card = rschema.rproperty(entity.e_schema, targettype, 'cardinality')[0] else: @@ -507,9 +508,8 @@ # there is no related entity and we need at least one: we need to # display one explicit inline-creation view if form.should_display_inline_creation_form(rschema, existant, card): - w(form.view('inline-creation', None, etype=targettype, - peid=entity.eid, ptype=entity.e_schema, - rtype=rschema, role=role)) + form.display_inline_creation_form(w, rschema, targettype, + role, i18nctx) existant = True # we can create more than one related entity, we thus display a link # to add new related entities @@ -517,13 +517,12 @@ divid = "addNew%s%s%s:%s" % (targettype, rschema, role, entity.eid) w(u'
' % divid) - js = "addInlineCreationForm('%s', '%s', '%s', '%s')" % ( - entity.eid, targettype, rschema, role) - if card in '1?': + js = "addInlineCreationForm('%s', '%s', '%s', '%s', '%s')" % ( + entity.eid, targettype, rschema, role, i18nctx) + if form.should_hide_add_new_relation_link(rschema, card): js = "toggleVisibility('%s'); %s" % (divid, js) - ctx = 'inlined:%s.%s.%s' % (entity.e_schema, rschema, role) w(u'+ %s.' - % (rschema, entity.eid, js, __(ctx, 'add a %s' % targettype))) + % (rschema, entity.eid, js, __(i18nctx, 'add a %s' % targettype))) w(u'
') w(u'
 
') w(u'
') @@ -547,7 +546,9 @@ w(u'
%s
' % ( values['divid'], self.req._('click on the box to cancel the deletion'))) w(u'
') - values['removemsg'] = self.req.__('remove this %s' % form.edited_entity.e_schema) + eschema = form.edited_entity.e_schema + ctx = values.pop('i18nctx') + values['removemsg'] = self.req.pgettext(ctx, 'remove this %s' % eschema) w(u'
%(title)s ' '#%(counter)s ' '[%(removemsg)s]
'