53 from rql.nodes import VariableRef, Constant |
53 from rql.nodes import VariableRef, Constant |
54 |
54 |
55 from logilab.mtconverter import xml_escape |
55 from logilab.mtconverter import xml_escape |
56 from logilab.common.deprecation import deprecated |
56 from logilab.common.deprecation import deprecated |
57 |
57 |
58 from cubicweb.predicates import (paginated_rset, sorted_rset, |
58 from cubicweb.utils import json_dumps |
59 adaptable, implements) |
59 from cubicweb.predicates import paginated_rset, sorted_rset, adaptable |
60 from cubicweb.uilib import cut |
60 from cubicweb.uilib import cut |
61 from cubicweb.view import EntityAdapter, implements_adapter_compat |
61 from cubicweb.view import EntityAdapter |
62 from cubicweb.web.component import EmptyComponent, EntityCtxComponent, NavigationComponent |
62 from cubicweb.web.component import EmptyComponent, EntityCtxComponent, NavigationComponent |
63 |
63 |
64 |
64 |
65 class PageNavigation(NavigationComponent): |
65 class PageNavigation(NavigationComponent): |
66 """The default pagination component: display link to pages where each pages |
66 """The default pagination component: display link to pages where each pages |
279 if w is None: |
279 if w is None: |
280 w = view.w |
280 w = view.w |
281 nav = req.vreg['components'].select_or_none( |
281 nav = req.vreg['components'].select_or_none( |
282 'navigation', req, rset=rset, page_size=page_size, view=view) |
282 'navigation', req, rset=rset, page_size=page_size, view=view) |
283 if nav: |
283 if nav: |
|
284 domid = getattr(view, 'domid', 'pageContent') |
|
285 view._cw.add_onload(''' |
|
286 jQuery('div.displayAllLink a, div.pagination a').click(function() { |
|
287 cw.jqNode(%s).loadxhtml(this.href, null, 'get', 'swap'); |
|
288 return false; |
|
289 }); |
|
290 ''' % json_dumps(domid)) |
284 if w is None: |
291 if w is None: |
285 w = view.w |
292 w = view.w |
286 if req.form.get('__force_display'): |
293 if req.form.get('__force_display'): |
287 # allow to come back to the paginated view |
294 # allow to come back to the paginated view |
288 params = dict(req.form) |
295 params = dict(req.form) |
322 View.do_paginate = do_paginate |
329 View.do_paginate = do_paginate |
323 View.paginate = paginate |
330 View.paginate = paginate |
324 View.handle_pagination = False |
331 View.handle_pagination = False |
325 |
332 |
326 |
333 |
327 from cubicweb.interfaces import IPrevNext |
|
328 |
334 |
329 class IPrevNextAdapter(EntityAdapter): |
335 class IPrevNextAdapter(EntityAdapter): |
330 """Interface for entities which can be linked to a previous and/or next |
336 """Interface for entities which can be linked to a previous and/or next |
331 entity |
337 entity |
332 |
338 |
333 .. automethod:: next_entity |
339 .. automethod:: next_entity |
334 .. automethod:: previous_entity |
340 .. automethod:: previous_entity |
335 """ |
341 """ |
336 __needs_bw_compat__ = True |
342 __needs_bw_compat__ = True |
337 __regid__ = 'IPrevNext' |
343 __regid__ = 'IPrevNext' |
338 __select__ = implements(IPrevNext, warn=False) # XXX for bw compat, else should be abstract |
344 __abstract__ = True |
339 |
345 |
340 @implements_adapter_compat('IPrevNext') |
|
341 def next_entity(self): |
346 def next_entity(self): |
342 """return the 'next' entity""" |
347 """return the 'next' entity""" |
343 raise NotImplementedError |
348 raise NotImplementedError |
344 |
349 |
345 @implements_adapter_compat('IPrevNext') |
|
346 def previous_entity(self): |
350 def previous_entity(self): |
347 """return the 'previous' entity""" |
351 """return the 'previous' entity""" |
348 raise NotImplementedError |
352 raise NotImplementedError |
349 |
353 |
350 |
354 |