webmcp

changeset 79:3a6962b9121c

Anchor support for encode.url{...}, ui.link{...} and ui.paginate{...}
author jbe
date Wed Jun 27 18:57:53 2012 +0200 (2012-06-27)
parents bff7194ea72c
children ca3f7b001014
files framework/env/encode/url.lua framework/env/ui/link.lua framework/env/ui/paginate.lua
line diff
     1.1 --- a/framework/env/encode/url.lua	Thu Jun 21 17:18:44 2012 +0200
     1.2 +++ b/framework/env/encode/url.lua	Wed Jun 27 18:57:53 2012 +0200
     1.3 @@ -8,7 +8,8 @@
     1.4    view      = view,       -- a view name of the WebMCP application
     1.5    action    = action,     -- an action name of the WebMCP application
     1.6    id        = id,         -- optional id to be passed to the view or action to select a particular data record
     1.7 -  params    = params      -- optional parameters to be passed to the view or action
     1.8 +  params    = params,     -- optional parameters to be passed to the view or action
     1.9 +  anchor    = anchor      -- anchor in URL
    1.10  }
    1.11  
    1.12  This function creates URLs to external locations, to static files within the WebMCP application or to a certain view or action inside a module.
    1.13 @@ -92,5 +93,12 @@
    1.14      end
    1.15      result[#result] = nil  -- remove last '&' or '?'
    1.16    end
    1.17 -  return table.concat(result)
    1.18 +  local string_result = table.concat(result)
    1.19 +  if anchor ~= nil then
    1.20 +    string_result = string.match(string_result, "^[^#]*")
    1.21 +    if anchor then
    1.22 +      string_result = string_result .. anchor
    1.23 +    end
    1.24 +  end
    1.25 +  return string_result
    1.26  end
     2.1 --- a/framework/env/ui/link.lua	Thu Jun 21 17:18:44 2012 +0200
     2.2 +++ b/framework/env/ui/link.lua	Wed Jun 27 18:57:53 2012 +0200
     2.3 @@ -11,6 +11,7 @@
     2.4    id        = id,         -- optional id to be passed to the view or action to select a particular data record
     2.5    params    = params,     -- optional parameters to be passed to the view or action
     2.6    routing   = routing,    -- optional routing information for action links, as described for ui.form{...}
     2.7 +  anchor    = anchor,     -- for views: anchor in destination URL
     2.8    text      = text,       -- link text
     2.9    content   = content,    -- link content (overrides link text, except for submit buttons for action calls without JavaScript)
    2.10    partial   = {           -- parameters for partial loading, see below
    2.11 @@ -102,6 +103,7 @@
    2.12        view      = args.view,
    2.13        id        = args.id,
    2.14        params    = args.params,
    2.15 +      anchor    = args.anchor
    2.16      }
    2.17      if ui.is_partial_loading_enabled() and args.partial then
    2.18        a_attr.onclick = ui._partial_load_js(args.partial)
     3.1 --- a/framework/env/ui/paginate.lua	Thu Jun 21 17:18:44 2012 +0200
     3.2 +++ b/framework/env/ui/paginate.lua	Wed Jun 27 18:57:53 2012 +0200
     3.3 @@ -1,6 +1,7 @@
     3.4  --[[--
     3.5  ui.paginate{
     3.6 -  selector       = selector,       -- a selector for items from the database
     3.7 +  selector       = selector,       -- a selector for items from the database (will be modified)
     3.8 +  anchor         = anchor,         -- optional name of anchor in document to jump to
     3.9    per_page       = per_page,       -- items per page, defaults to 10
    3.10    container_attr = container_attr  -- html attr for the container element
    3.11    name           = name,           -- name of the CGI get variable, defaults to "page"
    3.12 @@ -61,6 +62,7 @@
    3.13            view   = request.get_view(),
    3.14            id     = id,
    3.15            params = params,
    3.16 +          anchor = anchor,
    3.17            text   = tostring(page),
    3.18            partial = partial
    3.19          }

Impressum / About Us