[primary] Try to display links with a "more" href for displaying the whole connections default tip
authorVincent Michel <vincent.michel@logilab.fr>
Wed, 26 Oct 2011 12:28:06 +0200
changeset 5 74f36d773dc9
parent 4 f1ab1c1aa022
[primary] Try to display links with a "more" href for displaying the whole connections
views/primary.py
--- a/views/primary.py	Wed Oct 26 12:27:55 2011 +0200
+++ b/views/primary.py	Wed Oct 26 12:28:06 2011 +0200
@@ -51,13 +51,16 @@
                '<a href ="%(url)s">%(target)s</a></span>'
                % {'icon': xml_escape(icon), 'text': label, 'url': target_url,'target': target_label})
 
-    def _icon_multiple_href(self, label, targets, icon,):
+    def _icon_multiple_href(self, label, targets, icon, href=None):
         self.w(u'<span ><img src="%(icon)s" />%(text)s<ul>'
                % {'icon': xml_escape(icon), 'text': label})
         for target in targets:
             self.w(u'<li><a href ="%(url)s">%(target)s</a></li>'
                    %{'url': target.absolute_url(),'target': xml_escape(target.dc_title())})
-        self.w(u'</ul></span>')
+        self.w(u'</ul>')
+        if href:
+            self.w(href)
+        self.w(u'</span>')
 
 
 #################################################################################
@@ -132,17 +135,28 @@
                             redirection[0].absolute_url(), self._cw.uiprops['REDIRECTION'])
         ### WHOLE LINKS
         if entity.has_subject:
-            self._icon_multiple_href(self._cw._('Categorized in'), entity.has_subject,
-                                     self._cw.uiprops['CATEGORY'])
+            href = None
+            if len(entity.has_subject)>10:
+                rql = 'Any Y WHERE X jas_subject Y, X eid %s' % entity.eid
+                href = (u'<a href="%s">See all %s categories</a>'
+                        % (xml_escape(self._cw.build_url(rql=rql, vid='inlined-list')), len(links)))
+            self._icon_multiple_href(self._cw._('Categorized in'), entity.has_subject[:10],
+                                     self._cw.uiprops['CATEGORY'],  href=href)
         if entity.reverse_redirects_to:
             self._icon_multiple_href(self._cw._('Redirections from'), entity.reverse_redirects_to,
                                      self._cw.uiprops['REDIRECTION'])
         if entity.disambiguates:
             self._icon_multiple_href(self._cw._('Disambiguates'), entity.disambiguates,
                                      self._cw.uiprops['DISAMBIGUATE'])
-        if entity.links_to:
-            self._icon_multiple_href(self._cw._('Related pages'), entity.links_to,
-                                     self._cw.uiprops['LINK'])
+        links = entity.links_to
+        if links:
+            href = None
+            if len(links)>10:
+                rql = 'Any Y WHERE X links_to Y, X eid %s' % entity.eid
+                href = (u'<a href="%s">See all %s links</a>'
+                        % (xml_escape(self._cw.build_url(rql=rql, vid='inlined-list')), len(links)))
+            self._icon_multiple_href(self._cw._('Related pages'), links[:10],
+                                     self._cw.uiprops['LINK'], href=href)
 
 
 #################################################################################