web/uicfg.py
branchstable
changeset 6282 556b1b1a2c5a
parent 6246 62e25fac41cd
child 6283 c827fa795a6b
--- a/web/uicfg.py	Fri Sep 17 16:53:12 2010 +0200
+++ b/web/uicfg.py	Fri Sep 17 16:54:56 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"
 
@@ -375,22 +373,35 @@
 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:
+
+    * `default_value`, alternative default value (shown when there is no value).
+
+    * `default_showlabel`, when `default_value` 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 'incontext' or 'csv' depending on the cardinality. They can
+      also be statically changed by subclassing :class:`ClickAndEditFormView`
+      and redefining `_one_rvid` (resp. `_many_rvid`).
+
+    * `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 and one-to-one.
     """
-    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('default_value default_showlabel reload rvid edit_target'.split())
 
     def tag_relation(self, key, tag):
         for tagkey in tag.iterkeys():
@@ -415,6 +426,11 @@
         edittarget = 'related' if composite else 'rtype'
         rtag.tag_relation((sschema, rschema, oschema, role),
                           {'edit_target': edittarget})
+    if not 'default_showlabel' in values:
+        showlabel = primaryview_display_ctrl.get(
+            sschema, rschema, oschema, role).get('showlabel', True)
+        rtag.tag_relation((sschema, rschema, oschema, role),
+                          {'default_showlabel': not showlabel})
 
 reledit_ctrl = ReleditTags('reledit', init_reledit_ctrl)