liquid_feedback_frontend

view app/main/index/_member_home.lua @ 558:18e8de7a2b6a

Show notifications on start page as ulli list with links instead of tabs
author bsw
date Tue Jun 19 21:20:46 2012 +0200 (2012-06-19)
parents
children b904fc12cc1a
line source
1 local member = param.get("member", "table")
2 local for_member = param.get("for_member", atom.boolean)
3 local filter_unit = param.get_all_cgi()["filter_unit"] or "personal"
6 execute.view{
7 module = "index", view = "_notifications"
8 }
11 ui.container{ attr = { class = "ui_filter_head" }, content = function()
13 ui.link{
14 attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil },
15 text = _"My units and areas",
16 module = "index", view = "index", params = { filter_unit = "personal" }
17 }
19 slot.put(" ")
21 ui.link{
22 attr = { class = filter_unit == "global" and "active" or nil },
23 text = _"All units",
24 module = "index", view = "index", params = { filter_unit = "global" }
25 }
26 end }
28 slot.put("<br />")
31 if filter_unit == "global" then
32 execute.view{ module = "unit", view = "_list" }
33 return
34 end
36 local units = Unit:new_selector():exec()
38 for i, unit in ipairs(units) do
39 local trustee_member = Member:new_selector()
40 :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
41 :optional_object_mode()
42 :exec()
44 local areas_selector = Area:new_selector()
45 :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
46 :add_where{ "area.unit_id = ?", unit.id }
47 :add_where{ "area.active" }
48 :add_order_by("area.member_weight DESC")
50 local area_count = areas_selector:count()
52 ui.container{ attr = { class = "member_area_list" }, content = function()
53 ui.container{ attr = { class = "xunit_head" }, content = function()
54 ui.link{
55 text = unit.name,
56 module = "unit", view = "show", id = unit.id
57 }
59 if trustee_member then
60 local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
61 ui.image{
62 attr = { class = "delegation_arrow", alt = text, title = text },
63 static = "delegation_arrow_24_horizontal.png"
64 }
65 execute.view{
66 module = "member_image",
67 view = "_show",
68 params = {
69 member = trustee_member,
70 image_type = "avatar",
71 show_dummy = true,
72 class = "micro_avatar",
73 popup_text = text
74 }
75 }
76 end
77 end }
79 if area_count > 0 then
80 execute.view{
81 module = "area", view = "_list",
82 params = { areas_selector = areas_selector, hide_membership = true }
83 }
84 elseif member:has_voting_right_for_unit_id(unit.id) then
85 if for_member then
86 ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
87 else
88 ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
89 end
90 end
91 local max_area_count = Area:new_selector()
92 :add_where{ "area.unit_id = ?", unit.id }
93 :add_where{ "area.active" }
94 :count()
95 local more_area_count = max_area_count - area_count
96 local delegated_count = Area:new_selector()
97 :add_where{ "area.unit_id = ?", unit.id }
98 :add_where{ "area.active" }
99 :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
100 :add_where{ "membership.member_id ISNULL" }
101 :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
102 :count()
103 if more_area_count > 0 then
104 slot.put("<br />")
105 ui.container{ attr = { class = "more_areas" }, content = function()
106 ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
107 end }
108 end
109 end }
111 end

Impressum / About Us