Skip to content
Snippets Groups Projects
Commit 727f5c30d1c4 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[views] pagination fixes (still wip)

parent 124768a2e21c
No related branches found
No related tags found
No related merge requests found
......@@ -155,4 +155,6 @@
href=self._cw.build_url(**url_params))))
else:
ul(t.li(t.a('<<<')))
total_pages = response.hits.total / 10
page_padding = 3
......@@ -158,19 +160,22 @@
for i in range(0, min((response.hits.total / 10) + 1, 10)):
page = i + 1
url_params['page'] = page
url = self._cw.build_url(**url_params)
if page == current_page:
ul(t.li(t.a(t.b(page),
href=url)))
else:
ul(t.li(t.a(page,
href=url)))
if response.hits.total / 10 > 10:
ul(t.li(t.a("...")))
for i in range((response.hits.total / 10) - 3, response.hits.total / 10):
url_params['page'] = i
url = self._cw.build_url(**url_params)
ul(t.li(t.a(i,
href=url)))
if current_page > page_padding:
for page in range(1,
min(page_padding + 1,
current_page - page_padding)):
self.page_number(url_params, page, current_page, ul)
if current_page > (page_padding * 2) + 1:
ul(t.li(t.a("...")))
for page in range(max(1, current_page - page_padding),
min(current_page + page_padding, total_pages)):
self.page_number(url_params, page, current_page, ul)
if current_page < total_pages - page_padding:
if current_page < total_pages - page_padding * 2:
ul(t.li(t.a("...")))
for page in range(max(current_page + page_padding,
total_pages -page_padding),
total_pages):
self.page_number(url_params, page, current_page, ul)
url_params['page'] = current_page + 1
......@@ -176,7 +181,7 @@
url_params['page'] = current_page + 1
if current_page + 1 >= (response.hits.total / 10):
if current_page + 1 >= (total_pages):
ul(t.li(t.a('>>>')))
else:
ul(t.li(t.a('>>>',
href=self._cw.build_url(**url_params))))
......@@ -178,8 +183,19 @@
ul(t.li(t.a('>>>')))
else:
ul(t.li(t.a('>>>',
href=self._cw.build_url(**url_params))))
def page_number(self, url_params, page, current_page, ul):
url_params['page'] = page
url = self._cw.build_url(**url_params)
if page == current_page:
ul(t.li(t.a(t.b(page),
href=url)))
else:
ul(t.li(t.a(page,
href=url)))
return url
def display_facets(self, response):
self.w(u'''<aside id="aside-main-left" class="col-xs-2 cwjs-aside">
<div class="panel panel-default contextFreeBox facet_filterbox">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment