bsw@211: local areas = param.get("areas_selector", "table"):exec() bsw@212: local current_area_id = param.get("current_area_id", atom.integer) bsw@211: local head_content = param.get("head_content", "function") bsw@211: bsw@212: if #areas == 0 then bsw@212: return bsw@212: end bsw@212: bsw@212: areas:load("membership_for_member", { member_id = app.session.member_id}, "membership") bsw@212: bsw@212: ui.box{ class = "areas", row_count = #areas + 1, content = function() bsw@211: if head_content then bsw@212: ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function() bsw@212: ui.link{ content = head_content, module = "lf2", view = "index" } bsw@212: end } end } bsw@211: end bsw@211: bsw@211: for i, area in ipairs(areas) do bsw@211: local delegation = Delegation:by_pk(app.session.member_id, area.id) bsw@211: bsw@212: local class = "area" bsw@212: if (current_area_id and area.id == current_area_id) bsw@212: or (not current_area_id and area.membership) bsw@212: then bsw@212: class = class .. " active" bsw@212: end bsw@211: ui.box_row{ bsw@212: class = class, bsw@211: content = function() bsw@211: ui.box_col{ class = "name", content = function() bsw@211: if delegation then bsw@211: execute.view{ module = "lf2", view = "_avatars", params = { members = { delegation.trustee }, size = "small" } } bsw@211: end bsw@211: ui.link{ module = "lf2", view = "area", id = area.id, text = area.name } bsw@211: end } bsw@211: end bsw@211: } bsw@211: bsw@211: end bsw@211: bsw@212: end }