Commit 37efef02 authored by HERBERT Ryan's avatar HERBERT Ryan

sample_set * add basic pagination

parent 50bf2dbd
...@@ -158,7 +158,14 @@ def all(): ...@@ -158,7 +158,14 @@ def all():
else : else :
type = 'generic' type = 'generic'
list = SampleSetList(type) step = None
page = None
is_not_filtered = "sort" not in request.vars and "filter" not in request.vars
if request.vars['page'] is not None and is_not_filtered:
page = int(request.vars['page'])
step = 50
list = SampleSetList(type, page, step)
list.load_creator_names() list.load_creator_names()
list.load_sample_information() list.load_sample_information()
list.load_config_information() list.load_config_information()
...@@ -192,7 +199,9 @@ def all(): ...@@ -192,7 +199,9 @@ def all():
fields = fields, fields = fields,
type = type, type = type,
isAdmin = isAdmin, isAdmin = isAdmin,
reverse = False) reverse = False,
step = step,
page = page)
## return form to create new generic sample_set ## return form to create new generic sample_set
......
class SampleSetList(): class SampleSetList():
def __init__(self, type): def __init__(self, type, page=None, step=None):
self.type = type self.type = type
limitby = None
if page is not None and step is not None:
limitby = (page*step, (page+1)*step+1) # one more element to indicate if another page exists
query_gss = db( query_gss = db(
(auth.vidjil_accessible_query(PermissionEnum.read.value, db[type])) (auth.vidjil_accessible_query(PermissionEnum.read.value, db[type]))
).select( ).select(
db[type].ALL, db[type].ALL,
limitby = limitby,
orderby = ~db[type].id orderby = ~db[type].id
) )
......
...@@ -10,6 +10,16 @@ ...@@ -10,6 +10,16 @@
search search
<input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/all', {'type': '{{=type}}', 'filter' : this.value} )"> <input id="db_filter_input" type="text" value="{{=request.vars["filter"]}}" onchange="db.call('sample_set/all', {'type': '{{=type}}', 'filter' : this.value} )">
</div> </div>
<div class="db_block_right">
page:
{{ if page > 0: }}
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=type}}', 'page': {{=page-1}}})"><</div>
{{ pass }}
{{= page + 1 }}
{{if len(query) > step : }}
<div class="button" onclick="db.call('sample_set/all', {'type': '{{=type}}', 'page': {{=page+1}}})">></div>
{{ pass }}
</div>
</div> </div>
<div id="db_table_container"> <div id="db_table_container">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment