From 0fa08cdc98b813be559cd37fed46ca65c2ade216 Mon Sep 17 00:00:00 2001 From: totoro Date: Mon, 4 Feb 2019 00:53:18 +0100 Subject: [PATCH] add management of pager --- web/widgets/pager.anubis | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+), 0 deletions(-) create mode 100644 web/widgets/pager.anubis diff --git a/web/widgets/pager.anubis b/web/widgets/pager.anubis new file mode 100644 index 0000000..881eb83 --- /dev/null +++ b/web/widgets/pager.anubis @@ -0,0 +1,64 @@ +/* + * Created by PyramIDE. + * User: フランスのトトロ aka (David RENÉ) + * Date: 03/02/2019 + * Time: 19:32 + * © David RENÉ + */ + +read calexium_lib/web/CXM_making_a_web_site.anubis +read calexium_lib/web/CXM_web_session.anubis + +public define HTML_Partial_Content + control_panel_pager + ( + String pager_id, + String previous, + String next + ) + = + partial_content([js(js_file("js/cxm/cxm_pager.js"))], + div(id(pager_id), [ + text(class("o_pager_current_page"),"0"), + text("/"), + text(class("o_pager_total_page"),"0"), + text(" "), + text(class("o_pager_total_items"),"0"), + span(class("btn-group btn-group-sm"), [ + button([class("fa fa-chevron-left btn btn-icon o_pager_previous"), attr("type","button"), accesskey('p'), event(onclick, previous)]), + button([class("fa fa-chevron-right btn btn-icon o_pager_next"), attr("type","button"), accesskey('n'), event(onclick, next)]) + ]) + ])) +. + +public define HTML_Head_Tag + update_pager_script + ( + String pager_id, + Int current_page, + Int total_pages, + Int total_items + )= + js_script("update_pager('"+pager_id+"', "+current_page+", "+total_pages+", "+total_items+");") +. + +public define One + get_current_page + ( + WEB_Session _session + )= + with lwa = *_session.web_request.lwa, + //check if we clicked on next or previous pager + next_page = get_Bool(lwa, "next_page", false), + previous_page = get_Bool(lwa, "previous_page", false), + + //get the current page stored in session + _page = get_Int(_session.fields, "pager_current_page", 1), + + //if clicked on pager change page number else set to 1 (means change on query or tag. In that case reset the page) + current_page = if next_page then _page+1 else if previous_page then _page-1 else 1, + + //store current page in web session for the next call + replace_Int(_session.fields, "pager_current_page", current_page) +. + -- libgit2 0.21.4