27 from cubicweb.web.formfields import guess_field |
27 from cubicweb.web.formfields import guess_field |
28 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton |
28 from cubicweb.web.formwidgets import Button, SubmitButton, ResetButton |
29 from cubicweb.web.views import forms |
29 from cubicweb.web.views import forms |
30 |
30 |
31 _pvdc = uicfg.primaryview_display_ctrl |
31 _pvdc = uicfg.primaryview_display_ctrl |
32 |
|
33 def relation_id(eid, rtype, role, reid): |
|
34 """return an identifier for a relation between two entities""" |
|
35 if role == 'subject': |
|
36 return u'%s:%s:%s' % (eid, rtype, reid) |
|
37 return u'%s:%s:%s' % (reid, rtype, eid) |
|
38 |
|
39 def toggleable_relation_link(eid, nodeid, label='x'): |
|
40 """return javascript snippet to delete/undelete a relation between two |
|
41 entities |
|
42 """ |
|
43 js = u"javascript: togglePendingDelete('%s', %s);" % ( |
|
44 nodeid, xml_escape(dumps(eid))) |
|
45 return u'[<a class="handle" href="%s" id="handle%s">%s</a>]' % ( |
|
46 js, nodeid, label) |
|
47 |
32 |
48 |
33 |
49 class DeleteConfForm(forms.CompositeForm): |
34 class DeleteConfForm(forms.CompositeForm): |
50 __regid__ = 'deleteconf' |
35 __regid__ = 'deleteconf' |
51 __select__ = non_final_entity() |
36 __select__ = non_final_entity() |