liquid_feedback_frontend

annotate app/main/lf2/_sidebar_issue.lua @ 217:73dbc9e2bfd4

Cummulative patch for enhancements at next generation frontend
author bsw
date Sat Mar 12 19:22:50 2011 +0100 (2011-03-12)
parents 4f6e6b213fb8
children 7ea52c710503
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@217 18 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, 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@217 26 ui.box_row{ class = "issue_id head", content = function() ui.box_col{ class = "head", content = function()
bsw@217 27 if interest then
bsw@217 28 local text
bsw@217 29 if issue.close then
bsw@217 30 text = _"You were interested in this issue"
bsw@217 31 else
bsw@217 32 text = _"You are interested in this issue"
bsw@217 33 end
bsw@217 34 ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_star.png" }
bsw@217 35 slot.put(" ")
bsw@217 36 elseif delegating_interest then
bsw@217 37 local text
bsw@217 38 if issue.closed then
bsw@217 39 text = _"Someone in your delegation chain was interested"
bsw@217 40 else
bsw@217 41 text = _"Someone in your delegation chain is interested"
bsw@217 42 end
bsw@217 43 ui.image{ attr = { title = text, alt = text}, static = "lf2/icon_delegated_star.png" }
bsw@217 44 slot.put(" ")
bsw@217 45 end
bsw@217 46 ui.link{
bsw@217 47 module = "lf2", view = "issue", id = issue.id,
bsw@217 48 content = _("Issue ##{id}", { id = issue.id })
bsw@217 49 }
bsw@217 50 end } end }
bsw@217 51
bsw@217 52 if #trustees > 1 then
bsw@217 53 ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
bsw@217 54 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
bsw@217 55 end } end }
bsw@217 56 end
bsw@217 57
bsw@217 58 if not issue.closed then
bsw@217 59 ui.box_row{ class = "interest", content = function() ui.box_col{ content = function()
bsw@217 60 if interest then
bsw@217 61 ui.link{
bsw@217 62 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@217 63 routing = { default = {
bsw@217 64 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
bsw@217 65 } },
bsw@217 66 content = _"Remove my interest"
bsw@217 67 }
bsw@217 68 else
bsw@217 69 ui.link{
bsw@217 70 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@217 71 routing = { default = {
bsw@217 72 mode = "redirect", module = "lf2", view = initiative_id and "initiative" or "issue", id = initiative_id or issue.id,
bsw@217 73 } },
bsw@217 74 content = _"Add my interest"
bsw@217 75 }
bsw@217 76 end
bsw@217 77 end } end }
bsw@217 78 end
bsw@217 79
bsw@217 80 if not issue.closed then
bsw@217 81 ui.box_row{ class = "interest", content = function() ui.box_col{ content = function()
bsw@217 82 if #trustees > 1 and trustees[1].scope_out == "issue" then
bsw@217 83 ui.link{
bsw@217 84 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
bsw@217 85 content = _"Set issue delegation"
bsw@217 86 }
bsw@217 87 else
bsw@217 88 ui.link{
bsw@217 89 module = "lf2", view = "delegation", params = { issue_id = issue.id, initiative_id = initiative_id },
bsw@217 90 content = _"Change or remove delegation"
bsw@217 91 }
bsw@217 92 end
bsw@217 93
bsw@217 94 end } end }
bsw@217 95 end
bsw@217 96
bsw@217 97 ui.box_row{ class = "unit_name", content = function() ui.box_col{ content = function()
bsw@211 98 ui.link{
bsw@215 99 module = "lf2", view = "index", id = 1,
bsw@211 100 content = "DE / Berlin / Friedrichshain-Kreuzberg"
bsw@211 101 }
bsw@211 102 end } end }
bsw@211 103
bsw@217 104 ui.box_row{ class = "area_name", content = function() ui.box_col{ content = function()
bsw@211 105 ui.link{
bsw@211 106 module = "lf2", view = "area", id = issue.area_id,
bsw@211 107 content = issue.area.name
bsw@211 108 }
bsw@211 109 end } end }
bsw@211 110
bsw@216 111 ui.box_row{ class = "policy_name", content = function() ui.box_col{ content = function()
bsw@211 112 ui.link{
bsw@211 113 module = "lf2", view = "policy", id = issue.policy_id,
bsw@211 114 content = issue.policy.name
bsw@211 115 }
bsw@211 116 end } end }
bsw@211 117
bsw@216 118 ui.box_row{ class = "time_left", content = function()
bsw@216 119 ui.box_col{ class = "left", content = function()
bsw@216 120 ui.tag{ content = issue.state_name }
bsw@216 121 slot.put(" · ")
bsw@216 122 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 123 end }
bsw@211 124 end }
bsw@211 125
bsw@216 126 ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Initiatives" } end }
bsw@215 127 ui.box_row{ class = "initiatives last", content = function()
bsw@217 128 ui.box_col{ id = "resizable", class = "scrolled", content = function()
bsw@215 129 execute.view{ module = "lf2", view = "_issue_initiatives", params = { initiatives = alternative_initiatives, current_initiative_id = initiative_id } }
bsw@215 130 end }
bsw@215 131 end }
bsw@215 132
bsw@217 133 ui.script{ script = "$(function() { $( '#resizable' ).resizable(); });" }
bsw@215 134
bsw@211 135 end }

Impressum / About Us