liquid_feedback_frontend

view app/main/lf2/_sidebar_issue.lua @ 215:1dab81353eb1

More enhancements for second generation frontend
author bsw
date Sat Mar 05 15:34:17 2011 +0100 (2011-03-05)
parents acf92c2d33f4
children 4f6e6b213fb8
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 head2", 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 head2", 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 head2", 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 head2", 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 head", content = function()
55 ui.box_col{ content = issue.closed and _("Closed since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) }
56 end }
58 ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
59 if interest then
60 ui.image{ static = "lf2/icon_star.png" }
61 if issue.closed then
62 slot.put(" ", _"You were interested in this issue")
63 else
64 slot.put(" ", _"You are interested in this issue")
65 end
66 else
67 if not issue.closed and not issue.fully_frozen then
68 ui.image{ static = "lf2/icon_star_grey.png" }
69 end
70 slot.put(" ", _"You are not interested in this issue")
71 end
73 if issue.closed then
74 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
75 ui.container{ attr = { class = "content"}, content = function()
76 slot.put(" ", encode.html(_"This issue is closed"))
77 end }
78 end }
79 elseif issue.fully_frozen then
80 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
81 ui.container{ attr = { class = "content"}, content = function()
82 slot.put(" ", encode.html(_"This issue is in voting"))
83 end }
84 end }
85 else
86 if interest then
87 ui.link{
88 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
89 routing = { default = {
90 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
91 } },
92 attr = { class = "hoverbutton red"},
93 content = function()
94 ui.container{ attr = { class = "content"}, content = function()
95 ui.image{ static = "lf2/icon_star_crossed.png" }
96 slot.put(" ", encode.html(_"Remove my interest"))
97 end }
98 end
99 }
101 else
102 ui.link{
103 module = "interest", action = "update", params = { issue_id = issue.id },
104 routing = { default = {
105 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
106 } },
107 attr = { class = "hoverbutton green"},
108 content = function()
109 ui.container{ attr = { class = "content"}, content = function()
110 ui.image{ static = "lf2/icon_star.png" }
111 slot.put(" ", encode.html(_"Add my interest"))
112 end
113 }
114 end }
116 end
117 end
118 end } end }
120 ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
121 if trustees[1].scope_out then
122 ui.image{ static = "lf2/icon_delegation.png" }
123 slot.put(" ")
124 if trustees[1].disabled_out == false then
125 if trustees[1].scope_out == "issue" then
126 slot.put(encode.html(_"Issue is delegated"))
127 elseif trustees[1].scope_out == "area" then
128 slot.put(encode.html(_"Area is delegated"))
129 elseif trustees[1].scope_out == "global" then
130 slot.put(encode.html(_"Unit wide delegated"))
131 end
132 else
133 if trustees[1].scope_out == "issue" then
134 slot.put(encode.html(_"Issue delegation abandoned"))
135 elseif trustees[1].scope_out == "area" then
136 slot.put(encode.html(_"Area delegation abandoned"))
137 elseif trustees[1].scope_out == "global" then
138 slot.put(encode.html(_"Global delegation abandoned"))
139 end
140 end
141 else
142 slot.put(encode.html(_"No delegation active"))
143 end
145 if issue.closed then
146 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
147 ui.container{ attr = { class = "content"}, content = function()
148 slot.put(" ", encode.html(_"This issue is closed"))
149 end }
150 end }
151 elseif issue.fully_frozen then
152 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
153 ui.container{ attr = { class = "content"}, content = function()
154 slot.put(" ", encode.html(_"This issue is in voting"))
155 end }
156 end }
157 else
158 if #trustees > 1 and trustees[1].scope_out == "issue" then
159 ui.link{
160 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
161 attr = { class = "hoverbutton red"}, content = function()
162 ui.container{ attr = { class = "content"}, content = function()
163 slot.put(" ", encode.html(_"Change issue delegation"))
164 end }
165 end }
167 else
168 ui.link{
169 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
170 attr = { class = "hoverbutton green"}, content = function()
171 ui.container{ attr = { class = "content"}, content = function()
172 slot.put(" ", encode.html(_"Set issue delegation"))
174 end }
175 end }
177 end
178 end
180 end } end }
182 if #trustees > 1 then
183 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
184 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
185 end } end }
186 end
188 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Initiatives in this issue" } end }
189 ui.box_row{ class = "initiatives last", content = function()
190 ui.box_col{ class = "scrolled", content = function()
191 execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = alternative_initiatives, current_initiative_id = initiative_id } }
192 end }
193 end }
196 end }

Impressum / About Us