annotate app/main/lf2/_areas.lua @ 212:3e4ad069847a
Some more work at 2nd generation frontend code
author |
bsw |
date |
Thu Mar 03 18:39:00 2011 +0100 (2011-03-03) |
parents |
4993b71b383f |
children |
1dab81353eb1 |
rev |
line source |
bsw@211
|
1 local areas = param.get("areas_selector", "table"):exec()
|
bsw@212
|
2 local current_area_id = param.get("current_area_id", atom.integer)
|
bsw@211
|
3 local head_content = param.get("head_content", "function")
|
bsw@211
|
4
|
bsw@212
|
5 if #areas == 0 then
|
bsw@212
|
6 return
|
bsw@212
|
7 end
|
bsw@212
|
8
|
bsw@212
|
9 areas:load("membership_for_member", { member_id = app.session.member_id}, "membership")
|
bsw@212
|
10
|
bsw@212
|
11 ui.box{ class = "areas", row_count = #areas + 1, content = function()
|
bsw@211
|
12 if head_content then
|
bsw@212
|
13 ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
|
bsw@212
|
14 ui.link{ content = head_content, module = "lf2", view = "index" }
|
bsw@212
|
15 end } end }
|
bsw@211
|
16 end
|
bsw@211
|
17
|
bsw@211
|
18 for i, area in ipairs(areas) do
|
bsw@211
|
19 local delegation = Delegation:by_pk(app.session.member_id, area.id)
|
bsw@211
|
20
|
bsw@212
|
21 local class = "area"
|
bsw@212
|
22 if (current_area_id and area.id == current_area_id)
|
bsw@212
|
23 or (not current_area_id and area.membership)
|
bsw@212
|
24 then
|
bsw@212
|
25 class = class .. " active"
|
bsw@212
|
26 end
|
bsw@211
|
27 ui.box_row{
|
bsw@212
|
28 class = class,
|
bsw@211
|
29 content = function()
|
bsw@211
|
30 ui.box_col{ class = "name", content = function()
|
bsw@211
|
31 if delegation then
|
bsw@211
|
32 execute.view{ module = "lf2", view = "_avatars", params = { members = { delegation.trustee }, size = "small" } }
|
bsw@211
|
33 end
|
bsw@211
|
34 ui.link{ module = "lf2", view = "area", id = area.id, text = area.name }
|
bsw@211
|
35 end }
|
bsw@211
|
36 end
|
bsw@211
|
37 }
|
bsw@211
|
38
|
bsw@211
|
39 end
|
bsw@211
|
40
|
bsw@212
|
41 end }
|