# HG changeset patch # User jbe # Date 1340816273 -7200 # Node ID 3a6962b9121cfc94c17377f57ab537d3d0700cde # Parent bff7194ea72c40a1a6014849a15fb9ce5ea81b35 Anchor support for encode.url{...}, ui.link{...} and ui.paginate{...} diff -r bff7194ea72c -r 3a6962b9121c framework/env/encode/url.lua --- a/framework/env/encode/url.lua Thu Jun 21 17:18:44 2012 +0200 +++ b/framework/env/encode/url.lua Wed Jun 27 18:57:53 2012 +0200 @@ -8,7 +8,8 @@ view = view, -- a view name of the WebMCP application action = action, -- an action name of the WebMCP application id = id, -- optional id to be passed to the view or action to select a particular data record - params = params -- optional parameters to be passed to the view or action + params = params, -- optional parameters to be passed to the view or action + anchor = anchor -- anchor in URL } This function creates URLs to external locations, to static files within the WebMCP application or to a certain view or action inside a module. @@ -92,5 +93,12 @@ end result[#result] = nil -- remove last '&' or '?' end - return table.concat(result) + local string_result = table.concat(result) + if anchor ~= nil then + string_result = string.match(string_result, "^[^#]*") + if anchor then + string_result = string_result .. anchor + end + end + return string_result end diff -r bff7194ea72c -r 3a6962b9121c framework/env/ui/link.lua --- a/framework/env/ui/link.lua Thu Jun 21 17:18:44 2012 +0200 +++ b/framework/env/ui/link.lua Wed Jun 27 18:57:53 2012 +0200 @@ -11,6 +11,7 @@ id = id, -- optional id to be passed to the view or action to select a particular data record params = params, -- optional parameters to be passed to the view or action routing = routing, -- optional routing information for action links, as described for ui.form{...} + anchor = anchor, -- for views: anchor in destination URL text = text, -- link text content = content, -- link content (overrides link text, except for submit buttons for action calls without JavaScript) partial = { -- parameters for partial loading, see below @@ -102,6 +103,7 @@ view = args.view, id = args.id, params = args.params, + anchor = args.anchor } if ui.is_partial_loading_enabled() and args.partial then a_attr.onclick = ui._partial_load_js(args.partial) diff -r bff7194ea72c -r 3a6962b9121c framework/env/ui/paginate.lua --- a/framework/env/ui/paginate.lua Thu Jun 21 17:18:44 2012 +0200 +++ b/framework/env/ui/paginate.lua Wed Jun 27 18:57:53 2012 +0200 @@ -1,6 +1,7 @@ --[[-- ui.paginate{ - selector = selector, -- a selector for items from the database + selector = selector, -- a selector for items from the database (will be modified) + anchor = anchor, -- optional name of anchor in document to jump to per_page = per_page, -- items per page, defaults to 10 container_attr = container_attr -- html attr for the container element name = name, -- name of the CGI get variable, defaults to "page" @@ -61,6 +62,7 @@ view = request.get_view(), id = id, params = params, + anchor = anchor, text = tostring(page), partial = partial }