bsw@301: local unit_id = config.single_unit_id or param.get_id() bsw@301: bsw@301: local unit = Unit:by_id(unit_id) bsw@301: bsw@301: if not config.single_unit_id then bsw@301: slot.put_into("title", unit.name) bsw@301: else bsw@301: slot.put_into("title", encode.html(config.app_title)) bsw@301: end bsw@301: bsw@301: if config.single_unit_id and not app.session.member_id and config.motd_public then bsw@301: local help_text = config.motd_public bsw@301: ui.container{ bsw@301: attr = { class = "wiki motd" }, bsw@301: content = function() bsw@301: slot.put(format.wiki_text(help_text)) bsw@301: end bsw@301: } bsw@301: end bsw@301: bsw@301: util.help("unit.show", _"Unit") bsw@301: bsw@301: if app.session.member_id then bsw@301: execute.view{ bsw@301: module = "delegation", bsw@301: view = "_show_box", bsw@301: params = { unit_id = unit_id } bsw@301: } bsw@301: end bsw@301: bsw@301: bsw@301: local areas_selector = Area:build_selector{ active = true, unit_id = unit_id } bsw@301: areas_selector:add_order_by("member_weight DESC") bsw@301: bsw@301: local members_selector = Member:build_selector{ bsw@301: active = true, bsw@301: voting_right_for_unit_id = unit.id bsw@301: } bsw@301: bsw@301: local delegations_selector = Delegation:new_selector() bsw@301: :join("member", "truster", "truster.id = delegation.truster_id AND truster.active") bsw@302: :join("privilege", "truster_privilege", "truster_privilege.member_id = truster.id AND truster_privilege.unit_id = delegation.unit_id AND truster_privilege.voting_right") bsw@301: :join("member", "trustee", "trustee.id = delegation.trustee_id AND truster.active") bsw@302: :join("privilege", "trustee_privilege", "trustee_privilege.member_id = trustee.id AND trustee_privilege.unit_id = delegation.unit_id AND trustee_privilege.voting_right") bsw@301: :add_where{ "delegation.unit_id = ?", unit.id } bsw@301: bsw@301: local issues_selector = Issue:new_selector() bsw@301: :join("area", nil, "area.id = issue.area_id") bsw@301: :add_where{ "area.unit_id = ?", unit.id } bsw@301: bsw@301: bsw@301: local tabs = { bsw@301: module = "unit", bsw@301: view = "show", bsw@301: id = unit.id bsw@301: } bsw@301: bsw@301: tabs[#tabs+1] = { bsw@301: name = "areas", bsw@301: label = _"Areas", bsw@301: module = "area", bsw@301: view = "_list", bsw@301: params = { areas_selector = areas_selector } bsw@301: } bsw@301: bsw@301: tabs[#tabs+1] = { bsw@301: name = "issues", bsw@301: label = _"Issues", bsw@301: module = "issue", bsw@301: view = "_list", bsw@301: params = { issues_selector = issues_selector } bsw@301: } bsw@301: bsw@301: if app.session.member_id then bsw@301: tabs[#tabs+1] = { bsw@301: name = "members", bsw@301: label = _"Members", bsw@301: module = "member", bsw@301: view = "_list", bsw@301: params = { members_selector = members_selector } bsw@301: } bsw@301: bsw@301: tabs[#tabs+1] = { bsw@301: name = "delegations", bsw@301: label = _"Delegations", bsw@301: module = "delegation", bsw@301: view = "_list", bsw@301: params = { delegations_selector = delegations_selector } bsw@301: } bsw@301: end bsw@301: bsw@301: ui.tabs(tabs)