# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1417689430 -3600
# Node ID a328b91938b23166586d65fca58ebc5757680286
# Parent  4b33246cb43ceb9231c323c1f1462c1a939f1ff2
Fix handling of limit within the primary view for related elements. Closes #4723579

* respect limit set by uicfg (like the 'autolimited' view itself does)
* set limit in rql query to one more than the specified one so the view knows
  there are more things to display

diff -r 4b33246cb43c -r a328b91938b2 web/views/primary.py
--- a/web/views/primary.py	Mon Dec 29 12:35:34 2014 +0100
+++ b/web/views/primary.py	Thu Dec 04 11:37:10 2014 +0100
@@ -237,7 +237,9 @@
                                      rtype=rschema.type, role=role)
             else:
                 vid = dispctrl.get('vid', 'autolimited')
-                limit = defaultlimit if vid == 'autolimited' else None
+                limit = dispctrl.get('limit', defaultlimit) if vid == 'autolimited' else None
+                if limit is not None:
+                    limit += 1 # need one more so the view can check if there is more than the limit
                 rset = self._relation_rset(entity, rschema, role, dispctrl, limit=limit)
                 if not rset:
                     continue