liquid_feedback_frontend

view app/main/issue/_show.lua @ 715:21ae6ff8629a

Optical improvements
author bsw
date Wed Jun 27 01:56:07 2012 +0200 (2012-06-27)
parents e9cf53cd5954
children fda70d12e695
line source
1 local issue = param.get("issue", "table")
2 local initiative_limit = param.get("initiative_limit", atom.integer)
3 local for_listing = param.get("for_listing", atom.boolean)
4 local for_initiative = param.get("for_initiative", "table")
5 local for_initiative_id = for_initiative and for_initiative.id or nil
7 local direct_voter
8 if app.session.member_id then
9 direct_voter = issue.member_info.direct_voted
10 end
12 local voteable = app.session.member_id and issue.state == 'voting' and
13 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
15 local vote_link_text = direct_voter and _"Change vote" or _"Vote now"
18 local class = "issue"
19 if issue.is_interested then
20 class = class .. " interested"
21 elseif issue.is_interested_by_delegation_to_member_id then
22 class = class .. " interested_by_delegation"
23 end
25 ui.container{ attr = { class = class }, content = function()
27 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
29 if for_listing then
30 ui.container{ attr = { class = "content" }, content = function()
31 ui.link{
32 module = "unit", view = "show", id = issue.area.unit_id,
33 attr = { class = "unit_link" }, text = issue.area.unit.name
34 }
35 slot.put(" ")
36 ui.link{
37 module = "area", view = "show", id = issue.area_id,
38 attr = { class = "area_link" }, text = issue.area.name
39 }
40 end }
41 end
43 ui.container{ attr = { class = "title" }, content = function()
45 ui.link{
46 attr = { class = "issue_id" },
47 text = _("#{policy_name} ##{issue_id}", {
48 policy_name = issue.policy.name,
49 issue_id = issue.id
50 }),
51 module = "issue",
52 view = "show",
53 id = issue.id
54 }
55 end }
57 ui.tag{
58 attr = { class = "content issue_policy_info" },
59 tag = "div",
60 content = function()
62 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
64 if issue.state_time_left then
65 slot.put(" · ")
66 if issue.state_time_left:sub(1,1) == "-" then
67 if issue.state == "accepted" then
68 ui.tag{ content = _("Discussion starts soon") }
69 elseif issue.state == "discussion" then
70 ui.tag{ content = _("Verification starts soon") }
71 elseif issue.state == "frozen" then
72 ui.tag{ content = _("Voting starts soon") }
73 elseif issue.state == "voting" then
74 ui.tag{ content = _("Counting starts soon") }
75 end
76 else
77 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
78 end
79 end
81 end
82 }
84 local links = {}
86 if voteable then
87 links[#links+1] ={
88 content = vote_link_text,
89 module = "vote",
90 view = "list",
91 params = { issue_id = issue.id }
92 }
93 end
95 if app.session.member_id then
97 if issue.member_info.own_participation then
98 if issue.closed then
99 links[#links+1] = { content = _"You were interested" }
100 else
101 links[#links+1] = { content = _"You are interested" }
102 end
103 end
105 if not issue.closed and not issue.fully_frozen then
106 if issue.member_info.own_participation then
107 links[#links+1] = {
108 in_brackets = true,
109 text = _"Withdraw",
110 module = "interest",
111 action = "update",
112 params = { issue_id = issue.id, delete = true },
113 routing = {
114 default = {
115 mode = "redirect",
116 module = request.get_module(),
117 view = request.get_view(),
118 id = param.get_id_cgi(),
119 params = param.get_all_cgi()
120 }
121 }
122 }
123 elseif app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
124 links[#links+1] = {
125 text = _"Add my interest",
126 module = "interest",
127 action = "update",
128 params = { issue_id = issue.id },
129 routing = {
130 default = {
131 mode = "redirect",
132 module = request.get_module(),
133 view = request.get_view(),
134 id = param.get_id_cgi(),
135 params = param.get_all_cgi()
136 }
137 }
138 }
139 end
140 end
141 end
143 if not issue.closed and app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
144 if issue.member_info.own_delegation_scope ~= "issue" then
145 links[#links+1] = { text = _"Delegate issue", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
146 else
147 links[#links+1] = { text = _"Change issue delegation", module = "delegation", view = "show", params = { issue_id = issue.id, initiative_id = for_initiative_id } }
148 end
149 end
151 if config.issue_discussion_url_func then
152 local url = config.issue_discussion_url_func(issue)
153 links[#links+1] = {
154 attr = { target = "_blank" },
155 external = url,
156 content = _"Discussion on issue"
157 }
158 end
160 if config.etherpad and app.session.member then
161 links[#links+1] = {
162 attr = { target = "_blank" },
163 external = issue.etherpad_url,
164 content = _"Issue pad"
165 }
166 end
169 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
170 if not issue.fully_frozen and not issue.closed then
171 links[#links+1] = {
172 attr = { class = "action" },
173 text = _"Create alternative initiative",
174 module = "initiative",
175 view = "new",
176 params = { issue_id = issue.id }
177 }
178 end
179 end
181 ui.container{ attr = { class = "content actions" }, content = function()
182 for i, link in ipairs(links) do
183 if link.in_brackets then
184 slot.put(" (")
185 elseif i > 1 then
186 slot.put(" · ")
187 end
188 if link.module or link.external then
189 ui.link(link)
190 else
191 ui.tag(link)
192 end
193 if link.in_brackets then
194 slot.put(")")
195 end
196 end
197 end }
199 if not for_listing then
200 if issue.state == "cancelled" then
201 local policy = issue.policy
202 ui.container{
203 attr = { class = "not_admitted_info" },
204 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
205 }
206 end
207 end
209 ui.container{ attr = { class = "initiative_list content" }, content = function()
211 local initiatives_selector = issue:get_reference_selector("initiatives")
212 local highlight_string = param.get("highlight_string")
213 if highlight_string then
214 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
215 end
216 execute.view{
217 module = "initiative",
218 view = "_list",
219 params = {
220 issue = issue,
221 initiatives_selector = initiatives_selector,
222 highlight_initiative = for_initiative,
223 highlight_string = highlight_string,
224 no_sort = true,
225 limit = (for_listing or for_initiative) and 5 or nil,
226 for_member = for_member
227 }
228 }
229 end }
230 end }

Impressum / About Us