liquid_feedback_frontend
diff app/main/lf2/_sidebar_issue.lua @ 211:4993b71b383f
First checkin of lf2 (frontend second generation) prototype
| author | bsw |
|---|---|
| date | Wed Mar 02 20:06:26 2011 +0100 (2011-03-02) |
| parents | |
| children | 3e4ad069847a |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/lf2/_sidebar_issue.lua Wed Mar 02 20:06:26 2011 +0100 1.3 @@ -0,0 +1,177 @@ 1.4 +local issue = param.get("issue", "table") 1.5 + 1.6 +local initiatives = issue.initiatives 1.7 + 1.8 +local interested_members_selector = Member:new_selector() 1.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 }) 1.10 + :add_field("dis.weight", "weight") 1.11 + :add_order_by("dis.weight DESC") 1.12 +local interested_members = interested_members_selector:exec() 1.13 + 1.14 +local interest = issue.interest 1.15 + 1.16 +local delegations = issue.delegations 1.17 + 1.18 +local trustees = Member:new_selector() 1.19 + :add_field("delegation_chain.*") 1.20 + :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id") 1.21 + :add_order_by("index") 1.22 + :exec() 1.23 + 1.24 +local global_delegation 1.25 +local area_delegation 1.26 +local issue_delegation 1.27 + 1.28 +for i, delegation in ipairs(issue.delegations) do 1.29 + if delegation.scope == "global" then global_delegation = delegation 1.30 + elseif delegation.scope == "area" then area_delegation = delegation 1.31 + elseif delegation.scope == "issue" then issue_delegation = delegation 1.32 + end 1.33 +end 1.34 + 1.35 +local delegation = issue_delegation or area_delegation or global_delegation 1.36 + 1.37 +local delegating_interest = issue.delegating_interest 1.38 + 1.39 +ui.box{ class = "issue", content = function() 1.40 + 1.41 + ui.box_row{ class = "issue_id head", content = function() ui.box_col{ content = function() 1.42 + ui.link{ 1.43 + module = "lf2", view = "issue", id = issue.id, 1.44 + content = _("Issue ##{id}", { id = issue.id }) 1.45 + } 1.46 + end } end } 1.47 + 1.48 + ui.box_row{ class = "unit_name", content = function() ui.box_col{ content = function() 1.49 + ui.link{ 1.50 + module = "lf2", view = "unit", id = 1, 1.51 + content = "DE / Berlin / Friedrichshain-Kreuzberg" 1.52 + } 1.53 + end } end } 1.54 + 1.55 + ui.box_row{ class = "area_name", content = function() ui.box_col{ content = function() 1.56 + ui.link{ 1.57 + module = "lf2", view = "area", id = issue.area_id, 1.58 + content = issue.area.name 1.59 + } 1.60 + end } end } 1.61 + 1.62 + ui.box_row{ class = "policy_name", content = function() ui.box_col{ content = function() 1.63 + ui.link{ 1.64 + module = "lf2", view = "policy", id = issue.policy_id, 1.65 + content = issue.policy.name 1.66 + } 1.67 + end } end } 1.68 + 1.69 + ui.box_row{ class = "time_left", content = function() 1.70 + 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 }) } 1.71 + end } 1.72 + 1.73 + ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function() 1.74 + if interest then 1.75 + ui.image{ static = "lf2/icon_star.png" } 1.76 + if issue.closed then 1.77 + slot.put(" ", _"You were interested in this issue") 1.78 + else 1.79 + slot.put(" ", _"You are interested in this issue") 1.80 + end 1.81 + else 1.82 + ui.image{ static = "lf2/icon_star_grey.png" } 1.83 + slot.put(_"You are not interested in this issue") 1.84 + end 1.85 + 1.86 + if issue.closed then 1.87 + ui.container{ attr = { class = "hoverbutton noaction"}, content = function() 1.88 + ui.container{ attr = { class = "content"}, content = function() 1.89 + slot.put(" ", encode.html(_"This issue is closed")) 1.90 + end } 1.91 + end } 1.92 + elseif issue.fully_frozen then 1.93 + ui.container{ attr = { class = "hoverbutton noaction"}, content = function() 1.94 + ui.container{ attr = { class = "content"}, content = function() 1.95 + slot.put(" ", encode.html(_"This issue is in voting")) 1.96 + end } 1.97 + end } 1.98 + else 1.99 + if interest then 1.100 + ui.link{ 1.101 + module = "interest", action = "update", params = { issue_id = issue.id, delete = true }, 1.102 + routing = { default = { 1.103 + mode = "redirect", module = "lf2", view = "issue", id = issue.id 1.104 + } }, 1.105 + attr = { class = "hoverbutton red"}, 1.106 + content = function() 1.107 + ui.container{ attr = { class = "content"}, content = function() 1.108 + ui.image{ static = "lf2/icon_star_crossed.png" } 1.109 + slot.put(" ", encode.html(_"Remove my interest")) 1.110 + end } 1.111 + end 1.112 + } 1.113 + 1.114 + else 1.115 + ui.link{ 1.116 + module = "interest", action = "update", params = { issue_id = issue.id }, 1.117 + routing = { default = { 1.118 + mode = "redirect", module = "lf2", view = "issue", id = issue.id 1.119 + } }, 1.120 + attr = { class = "hoverbutton green"}, 1.121 + content = function() 1.122 + ui.container{ attr = { class = "content"}, content = function() 1.123 + ui.image{ static = "lf2/icon_star.png" } 1.124 + slot.put(" ", encode.html(_"Add my interest")) 1.125 + end 1.126 + } 1.127 + end } 1.128 + 1.129 + end 1.130 + end 1.131 + end } end } 1.132 + 1.133 + ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function() 1.134 + if delegation then 1.135 + if delegation.issue_id then 1.136 + slot.put(encode.html(_"You have delegated this issue")) 1.137 + elseif delegation.area_id then 1.138 + slot.put(encode.html(_"You have delegated this area")) 1.139 + elseif delegation then 1.140 + slot.put(encode.html(_"You have delegated globally")) 1.141 + end 1.142 + else 1.143 + slot.put(encode.html(_"No delegation active")) 1.144 + end 1.145 + 1.146 + if issue.closed then 1.147 + ui.container{ attr = { class = "hoverbutton noaction"}, content = function() 1.148 + ui.container{ attr = { class = "content"}, content = function() 1.149 + slot.put(" ", encode.html(_"This issue is closed")) 1.150 + end } 1.151 + end } 1.152 + else 1.153 + if delegation then 1.154 + ui.link{ attr = { class = "hoverbutton red"}, content = function() 1.155 + ui.container{ attr = { class = "content"}, content = function() 1.156 + ui.image{ static = "lf2/icon_delegation.png" } 1.157 + slot.put(" ", encode.html(_"Change delegation...")) 1.158 + end } 1.159 + end } 1.160 + 1.161 + else 1.162 + ui.link{ attr = { class = "hoverbutton green"}, content = function() 1.163 + ui.container{ attr = { class = "content"}, content = function() 1.164 + ui.image{ static = "lf2/icon_delegation.png" } 1.165 + slot.put(" ", encode.html(_"Delegate issue")) 1.166 + end } 1.167 + end } 1.168 + 1.169 + end 1.170 + end 1.171 + 1.172 + end } end } 1.173 + 1.174 + if delegation then 1.175 + ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function() 1.176 + execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } } 1.177 + end } end } 1.178 + end 1.179 + 1.180 +end }