[ui] Enhance event view so that user annotation is display below other attributes information
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 13 Jul 2016 09:36:44 +0200
changeset 1425 50753eb0a0fa
parent 1424 b124eaa8384a
child 1426 8c1a0a0310b8
[ui] Enhance event view so that user annotation is display below other attributes information Note that each attribute may also have its own annotation, which are not displayed in the list item view. IMO, we should remove those at some point rather than cluttering this view.
views/content.py
views/viewlib.py
--- a/views/content.py	Tue Jul 12 16:53:23 2016 +0200
+++ b/views/content.py	Wed Jul 13 09:36:44 2016 +0200
@@ -389,7 +389,7 @@
     __select__ = viewlib.LinkMetaEntityView.__select__ & is_instance('SEDAEvent')
 
     def entity_call(self, entity):
-        entity.view('seda.xsdmeta', w=self.w, skip_one_card=True)
+        entity.view('seda.xsdmeta', w=self.w, skip_one_card=True, with_annotation=False)
         attrs = []
         for rtype in ['seda_event_type_from',
                       'seda_event_identifier',
@@ -410,6 +410,9 @@
                                                               card=card))
         if attrs:
             self.w(u' ({0})'.format(', '.join(attrs)))
+        description = getattr(entity, 'user_annotation', None)
+        if description:
+            self.w(u' <div class="description text-muted">%s</div>' % description)
 
 
 affk.set_fields_order('SEDAEvent', ['user_cardinality',
--- a/views/viewlib.py	Tue Jul 12 16:53:23 2016 +0200
+++ b/views/viewlib.py	Wed Jul 13 09:36:44 2016 +0200
@@ -29,13 +29,14 @@
 class XSDMetaEntityView(EntityView):
     __regid__ = 'seda.xsdmeta'
 
-    def entity_call(self, entity, skip_one_card=False):
+    def entity_call(self, entity, skip_one_card=False, with_annotation=True):
         cardinality = getattr(entity, 'user_cardinality', '1')
         if cardinality != '1' or not skip_one_card:
             self.w(u' <span class="cardinality">[%s]</span>' % cardinality)
-        description = getattr(entity, 'user_annotation', None)
-        if description:
-            self.w(u' <div class="description text-muted">%s</div>' % description)
+        if with_annotation:
+            description = getattr(entity, 'user_annotation', None)
+            if description:
+                self.w(u' <div class="description text-muted">%s</div>' % description)
 
 
 class TextEntityAttributeView(EntityView):