liquid_feedback_frontend

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

Impressum / About Us