liquid_feedback_frontend

changeset 262:7ef1e03e4057

Added unit chooser and unit support to area list
author bsw
date Tue Feb 07 17:54:00 2012 +0100 (2012-02-07)
parents 82c1d3a7819c
children f42d16567c5d
files app/main/_filter/21_auth.lua app/main/_filter_view/30_navigation.lua app/main/area/list.lua app/main/area/show.lua app/main/unit/list.lua model/area.lua
line diff
     1.1 --- a/app/main/_filter/21_auth.lua	Tue Feb 07 17:35:45 2012 +0100
     1.2 +++ b/app/main/_filter/21_auth.lua	Tue Feb 07 17:54:00 2012 +0100
     1.3 @@ -18,7 +18,12 @@
     1.4  if config.public_access then
     1.5  
     1.6    if
     1.7 -    request.get_module() == "area" and (
     1.8 +    request.get_module() == "unit" and (
     1.9 +     request.get_view() == "list"
    1.10 +     or request.get_view() == "show"
    1.11 +     or request.get_view() == "show_tab"
    1.12 +    )
    1.13 +    or request.get_module() == "area" and (
    1.14       request.get_view() == "list"
    1.15       or request.get_view() == "show"
    1.16       or request.get_view() == "show_tab"
     2.1 --- a/app/main/_filter_view/30_navigation.lua	Tue Feb 07 17:35:45 2012 +0100
     2.2 +++ b/app/main/_filter_view/30_navigation.lua	Tue Feb 07 17:54:00 2012 +0100
     2.3 @@ -13,13 +13,21 @@
     2.4  
     2.5    if app.session.member or config.public_access then
     2.6  
     2.7 -    ui.link{
     2.8 -      image  = { static = "icons/16/package.png" },
     2.9 -      text   = _"Areas",
    2.10 -      module = 'area',
    2.11 -      view   = 'list'
    2.12 -    }
    2.13 -
    2.14 +    if config.feature_units_enabled then
    2.15 +      ui.link{
    2.16 +        image  = { static = "icons/16/package.png" },
    2.17 +        text   = _"Units",
    2.18 +        module = 'unit',
    2.19 +        view   = 'list'
    2.20 +      }
    2.21 +    else
    2.22 +      ui.link{
    2.23 +        image  = { static = "icons/16/package.png" },
    2.24 +        text   = _"Areas",
    2.25 +        module = 'area',
    2.26 +        view   = 'list'
    2.27 +      }
    2.28 +    end
    2.29    end
    2.30  
    2.31    if app.session.member == nil then
     3.1 --- a/app/main/area/list.lua	Tue Feb 07 17:35:45 2012 +0100
     3.2 +++ b/app/main/area/list.lua	Tue Feb 07 17:54:00 2012 +0100
     3.3 @@ -1,11 +1,12 @@
     3.4 --- TODO support multiple units
     3.5 +local unit_id = param.get("unit_id", atom.integer)
     3.6 +
     3.7  local areas_selector = Area:build_selector{ active = true, unit_id = unit_id }
     3.8  
     3.9  local unit = Unit:by_id(unit_id)
    3.10  
    3.11  
    3.12 -if app.session.member_id then
    3.13 -  slot.put_into("title", _("Area list of unit '#{unit_name}'", { unit_name = unit.name }))
    3.14 +if config.feature_units_enabled then
    3.15 +  slot.put_into("title", unit.name)
    3.16  else
    3.17    slot.put_into("title", encode.html(config.app_title))
    3.18  end
     4.1 --- a/app/main/area/show.lua	Tue Feb 07 17:35:45 2012 +0100
     4.2 +++ b/app/main/area/show.lua	Tue Feb 07 17:54:00 2012 +0100
     4.3 @@ -13,7 +13,7 @@
     4.4  end
     4.5  
     4.6  
     4.7 -slot.put_into("title", encode.html(_("Area '#{name}'", { name = area.name })))
     4.8 +slot.put_into("title", area.name_with_unit_name)
     4.9  
    4.10  
    4.11  ui.container{
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/app/main/unit/list.lua	Tue Feb 07 17:54:00 2012 +0100
     5.3 @@ -0,0 +1,27 @@
     5.4 +local units = Unit:get_flattened_tree{ active = true }
     5.5 +
     5.6 +slot.put_into("title", encode.html(config.app_title))
     5.7 +
     5.8 +if not app.session.member_id and config.motd_public then
     5.9 +  local help_text = config.motd_public
    5.10 +  ui.container{
    5.11 +    attr = { class = "wiki motd" },
    5.12 +    content = function()
    5.13 +      slot.put(format.wiki_text(help_text))
    5.14 +    end
    5.15 +  }
    5.16 +end
    5.17 +
    5.18 +util.help("unit.list", _"Unit list")
    5.19 +
    5.20 +ui.list{
    5.21 +  records = units,
    5.22 +  columns = {
    5.23 +    {
    5.24 +      label = "name",
    5.25 +      content = function(unit)
    5.26 +        ui.link{ text = unit.name, module = "area", view = "list", params = { unit_id = unit.id } }
    5.27 +      end 
    5.28 +    }
    5.29 +  }
    5.30 +}
    5.31 \ No newline at end of file
     6.1 --- a/model/area.lua	Tue Feb 07 17:35:45 2012 +0100
     6.2 +++ b/model/area.lua	Tue Feb 07 17:54:00 2012 +0100
     6.3 @@ -2,6 +2,14 @@
     6.4  Area.table = 'area'
     6.5  
     6.6  Area:add_reference{
     6.7 +  mode          = 'm1',
     6.8 +  to            = "Unit",
     6.9 +  this_key      = 'unit_id',
    6.10 +  that_key      = 'id',
    6.11 +  ref           = 'unit',
    6.12 +}
    6.13 +
    6.14 +Area:add_reference{
    6.15    mode          = '1m',
    6.16    to            = "Issue",
    6.17    this_key      = 'id',
    6.18 @@ -68,3 +76,9 @@
    6.19    end
    6.20    return selector
    6.21  end
    6.22 +
    6.23 +function Area.object_get:name_with_unit_name()
    6.24 +  if config.feature_units_enabled then
    6.25 +    return self.unit.name .. " > " .. self.name
    6.26 +  end
    6.27 +end
    6.28 \ No newline at end of file

Impressum / About Us