333 if form.should_inline_relation_form(rschema, targettype, role): |
333 if form.should_inline_relation_form(rschema, targettype, role): |
334 w(u'<div id="inline%sslot">' % rschema) |
334 w(u'<div id="inline%sslot">' % rschema) |
335 existant = entity.has_eid() and entity.related(rschema) |
335 existant = entity.has_eid() and entity.related(rschema) |
336 if existant: |
336 if existant: |
337 # display inline-edition view for all existing related entities |
337 # display inline-edition view for all existing related entities |
338 w(self.view('inline-edition', existant, rtype=rschema, role=role, |
338 w(form.view('inline-edition', existant, rtype=rschema, role=role, |
339 ptype=entity.e_schema, peid=entity.eid, |
339 ptype=entity.e_schema, peid=entity.eid)) |
340 **kwargs)) |
|
341 if role == 'subject': |
340 if role == 'subject': |
342 card = rschema.rproperty(entity.e_schema, targettype, 'cardinality')[0] |
341 card = rschema.rproperty(entity.e_schema, targettype, 'cardinality')[0] |
343 else: |
342 else: |
344 card = rschema.rproperty(targettype, entity.e_schema, 'cardinality')[1] |
343 card = rschema.rproperty(targettype, entity.e_schema, 'cardinality')[1] |
345 # there is no related entity and we need at least one: we need to |
344 # there is no related entity and we need at least one: we need to |
352 # to add new related entities |
351 # to add new related entities |
353 if form.should_display_add_new_relation_link(rschema, existant, card): |
352 if form.should_display_add_new_relation_link(rschema, existant, card): |
354 divid = "addNew%s%s%s:%s" % (targettype, rschema, role, entity.eid) |
353 divid = "addNew%s%s%s:%s" % (targettype, rschema, role, entity.eid) |
355 w(u'<div class="inlinedform" id="%s" cubicweb:limit="true">' |
354 w(u'<div class="inlinedform" id="%s" cubicweb:limit="true">' |
356 % divid) |
355 % divid) |
357 js = "addInlineCreationForm('%s', '%s', '%s', '%s', '%s')" % ( |
356 js = "addInlineCreationForm('%s', '%s', '%s', '%s')" % ( |
358 entity.eid, entity.e_schema, targettype, rschema, role) |
357 entity.eid, targettype, rschema, role) |
359 if card in '1?': |
358 if card in '1?': |
360 js = "toggleVisibility('%s'); %s" % (divid, js) |
359 js = "toggleVisibility('%s'); %s" % (divid, js) |
361 w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>' |
360 w(u'<a class="addEntity" id="add%s:%slink" href="javascript: %s" >+ %s.</a>' |
362 % (rschema, entity.eid, js, __('add a %s' % targettype))) |
361 % (rschema, entity.eid, js, __('add a %s' % targettype))) |
363 w(u'</div>') |
362 w(u'</div>') |