liquid_feedback_frontend

annotate 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
rev   line source
bsw@211 1 local issue = param.get("issue", "table")
bsw@211 2
bsw@211 3 local initiatives = issue.initiatives
bsw@211 4
bsw@211 5 local interested_members_selector = Member:new_selector()
bsw@211 6 :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 })
bsw@211 7 :add_field("dis.weight", "weight")
bsw@211 8 :add_order_by("dis.weight DESC")
bsw@211 9 local interested_members = interested_members_selector:exec()
bsw@211 10
bsw@211 11 local interest = issue.interest
bsw@211 12
bsw@211 13 local delegations = issue.delegations
bsw@211 14
bsw@211 15 local trustees = Member:new_selector()
bsw@211 16 :add_field("delegation_chain.*")
bsw@211 17 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
bsw@211 18 :add_order_by("index")
bsw@211 19 :exec()
bsw@211 20
bsw@211 21 local global_delegation
bsw@211 22 local area_delegation
bsw@211 23 local issue_delegation
bsw@211 24
bsw@211 25 for i, delegation in ipairs(issue.delegations) do
bsw@211 26 if delegation.scope == "global" then global_delegation = delegation
bsw@211 27 elseif delegation.scope == "area" then area_delegation = delegation
bsw@211 28 elseif delegation.scope == "issue" then issue_delegation = delegation
bsw@211 29 end
bsw@211 30 end
bsw@211 31
bsw@211 32 local delegation = issue_delegation or area_delegation or global_delegation
bsw@211 33
bsw@211 34 local delegating_interest = issue.delegating_interest
bsw@211 35
bsw@211 36 ui.box{ class = "issue", content = function()
bsw@211 37
bsw@211 38 ui.box_row{ class = "issue_id head", content = function() ui.box_col{ content = function()
bsw@211 39 ui.link{
bsw@211 40 module = "lf2", view = "issue", id = issue.id,
bsw@211 41 content = _("Issue ##{id}", { id = issue.id })
bsw@211 42 }
bsw@211 43 end } end }
bsw@211 44
bsw@211 45 ui.box_row{ class = "unit_name", content = function() ui.box_col{ content = function()
bsw@211 46 ui.link{
bsw@211 47 module = "lf2", view = "unit", id = 1,
bsw@211 48 content = "DE / Berlin / Friedrichshain-Kreuzberg"
bsw@211 49 }
bsw@211 50 end } end }
bsw@211 51
bsw@211 52 ui.box_row{ class = "area_name", content = function() ui.box_col{ content = function()
bsw@211 53 ui.link{
bsw@211 54 module = "lf2", view = "area", id = issue.area_id,
bsw@211 55 content = issue.area.name
bsw@211 56 }
bsw@211 57 end } end }
bsw@211 58
bsw@211 59 ui.box_row{ class = "policy_name", content = function() ui.box_col{ content = function()
bsw@211 60 ui.link{
bsw@211 61 module = "lf2", view = "policy", id = issue.policy_id,
bsw@211 62 content = issue.policy.name
bsw@211 63 }
bsw@211 64 end } end }
bsw@211 65
bsw@211 66 ui.box_row{ class = "time_left", content = function()
bsw@211 67 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 }) }
bsw@211 68 end }
bsw@211 69
bsw@211 70 ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
bsw@211 71 if interest then
bsw@211 72 ui.image{ static = "lf2/icon_star.png" }
bsw@211 73 if issue.closed then
bsw@211 74 slot.put(" ", _"You were interested in this issue")
bsw@211 75 else
bsw@211 76 slot.put(" ", _"You are interested in this issue")
bsw@211 77 end
bsw@211 78 else
bsw@211 79 ui.image{ static = "lf2/icon_star_grey.png" }
bsw@211 80 slot.put(_"You are not interested in this issue")
bsw@211 81 end
bsw@211 82
bsw@211 83 if issue.closed then
bsw@211 84 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@211 85 ui.container{ attr = { class = "content"}, content = function()
bsw@211 86 slot.put(" ", encode.html(_"This issue is closed"))
bsw@211 87 end }
bsw@211 88 end }
bsw@211 89 elseif issue.fully_frozen then
bsw@211 90 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@211 91 ui.container{ attr = { class = "content"}, content = function()
bsw@211 92 slot.put(" ", encode.html(_"This issue is in voting"))
bsw@211 93 end }
bsw@211 94 end }
bsw@211 95 else
bsw@211 96 if interest then
bsw@211 97 ui.link{
bsw@211 98 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@211 99 routing = { default = {
bsw@211 100 mode = "redirect", module = "lf2", view = "issue", id = issue.id
bsw@211 101 } },
bsw@211 102 attr = { class = "hoverbutton red"},
bsw@211 103 content = function()
bsw@211 104 ui.container{ attr = { class = "content"}, content = function()
bsw@211 105 ui.image{ static = "lf2/icon_star_crossed.png" }
bsw@211 106 slot.put(" ", encode.html(_"Remove my interest"))
bsw@211 107 end }
bsw@211 108 end
bsw@211 109 }
bsw@211 110
bsw@211 111 else
bsw@211 112 ui.link{
bsw@211 113 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@211 114 routing = { default = {
bsw@211 115 mode = "redirect", module = "lf2", view = "issue", id = issue.id
bsw@211 116 } },
bsw@211 117 attr = { class = "hoverbutton green"},
bsw@211 118 content = function()
bsw@211 119 ui.container{ attr = { class = "content"}, content = function()
bsw@211 120 ui.image{ static = "lf2/icon_star.png" }
bsw@211 121 slot.put(" ", encode.html(_"Add my interest"))
bsw@211 122 end
bsw@211 123 }
bsw@211 124 end }
bsw@211 125
bsw@211 126 end
bsw@211 127 end
bsw@211 128 end } end }
bsw@211 129
bsw@211 130 ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
bsw@211 131 if delegation then
bsw@211 132 if delegation.issue_id then
bsw@211 133 slot.put(encode.html(_"You have delegated this issue"))
bsw@211 134 elseif delegation.area_id then
bsw@211 135 slot.put(encode.html(_"You have delegated this area"))
bsw@211 136 elseif delegation then
bsw@211 137 slot.put(encode.html(_"You have delegated globally"))
bsw@211 138 end
bsw@211 139 else
bsw@211 140 slot.put(encode.html(_"No delegation active"))
bsw@211 141 end
bsw@211 142
bsw@211 143 if issue.closed then
bsw@211 144 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@211 145 ui.container{ attr = { class = "content"}, content = function()
bsw@211 146 slot.put(" ", encode.html(_"This issue is closed"))
bsw@211 147 end }
bsw@211 148 end }
bsw@211 149 else
bsw@211 150 if delegation then
bsw@211 151 ui.link{ attr = { class = "hoverbutton red"}, content = function()
bsw@211 152 ui.container{ attr = { class = "content"}, content = function()
bsw@211 153 ui.image{ static = "lf2/icon_delegation.png" }
bsw@211 154 slot.put(" ", encode.html(_"Change delegation..."))
bsw@211 155 end }
bsw@211 156 end }
bsw@211 157
bsw@211 158 else
bsw@211 159 ui.link{ attr = { class = "hoverbutton green"}, content = function()
bsw@211 160 ui.container{ attr = { class = "content"}, content = function()
bsw@211 161 ui.image{ static = "lf2/icon_delegation.png" }
bsw@211 162 slot.put(" ", encode.html(_"Delegate issue"))
bsw@211 163 end }
bsw@211 164 end }
bsw@211 165
bsw@211 166 end
bsw@211 167 end
bsw@211 168
bsw@211 169 end } end }
bsw@211 170
bsw@211 171 if delegation then
bsw@211 172 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
bsw@211 173 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
bsw@211 174 end } end }
bsw@211 175 end
bsw@211 176
bsw@211 177 end }

Impressum / About Us