# HG changeset patch # User bsw # Date 1328633640 -3600 # Node ID 7ef1e03e4057c7284cd9ab30e61867ac4f602e00 # Parent 82c1d3a7819cbc6d23f2977c06e29c0d4ec54649 Added unit chooser and unit support to area list diff -r 82c1d3a7819c -r 7ef1e03e4057 app/main/_filter/21_auth.lua --- a/app/main/_filter/21_auth.lua Tue Feb 07 17:35:45 2012 +0100 +++ b/app/main/_filter/21_auth.lua Tue Feb 07 17:54:00 2012 +0100 @@ -18,7 +18,12 @@ if config.public_access then if - request.get_module() == "area" and ( + request.get_module() == "unit" and ( + request.get_view() == "list" + or request.get_view() == "show" + or request.get_view() == "show_tab" + ) + or request.get_module() == "area" and ( request.get_view() == "list" or request.get_view() == "show" or request.get_view() == "show_tab" diff -r 82c1d3a7819c -r 7ef1e03e4057 app/main/_filter_view/30_navigation.lua --- a/app/main/_filter_view/30_navigation.lua Tue Feb 07 17:35:45 2012 +0100 +++ b/app/main/_filter_view/30_navigation.lua Tue Feb 07 17:54:00 2012 +0100 @@ -13,13 +13,21 @@ if app.session.member or config.public_access then - ui.link{ - image = { static = "icons/16/package.png" }, - text = _"Areas", - module = 'area', - view = 'list' - } - + if config.feature_units_enabled then + ui.link{ + image = { static = "icons/16/package.png" }, + text = _"Units", + module = 'unit', + view = 'list' + } + else + ui.link{ + image = { static = "icons/16/package.png" }, + text = _"Areas", + module = 'area', + view = 'list' + } + end end if app.session.member == nil then diff -r 82c1d3a7819c -r 7ef1e03e4057 app/main/area/list.lua --- a/app/main/area/list.lua Tue Feb 07 17:35:45 2012 +0100 +++ b/app/main/area/list.lua Tue Feb 07 17:54:00 2012 +0100 @@ -1,11 +1,12 @@ --- TODO support multiple units +local unit_id = param.get("unit_id", atom.integer) + local areas_selector = Area:build_selector{ active = true, unit_id = unit_id } local unit = Unit:by_id(unit_id) -if app.session.member_id then - slot.put_into("title", _("Area list of unit '#{unit_name}'", { unit_name = unit.name })) +if config.feature_units_enabled then + slot.put_into("title", unit.name) else slot.put_into("title", encode.html(config.app_title)) end diff -r 82c1d3a7819c -r 7ef1e03e4057 app/main/area/show.lua --- a/app/main/area/show.lua Tue Feb 07 17:35:45 2012 +0100 +++ b/app/main/area/show.lua Tue Feb 07 17:54:00 2012 +0100 @@ -13,7 +13,7 @@ end -slot.put_into("title", encode.html(_("Area '#{name}'", { name = area.name }))) +slot.put_into("title", area.name_with_unit_name) ui.container{ diff -r 82c1d3a7819c -r 7ef1e03e4057 app/main/unit/list.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/main/unit/list.lua Tue Feb 07 17:54:00 2012 +0100 @@ -0,0 +1,27 @@ +local units = Unit:get_flattened_tree{ active = true } + +slot.put_into("title", encode.html(config.app_title)) + +if not app.session.member_id and config.motd_public then + local help_text = config.motd_public + ui.container{ + attr = { class = "wiki motd" }, + content = function() + slot.put(format.wiki_text(help_text)) + end + } +end + +util.help("unit.list", _"Unit list") + +ui.list{ + records = units, + columns = { + { + label = "name", + content = function(unit) + ui.link{ text = unit.name, module = "area", view = "list", params = { unit_id = unit.id } } + end + } + } +} \ No newline at end of file diff -r 82c1d3a7819c -r 7ef1e03e4057 model/area.lua --- a/model/area.lua Tue Feb 07 17:35:45 2012 +0100 +++ b/model/area.lua Tue Feb 07 17:54:00 2012 +0100 @@ -2,6 +2,14 @@ Area.table = 'area' Area:add_reference{ + mode = 'm1', + to = "Unit", + this_key = 'unit_id', + that_key = 'id', + ref = 'unit', +} + +Area:add_reference{ mode = '1m', to = "Issue", this_key = 'id', @@ -68,3 +76,9 @@ end return selector end + +function Area.object_get:name_with_unit_name() + if config.feature_units_enabled then + return self.unit.name .. " > " .. self.name + end +end \ No newline at end of file