backoffice: paginate listing results (#1584)
This commit is contained in:
parent
513392b23a
commit
36f5accdfc
|
@ -15,6 +15,7 @@
|
|||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import urllib
|
||||
|
||||
from quixote import get_request, get_publisher
|
||||
|
||||
|
@ -34,7 +35,7 @@ class FormDefUI:
|
|||
if offset and not count:
|
||||
count = 20
|
||||
items, total_count = self.get_listing_items(selected_filter, offset, count)
|
||||
if offset > 0 or total_count < count:
|
||||
if offset > 0 or total_count > count:
|
||||
partial_display = True
|
||||
|
||||
if not partial_display:
|
||||
|
@ -93,12 +94,28 @@ class FormDefUI:
|
|||
'<tbody>'
|
||||
self.tbody(fields, items, url_action)
|
||||
'</tbody>'
|
||||
"</table>"
|
||||
'</table>'
|
||||
|
||||
if offset and count:
|
||||
if partial_display:
|
||||
# add links to paginate
|
||||
pass
|
||||
'<div id="page-links">'
|
||||
if offset > 0:
|
||||
# link to previous page
|
||||
query = get_request().form.copy()
|
||||
query['offset'] = max(offset-count, 0)
|
||||
query['count'] = count
|
||||
'<a href="?%s">%s</a>' % (urllib.urlencode(query), _('Previous Page'))
|
||||
|
||||
if offset + count < total_count:
|
||||
' - '
|
||||
|
||||
if offset + count < total_count:
|
||||
# link to next page
|
||||
query = get_request().form.copy()
|
||||
query['offset'] = offset+count
|
||||
query['count'] = count
|
||||
'<a href="?%s">%s</a>' % (urllib.urlencode(query), _('Next Page'))
|
||||
'</div>'
|
||||
|
||||
def get_listing_items(self, selected_filter='all', offset=None, count=None):
|
||||
if selected_filter == 'all':
|
||||
|
@ -123,7 +140,10 @@ class FormDefUI:
|
|||
|
||||
total_count = len(item_ids)
|
||||
|
||||
if offset and count:
|
||||
if not offset:
|
||||
offset = 0
|
||||
|
||||
if count:
|
||||
items = [self.formdef.data_class().get(x) for x in item_ids[offset:offset+count]]
|
||||
else:
|
||||
items = [self.formdef.data_class().get(x) for x in item_ids]
|
||||
|
|
|
@ -646,10 +646,6 @@ table#substvars td {
|
|||
-moz-column-gap: 1em;
|
||||
-webkit-column-count: 2;
|
||||
-webkit-column-gap: 1em;
|
||||
|
||||
svg {
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
h2 span.change,
|
||||
|
@ -658,7 +654,17 @@ h3 span.change {
|
|||
font-weight: normal;
|
||||
}
|
||||
|
||||
div#page-links {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
/* Styling for workflow graphs */
|
||||
|
||||
svg {
|
||||
width: 100%;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
svg .node polygon {
|
||||
stroke:black;
|
||||
fill:#EEE;
|
||||
|
|
Loading…
Reference in New Issue