liquid_feedback_frontend
view app/main/issue/_show.lua @ 527:4cee33ad5e16
Completed support for config.public_access = "full"
author | bsw |
---|---|
date | Fri May 18 19:44:41 2012 +0200 (2012-05-18) |
parents | 63d6549cc00b |
children | 305329da1c75 |
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)
5 local direct_voter
6 if app.session.member_id then
7 direct_voter = DirectVoter:by_pk(issue.id, app.session.member.id)
8 end
10 local voteable = app.session.member_id and issue.state == 'voting' and
11 app.session.member:has_voting_right_for_unit_id(issue.area.unit_id)
13 local vote_link_text = direct_voter and _"Change vote" or "Vote now"
16 local class = "issue"
17 if issue.is_interested then
18 class = class .. " interested"
19 elseif issue.is_interested_by_delegation_to_member_id then
20 class = class .. " interested_by_delegation"
21 end
23 ui.container{ attr = { class = class }, content = function()
25 execute.view{ module = "delegation", view = "_info", params = { issue = issue } }
27 if for_listing then
28 ui.container{ attr = { class = "context" }, content = function()
29 ui.tag{ content = issue.area.unit.name }
30 slot.put(" · ")
31 ui.tag{ content = issue.area.name }
32 end }
33 end
34 ui.container{ attr = { class = "title" }, content = function()
36 ui.link{
37 attr = { class = "issue_id" },
38 text = _("#{policy_name} ##{issue_id}", {
39 policy_name = issue.policy.name,
40 issue_id = issue.id
41 }),
42 module = "issue",
43 view = "show",
44 id = issue.id
45 }
46 end }
48 ui.tag{
49 attr = { class = "content issue_policy_info" },
50 tag = "div",
51 content = function()
53 ui.tag{ attr = { class = "event_name" }, content = issue.state_name }
55 if issue.state_time_left then
56 slot.put(" · ")
57 if issue.state_time_left:sub(1,1) == "-" then
58 if issue.state == "new" then
59 ui.tag{ content = _("Discussion starts soon") }
60 elseif issue.state == "discussion" then
61 ui.tag{ content = _("Verification starts soon") }
62 elseif issue.state == "frozen" then
63 ui.tag{ content = _("Voting starts soon") }
64 elseif issue.state == "voting" then
65 ui.tag{ content = _("Counting starts soon") }
66 end
67 else
68 ui.tag{ content = _("#{time_left} left", { time_left = issue.state_time_left:gsub("days", _"days"):gsub("day", _"day") }) }
69 end
70 end
72 end
73 }
75 ui.container{
76 attr = { class = "content actions" }, content = function()
78 if voteable then
79 ui.link{
80 content = vote_link_text,
81 module = "vote",
82 view = "list",
83 params = { issue_id = issue.id }
84 }
85 slot.put(" · ")
86 end
88 if app.session.member_id then
89 execute.view{
90 module = "interest",
91 view = "_show_box",
92 params = { issue = issue, initiative = initiative }
93 }
94 slot.put(" · ")
95 end
97 if config.issue_discussion_url_func then
98 local url = config.issue_discussion_url_func(issue)
99 ui.link{
100 attr = { target = "_blank" },
101 external = url,
102 content = _"Discussion on issue"
103 }
104 slot.put(" · ")
105 end
107 if config.etherpad and app.session.member then
108 ui.link{
109 attr = { target = "_blank" },
110 external = issue.etherpad_url,
111 content = _"Issue pad"
112 }
113 slot.put(" · ")
114 end
117 if app.session.member_id and app.session.member:has_voting_right_for_unit_id(issue.area.unit_id) then
118 if not issue.fully_frozen and not issue.closed then
119 ui.link{
120 attr = { class = "action" },
121 text = _"Create alternative initiative",
122 module = "initiative",
123 view = "new",
124 params = { issue_id = issue.id }
125 }
126 end
127 end
129 end }
131 if not for_listing then
133 if voteable then
134 ui.container{
135 attr = { class = "voting_active_info" },
136 content = function()
137 slot.put(_"Voting for this issue is currently running!")
138 slot.put(" ")
139 if app.session.member_id then
140 ui.link{
141 content = vote_link_text,
142 module = "vote",
143 view = "list",
144 params = { issue_id = issue.id }
145 }
146 end
147 end
148 }
149 end
151 if issue.state == "cancelled" then
152 local policy = issue.policy
153 ui.container{
154 attr = { class = "not_admitted_info" },
155 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
156 }
157 end
159 end
161 ui.container{ attr = { class = "initiative_list" }, content = function()
163 local initiatives_selector = issue:get_reference_selector("initiatives")
164 local highlight_string = param.get("highlight_string")
165 if highlight_string then
166 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
167 end
168 execute.view{
169 module = "initiative",
170 view = "_list",
171 params = {
172 issue = issue,
173 initiatives_selector = initiatives_selector,
174 highlight_string = highlight_string,
175 per_page = initiative_limit,
176 no_sort = true,
177 limit = initiative_limit,
178 for_member = for_member
179 }
180 }
181 end }
182 end }