# HG changeset patch # User Florent Cayré # Date 1450285717 -3600 # Node ID 23eb30449fe52ae1bc0addbfd1002591050dea63 # Parent 0b59724cb3f21e2414b86fc37f759dd41da83330 [web] Move "display all"/ "back to pagination" link generation into the navigation component This makes the html generation customizable. Closes #9219057 diff -r 0b59724cb3f2 -r 23eb30449fe5 cubicweb/web/component.py --- a/cubicweb/web/component.py Sat Jan 16 13:48:51 2016 +0100 +++ b/cubicweb/web/component.py Wed Dec 16 18:08:37 2015 +0100 @@ -183,6 +183,28 @@ url = xml_escape(self.page_url(path, params, start, stop)) return self.next_page_link_templ % (url, self._cw._(title), content) + def render_link_back_to_pagination(self, w): + """allow to come back to the paginated view""" + req = self._cw + params = dict(req.form) + basepath = req.relative_path(includeparams=False) + del params['__force_display'] + url = self.page_url(basepath, params) + w(u'\n' + % (xml_escape(url), + req._('back to pagination (%s results)') % self.page_size)) + + def render_link_display_all(self, w): + """make a link to see them all""" + req = self._cw + params = dict(req.form) + self.clean_params(params) + basepath = req.relative_path(includeparams=False) + params['__force_display'] = 1 + params['__fromnavigation'] = 1 + url = self.page_url(basepath, params) + w(u'\n' + % (xml_escape(url), req._('show %s results') % len(self.cw_rset))) # new contextual components system ############################################# diff -r 0b59724cb3f2 -r 23eb30449fe5 cubicweb/web/views/navigation.py --- a/cubicweb/web/views/navigation.py Sat Jan 16 13:48:51 2016 +0100 +++ b/cubicweb/web/views/navigation.py Wed Dec 16 18:08:37 2015 +0100 @@ -285,28 +285,13 @@ if w is None: w = view.w if req.form.get('__force_display'): - # allow to come back to the paginated view - params = dict(req.form) - basepath = req.relative_path(includeparams=False) - del params['__force_display'] - url = nav.page_url(basepath, params) - w(u'\n' - % (xml_escape(url), req._('back to pagination (%s results)') - % nav.page_size)) + nav.render_link_back_to_pagination(w=w) else: # get boundaries before component rendering start, stop = nav.page_boundaries() nav.render(w=w) - params = dict(req.form) - nav.clean_params(params) - # make a link to see them all if show_all_option: - basepath = req.relative_path(includeparams=False) - params['__force_display'] = 1 - params['__fromnavigation'] = 1 - url = nav.page_url(basepath, params) - w(u'\n' - % (xml_escape(url), req._('show %s results') % len(rset))) + nav.render_link_display_all(w=w) rset.limit(offset=start, limit=stop-start, inplace=True)