web/uicfg.py
changeset 6333 e3994fcc21c3
parent 6279 42079f752a9c
parent 6283 c827fa795a6b
child 6366 1806148d6ce8
--- a/web/uicfg.py	Tue Sep 21 16:35:37 2010 +0200
+++ b/web/uicfg.py	Thu Sep 23 23:28:58 2010 +0200
@@ -42,8 +42,6 @@
    # Adds all subjects of the entry_of relation in the add menu of the ``Blog``
    # primary view
    uicfg.actionbox_appearsin_addmenu.tag_object_of(('*', 'entry_of', 'Blog'), True)
-
-
 """
 __docformat__ = "restructuredtext en"
 
@@ -372,22 +370,33 @@
 autoform_permissions_overrides = RelationTagsSet('autoform_permissions_overrides')
 
 class ReleditTags(NoTargetRelationTagsDict):
+    """Associate to relation a dictionnary to control `reledit` (e.g. edition of
+    attributes / relations from within views).
+
+    Possible keys and associated values are:
+
+    * `novalue_label`, alternative default value (shown when there is no value).
+
+    * `novalue_include_rtype`, when `novalue_label` is not specified, this boolean
+      flag control wether the generated default value should contains the
+      relation label or not. Will be the opposite of the `showlabel` value found
+      in the `primaryview_display_ctrl` rtag by default.
+
+    * `reload`, boolean, eid (to reload to) or function taking subject and
+      returning bool/eid. This is useful when editing a relation (or attribute)
+      that impacts the url or another parts of the current displayed
+      page. Defaults to False.
+
+    * `rvid`, alternative view id (as str) for relation or composite edition.
+      Default is 'autolimited'.
+
+    * `edit_target`, may be either 'rtype' (to edit the relation) or 'related'
+      (to edit the related entity).  This controls whether to edit the relation
+      or the target entity of the relation.  Currently only one-to-one relations
+      support target entity edition. By default, the 'related' option is taken
+      whenever the relation is composite.
     """
-    default_value: alternative default value
-      The default value is what is shown when there is no value.
-    reload: boolean, eid (to reload to) or function taking subject and returning bool/eid
-      This is useful when editing a relation (or attribute) that impacts the url
-      or another parts of the current displayed page. Defaults to False.
-    rvid: alternative view id (as str) for relation or composite edition
-      Default is 'incontext' or 'csv' depending on the cardinality. They can also be
-      statically changed by subclassing ClickAndEditFormView and redefining _one_rvid
-      (resp. _many_rvid).
-    edit_target: 'rtype' (to edit the relation) or 'related' (to edit the related entity)
-      This controls whether to edit the relation or the target entity of the relation.
-      Currently only one-to-one relations support target entity edition. By default,
-      the 'related' option is taken whenever the relation is composite and one-to-one.
-    """
-    _keys = frozenset('default_value reload rvid edit_target'.split())
+    _keys = frozenset('novalue_label novalue_include_rtype reload rvid edit_target'.split())
 
     def tag_relation(self, key, tag):
         for tagkey in tag.iterkeys():
@@ -412,6 +421,11 @@
         edittarget = 'related' if composite else 'rtype'
         rtag.tag_relation((sschema, rschema, oschema, role),
                           {'edit_target': edittarget})
+    if not 'novalue_include_rtype' in values:
+        showlabel = primaryview_display_ctrl.get(
+            sschema, rschema, oschema, role).get('showlabel', True)
+        rtag.tag_relation((sschema, rschema, oschema, role),
+                          {'novalue_include_rtype': not showlabel})
 
 reledit_ctrl = ReleditTags('reledit', init_reledit_ctrl)