liquid_feedback_frontend

view app/main/supporter/_show_box.lua @ 525:63d6549cc00b

Delegation chain preview improved, better visualisation of current context, code cleanup
author bsw
date Fri May 18 19:07:07 2012 +0200 (2012-05-18)
parents abebe5e9ff78
children 5ca9de94cb13
line source
1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
3 -- TODO performance
4 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
6 local initiative = param.get("initiative", "table")
7 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
9 local partial = {
10 routing = {
11 default = {
12 mode = "redirect",
13 module = "initiative",
14 view = "show_support",
15 id = initiative.id
16 }
17 }
18 }
20 local routing = {
21 default = {
22 mode = "redirect",
23 module = request.get_module(),
24 view = request.get_view(),
25 id = param.get_id_cgi(),
26 params = param.get_all_cgi()
27 }
28 }
30 if not initiative.issue.fully_frozen and not initiative.issue.closed then
31 if supporter then
32 if not supporter:has_critical_opinion() then
33 ui.tag{ content = function()
34 ui.image{
35 static = "icons/16/thumb_up_green.png"
36 }
37 slot.put(_"Your are supporter")
38 end }
39 else
40 ui.tag{ attr = { class = "potential_supporter" }, content = function()
41 ui.image{
42 static = "icons/16/thumb_up.png"
43 }
44 slot.put(_"Your are potential supporter")
45 end }
46 end
47 slot.put(" (")
48 ui.link{
49 text = _"Withdraw",
50 module = "initiative",
51 action = "remove_support",
52 id = initiative.id,
53 routing = routing,
54 partial = partial
55 }
56 slot.put(") ")
57 elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
58 local params = param.get_all_cgi()
59 params.dyn = nil
60 ui.link{
61 text = _"Support this initiative",
62 module = "initiative",
63 action = "add_support",
64 id = initiative.id,
65 routing = routing,
66 partial = partial
67 }
68 slot.put(" ")
69 end
70 end
72 if app.session.member_id
73 and not initiative.issue.half_frozen
74 and not initiative.issue.closed
75 and not initiative.revoked
76 and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
77 then
78 ui.link{
79 content = function()
80 slot.put(_"Add suggestion")
81 end,
82 module = "suggestion",
83 view = "new",
84 params = {
85 initiative_id = initiative.id
86 }
87 }
88 slot.put(" ")
89 end
91 if (initiative.discussion_url and #initiative.discussion_url > 0) then
92 if initiative.discussion_url:find("^https?://") then
93 if initiative.discussion_url and #initiative.discussion_url > 0 then
94 ui.link{
95 attr = {
96 target = "_blank",
97 title = _"Discussion with initiators"
98 },
99 text = _"Discuss with initiators",
100 external = initiative.discussion_url
101 }
102 slot.put(" ")
103 end
104 else
105 slot.put(encode.html(initiative.discussion_url))
106 end
107 end
108 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
109 ui.link{
110 image = { static = "icons/16/comments.png" },
111 text = _"change discussion URL",
112 module = "initiative",
113 view = "edit",
114 id = initiative.id
115 }
116 slot.put(" ")
117 end
118 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
119 ui.link{
120 content = function()
121 ui.image{ static = "icons/16/script_add.png" }
122 slot.put(_"Edit draft")
123 end,
124 module = "draft",
125 view = "new",
126 params = { initiative_id = initiative.id }
127 }
128 slot.put(" ")
129 end
131 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
132 ui.link{
133 content = function()
134 ui.image{ static = "icons/16/script_delete.png" }
135 slot.put(_"Revoke initiative")
136 end,
137 module = "initiative",
138 view = "revoke",
139 id = initiative.id
140 }
141 slot.put(" ")
142 end
144 if not initiative.issue.closed then
145 local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
146 if ignored_initiative then
147 ui.tag{
148 content = _"You have ignored this initiative"
149 }
150 ui.link{
151 text = _"Stop ignoring initiative",
152 module = "initiative",
153 action = "update_ignore",
154 id = initiative.id,
155 params = { delete = true },
156 routing = {
157 default = {
158 mode = "redirect",
159 module = request.get_module(),
160 view = request.get_view(),
161 id = param.get_id_cgi(),
162 params = param.get_all_cgi()
163 }
164 }
165 }
166 else
167 ui.link{
168 text = _"Ignore initiative",
169 module = "initiative",
170 action = "update_ignore",
171 id = initiative.id,
172 routing = {
173 default = {
174 mode = "redirect",
175 module = request.get_module(),
176 view = request.get_view(),
177 id = param.get_id_cgi(),
178 params = param.get_all_cgi()
179 }
180 }
181 }
182 end
183 end

Impressum / About Us