liquid_feedback_frontend

view app/main/issue/_show.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
children 4cee33ad5e16
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 end
153 ui.container{ attr = { class = "initiative_list" }, content = function()
155 local initiatives_selector = issue:get_reference_selector("initiatives")
156 local highlight_string = param.get("highlight_string")
157 if highlight_string then
158 initiatives_selector:add_field( {'"highlight"("initiative"."name", ?)', highlight_string }, "name_highlighted")
159 end
160 execute.view{
161 module = "initiative",
162 view = "_list",
163 params = {
164 issue = issue,
165 initiatives_selector = initiatives_selector,
166 highlight_string = highlight_string,
167 per_page = initiative_limit,
168 no_sort = true,
169 limit = initiative_limit,
170 for_member = for_member
171 }
172 }
173 end }
174 end }

Impressum / About Us