liquid_feedback_frontend

annotate app/main/initiative/_show.lua @ 272:65a1f7a01e7b

More optical enhancements and repositioning of elements
author bsw
date Wed Feb 08 00:55:17 2012 +0100 (2012-02-08)
parents 1fdf1e607494
children 7196685f9dd7
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw/jbe@19 2 local initiator = param.get("initiator", "table")
bsw/jbe@19 3
bsw@272 4 local initiators_members_selector = initiative:get_reference_selector("initiating_members")
bsw@272 5 :add_field("initiator.accepted", "accepted")
bsw@272 6
bsw@272 7 if not (initiator and initiator.accepted) then
bsw@272 8 initiators_members_selector:add_where("initiator.accepted")
bsw@272 9 end
bsw@272 10
bsw@272 11 local initiators = initiators_members_selector:exec()
bsw@272 12
bsw@272 13 slot.select("initiative_head", function()
bsw@272 14
bsw@272 15 ui.container{
bsw@272 16 attr = { class = "initiative_name" },
bsw@272 17 content = _("Initiative i#{id}: #{name}", { id = initiative.id, name = initiative.name })
bsw@272 18 }
bsw@272 19 ui.tag{
bsw@272 20 attr = { class = "initiator_names" },
bsw@272 21 content = function()
bsw@272 22 ui.tag{ content = _"by" }
bsw@272 23 slot.put(" ")
bsw@272 24 for i, initiator in ipairs(initiators) do
bsw@272 25 if i == #initiators and i > 1 then
bsw@272 26 slot.put(" ", _"and", " ")
bsw@272 27 elseif i > 1 then
bsw@272 28 slot.put(", ")
bsw@272 29 end
bsw@272 30 ui.link{
bsw@272 31 text = initiator.name,
bsw@272 32 module = "member", view = "show", id = initiator.id
bsw@272 33 }
bsw@272 34 end
bsw@272 35 end
bsw@272 36 }
bsw@272 37
bsw@272 38 if initiator and initiator.accepted and not initiative.issue.fully_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@272 39 slot.put(" · ")
bsw@272 40 ui.link{
bsw@272 41 attr = { class = "action" },
bsw@272 42 content = function()
bsw@272 43 slot.put(_"Invite initiator")
bsw@272 44 end,
bsw@272 45 module = "initiative",
bsw@272 46 view = "add_initiator",
bsw@272 47 params = { initiative_id = initiative.id }
bsw@272 48 }
bsw@272 49 if #initiators > 1 then
bsw@272 50 slot.put(" · ")
bsw@272 51 ui.link{
bsw@272 52 content = function()
bsw@272 53 slot.put(_"Remove initiator")
bsw@272 54 end,
bsw@272 55 module = "initiative",
bsw@272 56 view = "remove_initiator",
bsw@272 57 params = { initiative_id = initiative.id }
bsw@272 58 }
bsw@272 59 end
bsw@272 60 end
bsw@272 61 if initiator and initiator.accepted == false then
bsw@272 62 slot.put(" · ")
bsw@272 63 ui.link{
bsw@272 64 text = _"Cancel refuse of invitation",
bsw@272 65 module = "initiative",
bsw@272 66 action = "remove_initiator",
bsw@272 67 params = {
bsw@272 68 initiative_id = initiative.id,
bsw@272 69 member_id = app.session.member.id
bsw@272 70 },
bsw@272 71 routing = {
bsw@272 72 ok = {
bsw@272 73 mode = "redirect",
bsw@272 74 module = "initiative",
bsw@272 75 view = "show",
bsw@272 76 id = initiative.id
bsw@272 77 }
bsw@272 78 }
bsw@272 79 }
bsw@272 80 end
bsw@272 81
bsw@272 82
bsw@272 83 end )
bsw@272 84
bsw/jbe@19 85 util.help("initiative.show")
bsw/jbe@19 86
bsw@272 87
bsw/jbe@19 88 if initiative.issue.ranks_available and initiative.admitted then
bsw/jbe@19 89 local class = initiative.rank == 1 and "admitted_info" or "not_admitted_info"
bsw/jbe@19 90 ui.container{
bsw/jbe@19 91 attr = { class = class },
bsw/jbe@19 92 content = function()
bsw/jbe@19 93 local max_value = initiative.issue.voter_count
bsw/jbe@19 94 slot.put(" ")
bsw/jbe@19 95 local positive_votes = initiative.positive_votes
bsw/jbe@19 96 local negative_votes = initiative.negative_votes
jorges@104 97 local sum_votes = initiative.positive_votes + initiative.negative_votes
poelzi@167 98 local function perc(votes, sum)
poelzi@167 99 if sum > 0 and votes > 0 then return " (" .. string.format( "%.f", votes * 100 / sum ) .. "%)" end
poelzi@167 100 return ""
poelzi@167 101 end
poelzi@167 102 slot.put(_"Yes" .. ": <b>" .. tostring(positive_votes) .. perc(positive_votes, sum_votes) .. "</b>")
bsw/jbe@19 103 slot.put(" &middot; ")
bsw/jbe@19 104 slot.put(_"Abstention" .. ": <b>" .. tostring(max_value - initiative.negative_votes - initiative.positive_votes) .. "</b>")
bsw/jbe@19 105 slot.put(" &middot; ")
poelzi@167 106 slot.put(_"No" .. ": <b>" .. tostring(initiative.negative_votes) .. perc(negative_votes, sum_votes) .. "</b>")
bsw/jbe@19 107 slot.put(" &middot; ")
bsw/jbe@19 108 slot.put("<b>")
bsw/jbe@19 109 if initiative.rank == 1 then
bsw/jbe@19 110 slot.put(_"Approved")
bsw/jbe@19 111 elseif initiative.rank then
bsw/jbe@19 112 slot.put(_("Not approved (rank #{rank})", { rank = initiative.rank }))
bsw@24 113 else
bsw@24 114 slot.put(_"Not approved")
bsw/jbe@19 115 end
bsw/jbe@19 116 slot.put("</b>")
bsw/jbe@19 117 end
bsw/jbe@19 118 }
bsw/jbe@19 119 end
bsw/jbe@19 120
bsw/jbe@19 121 if initiative.admitted == false then
bsw/jbe@19 122 local policy = initiative.issue.policy
bsw/jbe@19 123 ui.container{
bsw/jbe@19 124 attr = { class = "not_admitted_info" },
bsw/jbe@19 125 content = _("This initiative has not been admitted! It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.initiative_quorum_num / policy.initiative_quorum_den) })
bsw/jbe@19 126 }
bsw/jbe@19 127 end
bsw/jbe@19 128
bsw/jbe@19 129 local web20 = config.user_tab_mode == "accordeon"
bsw/jbe@19 130 or config.user_tab_mode == "accordeon_first_expanded"
bsw/jbe@19 131 or config.user_tab_mode == "accordeon_all_expanded"
bsw/jbe@19 132
bsw/jbe@19 133 if not web20 and initiative.issue.state == "cancelled" then
bsw/jbe@19 134 local policy = initiative.issue.policy
bsw/jbe@19 135 ui.container{
bsw/jbe@19 136 attr = { class = "not_admitted_info" },
bsw/jbe@19 137 content = _("This issue has been cancelled. It failed the quorum of #{quorum}.", { quorum = format.percentage(policy.issue_quorum_num / policy.issue_quorum_den) })
bsw/jbe@19 138 }
bsw/jbe@19 139 end
bsw/jbe@19 140
bsw/jbe@19 141 if initiative.revoked then
bsw/jbe@19 142 ui.container{
bsw/jbe@19 143 attr = { class = "revoked_info" },
bsw/jbe@19 144 content = function()
bsw/jbe@19 145 slot.put(_("This initiative has been revoked at #{revoked}", { revoked = format.timestamp(initiative.revoked) }))
bsw/jbe@19 146 local suggested_initiative = initiative.suggested_initiative
bsw/jbe@19 147 if suggested_initiative then
bsw/jbe@19 148 slot.put("<br /><br />")
bsw/jbe@19 149 slot.put(_("The initiators suggest to support the following initiative:"))
bsw/jbe@19 150 slot.put(" ")
bsw/jbe@19 151 ui.link{
bsw/jbe@19 152 content = _("Issue ##{id}", { id = suggested_initiative.issue.id } ) .. ": " .. encode.html(suggested_initiative.name),
bsw/jbe@19 153 module = "initiative",
bsw/jbe@19 154 view = "show",
bsw/jbe@19 155 id = suggested_initiative.id
bsw/jbe@19 156 }
bsw/jbe@19 157 end
bsw/jbe@19 158 end
bsw/jbe@19 159 }
bsw/jbe@19 160 end
bsw/jbe@19 161
bsw@41 162 if initiator and initiator.accepted == nil and not initiative.issue.half_frozen and not initiative.issue.closed then
bsw/jbe@19 163 ui.container{
bsw/jbe@19 164 attr = { class = "initiator_invite_info" },
bsw/jbe@19 165 content = function()
bsw/jbe@19 166 slot.put(_"You are invited to become initiator of this initiative.")
bsw/jbe@19 167 slot.put(" ")
bsw/jbe@19 168 ui.link{
bsw/jbe@19 169 image = { static = "icons/16/tick.png" },
bsw/jbe@19 170 text = _"Accept invitation",
bsw/jbe@19 171 module = "initiative",
bsw/jbe@19 172 action = "accept_invitation",
bsw/jbe@19 173 id = initiative.id,
bsw/jbe@19 174 routing = {
bsw/jbe@19 175 default = {
bsw/jbe@19 176 mode = "redirect",
bsw/jbe@19 177 module = request.get_module(),
bsw/jbe@19 178 view = request.get_view(),
bsw/jbe@19 179 id = param.get_id_cgi(),
bsw/jbe@19 180 params = param.get_all_cgi()
bsw/jbe@19 181 }
bsw/jbe@19 182 }
bsw/jbe@19 183 }
bsw/jbe@19 184 slot.put(" ")
bsw/jbe@19 185 ui.link{
bsw/jbe@19 186 image = { static = "icons/16/cross.png" },
bsw/jbe@19 187 text = _"Refuse invitation",
bsw/jbe@19 188 module = "initiative",
bsw/jbe@19 189 action = "reject_initiator_invitation",
bsw/jbe@19 190 params = {
bsw/jbe@19 191 initiative_id = initiative.id,
bsw/jbe@19 192 member_id = app.session.member.id
bsw/jbe@19 193 },
bsw/jbe@19 194 routing = {
bsw/jbe@19 195 default = {
bsw/jbe@19 196 mode = "redirect",
bsw/jbe@19 197 module = request.get_module(),
bsw/jbe@19 198 view = request.get_view(),
bsw/jbe@19 199 id = param.get_id_cgi(),
bsw/jbe@19 200 params = param.get_all_cgi()
bsw/jbe@19 201 }
bsw/jbe@19 202 }
bsw/jbe@19 203 }
bsw/jbe@19 204 end
bsw/jbe@19 205 }
bsw/jbe@19 206 slot.put("<br />")
bsw/jbe@19 207 end
bsw/jbe@19 208
bsw/jbe@19 209
bsw@51 210 local supporter
bsw@51 211
bsw@51 212 if app.session.member_id then
bsw@51 213 supporter = app.session.member:get_reference_selector("supporters")
bsw@51 214 :add_where{ "initiative_id = ?", initiative.id }
bsw@51 215 :optional_object_mode()
bsw@51 216 :exec()
bsw@51 217 end
bsw/jbe@19 218
bsw/jbe@19 219 if supporter and not initiative.issue.closed then
bsw/jbe@19 220 local old_draft_id = supporter.draft_id
bsw/jbe@19 221 local new_draft_id = initiative.current_draft.id
bsw/jbe@19 222 if old_draft_id ~= new_draft_id then
bsw/jbe@19 223 ui.container{
bsw/jbe@19 224 attr = { class = "draft_updated_info" },
bsw/jbe@19 225 content = function()
bsw/jbe@19 226 slot.put(_"The draft of this initiative has been updated!")
bsw/jbe@19 227 slot.put(" ")
bsw/jbe@19 228 ui.link{
bsw/jbe@19 229 content = _"Show diff",
bsw/jbe@19 230 module = "draft",
bsw/jbe@19 231 view = "diff",
bsw/jbe@19 232 params = {
bsw/jbe@19 233 old_draft_id = old_draft_id,
bsw/jbe@19 234 new_draft_id = new_draft_id
bsw/jbe@19 235 }
bsw/jbe@19 236 }
bsw@75 237 if not initiative.revoked then
bsw@75 238 slot.put(" ")
bsw@75 239 ui.link{
bsw@75 240 text = _"Refresh support to current draft",
bsw@75 241 module = "initiative",
bsw@75 242 action = "add_support",
bsw@75 243 id = initiative.id,
bsw@75 244 routing = {
bsw@75 245 default = {
bsw@75 246 mode = "redirect",
bsw@75 247 module = "initiative",
bsw@75 248 view = "show",
bsw@75 249 id = initiative.id
bsw@75 250 }
bsw/jbe@19 251 }
bsw/jbe@19 252 }
bsw@75 253 end
bsw/jbe@19 254 end
bsw/jbe@19 255 }
bsw/jbe@19 256 end
bsw/jbe@19 257 end
bsw/jbe@19 258
bsw/jbe@19 259
bsw@51 260 if app.session.member_id then
bsw@51 261 ui.container{
bsw@51 262 attr = {
bsw@51 263 id = "initiative_" .. tostring(initiative.id) .. "_support"
bsw@51 264 },
bsw@51 265 content = function()
bsw@51 266 execute.view{
bsw@51 267 module = "initiative",
bsw@51 268 view = "show_support",
bsw@51 269 params = {
bsw@51 270 initiative = initiative
bsw@51 271 }
bsw/jbe@19 272 }
bsw@51 273 end
bsw@51 274 }
bsw@51 275 end
bsw/jbe@19 276
bsw/jbe@19 277 if (initiative.discussion_url and #initiative.discussion_url > 0)
bsw/jbe@19 278 or (initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked) then
bsw/jbe@19 279 ui.container{
bsw/jbe@19 280 attr = { class = "vertical" },
bsw/jbe@19 281 content = function()
bsw/jbe@19 282 ui.container{
bsw/jbe@19 283 attr = { class = "ui_field_label" },
bsw/jbe@19 284 content = _"Discussion with initiators"
bsw/jbe@19 285 }
bsw/jbe@19 286 ui.tag{
bsw/jbe@19 287 tag = "span",
bsw/jbe@19 288 content = function()
bsw/jbe@19 289 if initiative.discussion_url:find("^https?://") then
bsw/jbe@19 290 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw/jbe@19 291 ui.link{
bsw/jbe@19 292 attr = {
bsw/jbe@19 293 class = "actions",
bsw/jbe@19 294 target = "_blank",
bsw/jbe@19 295 title = initiative.discussion_url
bsw/jbe@19 296 },
bsw/jbe@19 297 content = function()
bsw/jbe@19 298 slot.put(encode.html(initiative.discussion_url))
bsw/jbe@19 299 end,
bsw/jbe@19 300 external = initiative.discussion_url
bsw/jbe@19 301 }
bsw/jbe@19 302 end
bsw/jbe@19 303 else
bsw/jbe@19 304 slot.put(encode.html(initiative.discussion_url))
bsw/jbe@19 305 end
bsw/jbe@19 306 slot.put(" ")
bsw/jbe@19 307 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw/jbe@19 308 ui.link{
bsw/jbe@19 309 attr = { class = "actions" },
bsw/jbe@19 310 text = _"(change URL)",
bsw/jbe@19 311 module = "initiative",
bsw/jbe@19 312 view = "edit",
bsw/jbe@19 313 id = initiative.id
bsw/jbe@19 314 }
bsw/jbe@19 315 end
bsw/jbe@19 316 end
bsw/jbe@19 317 }
bsw/jbe@19 318 end
bsw/jbe@19 319 }
bsw/jbe@19 320 end
bsw/jbe@19 321
bsw/jbe@19 322
bsw/jbe@19 323
bsw/jbe@19 324 execute.view{
bsw/jbe@19 325 module = "initiative",
bsw/jbe@19 326 view = "show_tab",
bsw/jbe@19 327 params = {
bsw/jbe@19 328 initiative = initiative,
bsw/jbe@19 329 initiator = initiator
bsw/jbe@19 330 }
bsw/jbe@19 331 }
bsw/jbe@19 332

Impressum / About Us