webmcp
changeset 569:5b19007574de tip
New argument active_link_attr for env.ui.paginate{...}
author | jbe |
---|---|
date | Wed Oct 13 17:21:44 2021 +0200 (23 months ago) |
parents | c43f251262d8 |
children | |
files | Makefile.options framework/env/ui/paginate.lua |
line diff
1.1 --- a/Makefile.options Wed Oct 13 16:48:34 2021 +0200 1.2 +++ b/Makefile.options Wed Oct 13 17:21:44 2021 +0200 1.3 @@ -11,7 +11,7 @@ 1.4 # C compiler flags 1.5 # TODO: check alternatives to -D_GNU_SOURCE -fPIC 1.6 # using libtool? 1.7 -CFLAGS = -O2 -D_GNU_SOURCE -fPIC -Wall -I /usr/include -I /usr/local/include -I /usr/include/lua5.3 -I /usr/local/include/lua53 1.8 +CFLAGS = -O2 -D_GNU_SOURCE -fPIC -Wall -I /usr/include -I /usr/local/include -I /usr/include/lua5.4 -I /usr/local/include/lua54 1.9 1.10 # additional C compiler flags for parts which depend on PostgreSQL 1.11 CFLAGS_PGSQL = -I `pg_config --includedir` -I `pg_config --pkgincludedir` -I `pg_config --includedir-server`
2.1 --- a/framework/env/ui/paginate.lua Wed Oct 13 16:48:34 2021 +0200 2.2 +++ b/framework/env/ui/paginate.lua Wed Oct 13 17:21:44 2021 +0200 2.3 @@ -1,14 +1,15 @@ 2.4 --[[-- 2.5 ui.paginate{ 2.6 - selector = selector, -- a selector for items from the database (will be modified) 2.7 - anchor = anchor, -- optional name of anchor in document to jump to 2.8 - per_page = per_page, -- items per page, defaults to 10 2.9 - container_attr = container_attr, -- html attr for the container element 2.10 - link_attr = link_attr, -- html attr for each page link 2.11 - name = name, -- name of the CGI get variable, defaults to "page" 2.12 - position = position, -- position of page links relative to content: "before", "after", or "both" (default) 2.13 - content = function() 2.14 - ... -- code block which should be encapsulated with page selection links 2.15 + selector = selector, -- a selector for items from the database (will be modified) 2.16 + anchor = anchor, -- optional name of anchor in document to jump to 2.17 + per_page = per_page, -- items per page, defaults to 10 2.18 + container_attr = container_attr, -- html attr for the container element 2.19 + link_attr = link_attr, -- html attr for each page link 2.20 + active_link_attr = active_link_attr, -- alternative html attr for the active page link 2.21 + name = name, -- name of the CGI get variable, defaults to "page" 2.22 + position = position, -- position of page links relative to content: "before", "after", or "both" (default) 2.23 + content = function() 2.24 + ... -- code block which should be encapsulated with page selection links 2.25 end 2.26 } 2.27 2.28 @@ -17,14 +18,15 @@ 2.29 --]]-- 2.30 2.31 function ui.paginate(args) 2.32 - local selector = args.selector 2.33 - local anchor = args.anchor 2.34 - local per_page = args.per_page or 10 2.35 - local container_attr = args.container_attr or { class = 'ui_paginate' } 2.36 - local link_attr = args.link_attr or {} 2.37 - local name = args.name or 'page' 2.38 - local position = args.position or 'both' 2.39 - local content = args.content 2.40 + local selector = args.selector 2.41 + local anchor = args.anchor 2.42 + local per_page = args.per_page or 10 2.43 + local container_attr = args.container_attr or { class = 'ui_paginate' } 2.44 + local link_attr = args.link_attr or {} 2.45 + local active_link_attr = args.active_link_attr or link_attr 2.46 + local name = args.name or 'page' 2.47 + local position = args.position or 'both' 2.48 + local content = args.content 2.49 local count_selector = selector:get_db_conn():new_selector() 2.50 count_selector:add_field('count(1)') 2.51 count_selector:add_from(selector) 2.52 @@ -49,13 +51,16 @@ 2.53 slot.put(" ") 2.54 end 2.55 params[name] = page 2.56 - local attr = table.new(link_attr) 2.57 + local attr 2.58 if current_page == page then 2.59 + attr = table.new(active_link_attr) 2.60 if attr.class then 2.61 attr.class = attr.class .. " active" 2.62 else 2.63 attr.class = "active" 2.64 end 2.65 + else 2.66 + attr = table.new(link_attr) 2.67 end 2.68 ui.link{ 2.69 attr = attr,