liquid_feedback_frontend

annotate 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
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@216 26 ui.box_row{ class = "unit_name head2x", 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@216 33 ui.box_row{ class = "area_name head2x", 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@216 40 ui.box_row{ class = "issue_id subhead", 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@216 47 ui.box_row{ class = "policy_name", 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@216 54 ui.box_row{ class = "time_left", content = function()
bsw@216 55 ui.box_col{ class = "left", content = function()
bsw@216 56 ui.tag{ content = issue.state_name }
bsw@216 57 slot.put(" · ")
bsw@216 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 }) }
bsw@216 59 end }
bsw@211 60 end }
bsw@211 61
bsw@211 62 ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
bsw@211 63 if interest then
bsw@211 64 ui.image{ static = "lf2/icon_star.png" }
bsw@211 65 if issue.closed then
bsw@211 66 slot.put(" ", _"You were interested in this issue")
bsw@211 67 else
bsw@211 68 slot.put(" ", _"You are interested in this issue")
bsw@211 69 end
bsw@211 70 else
bsw@213 71 if not issue.closed and not issue.fully_frozen then
bsw@213 72 ui.image{ static = "lf2/icon_star_grey.png" }
bsw@213 73 end
bsw@215 74 slot.put(" ", _"You are not interested in this issue")
bsw@211 75 end
bsw@211 76
bsw@211 77 if issue.closed then
bsw@211 78 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@211 79 ui.container{ attr = { class = "content"}, content = function()
bsw@211 80 slot.put(" ", encode.html(_"This issue is closed"))
bsw@211 81 end }
bsw@211 82 end }
bsw@211 83 elseif issue.fully_frozen 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 in voting"))
bsw@211 87 end }
bsw@211 88 end }
bsw@211 89 else
bsw@211 90 if interest then
bsw@211 91 ui.link{
bsw@211 92 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@211 93 routing = { default = {
bsw@213 94 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
bsw@211 95 } },
bsw@211 96 attr = { class = "hoverbutton red"},
bsw@211 97 content = function()
bsw@211 98 ui.container{ attr = { class = "content"}, content = function()
bsw@211 99 ui.image{ static = "lf2/icon_star_crossed.png" }
bsw@211 100 slot.put(" ", encode.html(_"Remove my interest"))
bsw@211 101 end }
bsw@211 102 end
bsw@211 103 }
bsw@211 104
bsw@211 105 else
bsw@211 106 ui.link{
bsw@211 107 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@211 108 routing = { default = {
bsw@213 109 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
bsw@211 110 } },
bsw@211 111 attr = { class = "hoverbutton green"},
bsw@211 112 content = function()
bsw@211 113 ui.container{ attr = { class = "content"}, content = function()
bsw@211 114 ui.image{ static = "lf2/icon_star.png" }
bsw@211 115 slot.put(" ", encode.html(_"Add my interest"))
bsw@211 116 end
bsw@211 117 }
bsw@211 118 end }
bsw@211 119
bsw@211 120 end
bsw@211 121 end
bsw@211 122 end } end }
bsw@211 123
bsw@211 124 ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
bsw@213 125 if trustees[1].scope_out then
bsw@215 126 ui.image{ static = "lf2/icon_delegation.png" }
bsw@215 127 slot.put(" ")
bsw@213 128 if trustees[1].disabled_out == false then
bsw@213 129 if trustees[1].scope_out == "issue" then
bsw@215 130 slot.put(encode.html(_"Issue is delegated"))
bsw@213 131 elseif trustees[1].scope_out == "area" then
bsw@215 132 slot.put(encode.html(_"Area is delegated"))
bsw@213 133 elseif trustees[1].scope_out == "global" then
bsw@215 134 slot.put(encode.html(_"Unit wide delegated"))
bsw@213 135 end
bsw@213 136 else
bsw@213 137 if trustees[1].scope_out == "issue" then
bsw@213 138 slot.put(encode.html(_"Issue delegation abandoned"))
bsw@213 139 elseif trustees[1].scope_out == "area" then
bsw@213 140 slot.put(encode.html(_"Area delegation abandoned"))
bsw@213 141 elseif trustees[1].scope_out == "global" then
bsw@213 142 slot.put(encode.html(_"Global delegation abandoned"))
bsw@213 143 end
bsw@211 144 end
bsw@211 145 else
bsw@211 146 slot.put(encode.html(_"No delegation active"))
bsw@211 147 end
bsw@211 148
bsw@211 149 if issue.closed then
bsw@211 150 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@211 151 ui.container{ attr = { class = "content"}, content = function()
bsw@211 152 slot.put(" ", encode.html(_"This issue is closed"))
bsw@211 153 end }
bsw@211 154 end }
bsw@215 155 elseif issue.fully_frozen then
bsw@215 156 ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
bsw@215 157 ui.container{ attr = { class = "content"}, content = function()
bsw@215 158 slot.put(" ", encode.html(_"This issue is in voting"))
bsw@215 159 end }
bsw@215 160 end }
bsw@211 161 else
bsw@215 162 if #trustees > 1 and trustees[1].scope_out == "issue" then
bsw@213 163 ui.link{
bsw@213 164 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
bsw@213 165 attr = { class = "hoverbutton red"}, content = function()
bsw@211 166 ui.container{ attr = { class = "content"}, content = function()
bsw@215 167 slot.put(" ", encode.html(_"Change issue delegation"))
bsw@211 168 end }
bsw@211 169 end }
bsw@211 170
bsw@211 171 else
bsw@213 172 ui.link{
bsw@213 173 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
bsw@213 174 attr = { class = "hoverbutton green"}, content = function()
bsw@211 175 ui.container{ attr = { class = "content"}, content = function()
bsw@215 176 slot.put(" ", encode.html(_"Set issue delegation"))
bsw@213 177
bsw@211 178 end }
bsw@211 179 end }
bsw@211 180
bsw@211 181 end
bsw@211 182 end
bsw@211 183
bsw@211 184 end } end }
bsw@213 185
bsw@213 186 if #trustees > 1 then
bsw@211 187 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
bsw@216 188 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
bsw@211 189 end } end }
bsw@211 190 end
bsw@211 191
bsw@216 192 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Initiatives" } end }
bsw@215 193 ui.box_row{ class = "initiatives last", content = function()
bsw@215 194 ui.box_col{ class = "scrolled", content = function()
bsw@215 195 execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = alternative_initiatives, current_initiative_id = initiative_id } }
bsw@215 196 end }
bsw@215 197 end }
bsw@215 198
bsw@215 199
bsw@211 200 end }

Impressum / About Us