liquid_feedback_frontend

view app/main/member/_show_thumb.lua @ 945:b865f87ea810

Work on robustification of JavaScript voting
author jbe
date Thu Nov 08 13:17:37 2012 +0100 (2012-11-08)
parents ea3d3757ddc3
children 701a5cf6b067
line source
1 local initiator = param.get("initiator", "table")
2 local member = param.get("member", "table")
4 local issue = param.get("issue", "table")
5 local initiative = param.get("initiative", "table")
6 local trustee = param.get("trustee", "table")
8 local name_html
9 if member.name_highlighted then
10 name_html = encode.highlight(member.name_highlighted)
11 else
12 name_html = encode.html(member.name)
13 end
15 local container_class = "member_thumb"
16 if initiator and member.accepted ~= true then
17 container_class = container_class .. " not_accepted"
18 end
20 if member.is_informed == false then
21 container_class = container_class .. " not_informed"
22 end
24 local in_delegation_chain = false
25 if member.delegate_member_ids then
26 for member_id in member.delegate_member_ids:gmatch("(%w+)") do
27 if tonumber(member_id) == member.id then
28 in_delegation_chain = true
29 end
30 end
31 end
33 if in_delegation_chain or ((issue or initiative) and member.id == app.session.member_id) then
34 container_class = container_class .. " in_delegation_chain"
35 end
37 ui.container{
38 attr = { class = container_class },
39 content = function()
40 ui.container{
41 attr = { class = "flags" },
42 content = function()
44 if not member.active then
45 local text = _"inactive"
46 ui.tag{ content = text }
47 ui.image{
48 attr = { alt = text, title = text },
49 static = "icons/16/cross.png"
50 }
51 end
53 if member.grade then
54 ui.link{
55 module = "vote",
56 view = "list",
57 params = {
58 issue_id = initiative.issue.id,
59 member_id = member.id,
60 },
61 content = function()
62 if (member.voter_comment) then
63 ui.image{
64 attr = {
65 alt = _"Voting comment available",
66 title = _"Voting comment available"
67 },
68 static = "icons/16/comment.png"
69 }
70 end
72 if member.grade > 0 then
73 ui.image{
74 attr = {
75 alt = _"Voted yes",
76 title = _"Voted yes"
77 },
78 static = "icons/16/thumb_up_green.png"
79 }
80 elseif member.grade < 0 then
81 ui.image{
82 attr = {
83 alt = _"Voted no",
84 title = _"Voted no"
85 },
86 static = "icons/16/thumb_down_red.png"
87 }
88 else
89 ui.image{
90 attr = {
91 alt = _"Abstention",
92 title = _"Abstention"
93 },
94 static = "icons/16/bullet_yellow.png"
95 }
96 end
97 end
98 }
99 end
101 local weight = 0
102 if member.weight then
103 weight = member.weight
104 end
105 if member.voter_weight then
106 weight = member.voter_weight
107 end
108 if (issue or initiative) and weight > 1 then
109 local module
110 if issue then
111 module = "interest"
112 elseif initiative then
113 if member.voter_weight then
114 module = "vote"
115 else
116 module = "supporter"
117 end
118 end
119 ui.link{
120 attr = {
121 class = in_delegation_chain and "in_delegation_chain" or nil,
122 title = _"Number of incoming delegations, follow link to see more details"
123 },
124 content = _("+ #{weight}", { weight = weight - 1 }),
125 module = module,
126 view = "show_incoming",
127 params = {
128 member_id = member.id,
129 initiative_id = initiative and initiative.id or nil,
130 issue_id = issue and issue.id or nil
131 }
132 }
133 end
135 if initiator and initiator.accepted then
136 if member.accepted == nil then
137 slot.put(_"Invited")
138 elseif member.accepted == false then
139 slot.put(_"Rejected")
140 end
141 end
143 if member.is_informed == false then
144 local text = _"Member has not approved latest draft"
145 ui.image{
146 attr = { alt = text, title = text },
147 static = "icons/16/help_yellow.png"
148 }
149 end
151 end
152 }
154 ui.link{
155 attr = { title = _"Show member" },
156 module = "member",
157 view = "show",
158 id = member.id,
159 content = function()
160 execute.view{
161 module = "member_image",
162 view = "_show",
163 params = {
164 member = member,
165 image_type = "avatar",
166 show_dummy = true
167 }
168 }
169 ui.container{
170 attr = { class = "member_name" },
171 content = function() slot.put(name_html) end
172 }
173 end
174 }
175 end
176 }

Impressum / About Us