liquid_feedback_frontend

view app/main/lf2/_sidebar_issue.lua @ 216:4f6e6b213fb8

Cleanup on second generation frontend code and stylesheet
author bsw
date Mon Mar 07 12:15:22 2011 +0100 (2011-03-07)
parents 1dab81353eb1
children 73dbc9e2bfd4
line source
1 local issue = param.get("issue", "table")
2 local initiative_id = param.get("initiative_id", atom.integer)
4 local alternative_initiatives = param.get("alternative_initiatives", "table")
6 local initiatives = issue.initiatives
8 local interested_members_selector = Member:new_selector()
9 :join("direct_interest_snapshot", "dis", { "dis.issue_id = ? AND dis.member_id = member.id and dis.event = (select latest_snapshot_event from issue where id = ?)", issue.id, issue.id })
10 :add_field("dis.weight", "weight")
11 :add_order_by("dis.weight DESC")
12 local interested_members = interested_members_selector:exec()
14 local interest = issue.interest
16 local trustees = Member:new_selector()
17 :add_field("delegation_chain.*")
18 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
19 :add_order_by("index")
20 :exec()
22 local delegating_interest = issue.delegating_interest
24 ui.box{ class = "issue", content = function()
26 ui.box_row{ class = "unit_name head2x", content = function() ui.box_col{ content = function()
27 ui.link{
28 module = "lf2", view = "index", id = 1,
29 content = "DE / Berlin / Friedrichshain-Kreuzberg"
30 }
31 end } end }
33 ui.box_row{ class = "area_name head2x", content = function() ui.box_col{ content = function()
34 ui.link{
35 module = "lf2", view = "area", id = issue.area_id,
36 content = issue.area.name
37 }
38 end } end }
40 ui.box_row{ class = "issue_id subhead", content = function() ui.box_col{ class = "head", content = function()
41 ui.link{
42 module = "lf2", view = "issue", id = issue.id,
43 content = _("Issue ##{id}", { id = issue.id })
44 }
45 end } end }
47 ui.box_row{ class = "policy_name", content = function() ui.box_col{ content = function()
48 ui.link{
49 module = "lf2", view = "policy", id = issue.policy_id,
50 content = issue.policy.name
51 }
52 end } end }
54 ui.box_row{ class = "time_left", content = function()
55 ui.box_col{ class = "left", content = function()
56 ui.tag{ content = issue.state_name }
57 slot.put(" · ")
58 ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) }
59 end }
60 end }
62 ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
63 if interest then
64 ui.image{ static = "lf2/icon_star.png" }
65 if issue.closed then
66 slot.put(" ", _"You were interested in this issue")
67 else
68 slot.put(" ", _"You are interested in this issue")
69 end
70 else
71 if not issue.closed and not issue.fully_frozen then
72 ui.image{ static = "lf2/icon_star_grey.png" }
73 end
74 slot.put(" ", _"You are not interested in this issue")
75 end
77 if issue.closed then
78 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
79 ui.container{ attr = { class = "content"}, content = function()
80 slot.put(" ", encode.html(_"This issue is closed"))
81 end }
82 end }
83 elseif issue.fully_frozen then
84 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
85 ui.container{ attr = { class = "content"}, content = function()
86 slot.put(" ", encode.html(_"This issue is in voting"))
87 end }
88 end }
89 else
90 if interest then
91 ui.link{
92 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
93 routing = { default = {
94 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
95 } },
96 attr = { class = "hoverbutton red"},
97 content = function()
98 ui.container{ attr = { class = "content"}, content = function()
99 ui.image{ static = "lf2/icon_star_crossed.png" }
100 slot.put(" ", encode.html(_"Remove my interest"))
101 end }
102 end
103 }
105 else
106 ui.link{
107 module = "interest", action = "update", params = { issue_id = issue.id },
108 routing = { default = {
109 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
110 } },
111 attr = { class = "hoverbutton green"},
112 content = function()
113 ui.container{ attr = { class = "content"}, content = function()
114 ui.image{ static = "lf2/icon_star.png" }
115 slot.put(" ", encode.html(_"Add my interest"))
116 end
117 }
118 end }
120 end
121 end
122 end } end }
124 ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
125 if trustees[1].scope_out then
126 ui.image{ static = "lf2/icon_delegation.png" }
127 slot.put(" ")
128 if trustees[1].disabled_out == false then
129 if trustees[1].scope_out == "issue" then
130 slot.put(encode.html(_"Issue is delegated"))
131 elseif trustees[1].scope_out == "area" then
132 slot.put(encode.html(_"Area is delegated"))
133 elseif trustees[1].scope_out == "global" then
134 slot.put(encode.html(_"Unit wide delegated"))
135 end
136 else
137 if trustees[1].scope_out == "issue" then
138 slot.put(encode.html(_"Issue delegation abandoned"))
139 elseif trustees[1].scope_out == "area" then
140 slot.put(encode.html(_"Area delegation abandoned"))
141 elseif trustees[1].scope_out == "global" then
142 slot.put(encode.html(_"Global delegation abandoned"))
143 end
144 end
145 else
146 slot.put(encode.html(_"No delegation active"))
147 end
149 if issue.closed then
150 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
151 ui.container{ attr = { class = "content"}, content = function()
152 slot.put(" ", encode.html(_"This issue is closed"))
153 end }
154 end }
155 elseif issue.fully_frozen then
156 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
157 ui.container{ attr = { class = "content"}, content = function()
158 slot.put(" ", encode.html(_"This issue is in voting"))
159 end }
160 end }
161 else
162 if #trustees > 1 and trustees[1].scope_out == "issue" then
163 ui.link{
164 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
165 attr = { class = "hoverbutton red"}, content = function()
166 ui.container{ attr = { class = "content"}, content = function()
167 slot.put(" ", encode.html(_"Change issue delegation"))
168 end }
169 end }
171 else
172 ui.link{
173 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
174 attr = { class = "hoverbutton green"}, content = function()
175 ui.container{ attr = { class = "content"}, content = function()
176 slot.put(" ", encode.html(_"Set issue delegation"))
178 end }
179 end }
181 end
182 end
184 end } end }
186 if #trustees > 1 then
187 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
188 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
189 end } end }
190 end
192 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Initiatives" } end }
193 ui.box_row{ class = "initiatives last", content = function()
194 ui.box_col{ class = "scrolled", content = function()
195 execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = alternative_initiatives, current_initiative_id = initiative_id } }
196 end }
197 end }
200 end }

Impressum / About Us