liquid_feedback_frontend
diff app/main/unit/_sidebar.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
author | bsw |
---|---|
date | Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) |
parents | |
children | bd2509e7f627 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/unit/_sidebar.lua Thu Jul 10 01:19:48 2014 +0200 1.3 @@ -0,0 +1,80 @@ 1.4 +local member = param.get ( "member", "table" ) or app.session.member 1.5 + 1.6 +local unit = param.get ( "unit", "table" ) 1.7 + 1.8 +local areas_selector = Area:new_selector() 1.9 + :reset_fields() 1.10 + :add_field("area.id", nil, { "grouped" }) 1.11 + :add_field("area.unit_id", nil, { "grouped" }) 1.12 + :add_field("area.name", nil, { "grouped" }) 1.13 + :add_where{ "area.unit_id = ?", unit.id } 1.14 + :add_where{ "area.active" } 1.15 + :add_order_by("area.name") 1.16 + 1.17 +if member then 1.18 + areas_selector:left_join ( 1.19 + "membership", nil, 1.20 + { "membership.area_id = area.id AND membership.member_id = ?", member.id } 1.21 + ) 1.22 + areas_selector:add_field("membership.member_id NOTNULL", "subscribed", { "grouped" }) 1.23 +end 1.24 + 1.25 + 1.26 +local areas = areas_selector:exec() 1.27 +if member then 1.28 + unit:load_delegation_info_once_for_member_id(member.id) 1.29 + areas:load_delegation_info_once_for_member_id(member.id) 1.30 +end 1.31 + 1.32 + 1.33 +ui.sidebar ( "tab-whatcanido", function () 1.34 + 1.35 + ui.sidebarHead( function () 1.36 + ui.heading { 1.37 + level = 2, content = _"Subject areas" 1.38 + } 1.39 + end ) 1.40 + 1.41 + if #areas > 0 then 1.42 + 1.43 + ui.container { class = "areas", content = function () 1.44 + 1.45 + for i, area in ipairs ( areas ) do 1.46 + 1.47 + ui.container { attr = { class = "sidebarRow" }, content = function () 1.48 + 1.49 + if member then 1.50 + local delegation = Delegation:by_pk(member.id, nil, area.id, nil) 1.51 + 1.52 + if delegation then 1.53 + ui.link { 1.54 + module = "delegation", view = "show", params = { 1.55 + area_id = area.id 1.56 + }, 1.57 + attr = { class = "delegation_info" }, 1.58 + content = function () 1.59 + ui.delegation(delegation.trustee_id, delegation.trustee_id and delegation.trustee.name) 1.60 + end 1.61 + } 1.62 + end 1.63 + end 1.64 + 1.65 + if area.subscribed then 1.66 + ui.image { attr = { class = "icon24 star" }, static = "icons/48/star.png" } 1.67 + end 1.68 + 1.69 + ui.link { 1.70 + attr = { class = "area" }, 1.71 + module = "area", view = "show", id = area.id, 1.72 + content = area.name 1.73 + } 1.74 + 1.75 + end } -- ui.tag "li" 1.76 + 1.77 + end -- for i, area 1.78 + 1.79 + end } -- ui.tag "ul" 1.80 + 1.81 + end -- if #areas > 0 1.82 + 1.83 +end ) -- ui.sidebar 1.84 \ No newline at end of file