liquid_feedback_frontend

annotate app/main/lf2/_issues.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 issues = param.get("issues", "table")
bsw@211 2
bsw@211 3 for i, issue in ipairs(issues) do
bsw@211 4 local initiatives = issue.initiatives
bsw@211 5
bsw@211 6 local interested_members = issue.interested_members
bsw@211 7
bsw@211 8 -- prepare interest of current user
bsw@211 9 local interest = issue.interest
bsw@211 10
bsw@211 11 -- prepare trustees
bsw@211 12 local trustees = Member:new_selector()
bsw@211 13 :add_field("delegation_chain.*")
bsw@211 14 :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
bsw@211 15 :add_order_by("index")
bsw@211 16 :exec()
bsw@211 17
bsw@211 18 local global_delegation
bsw@211 19 local area_delegation
bsw@211 20 local issue_delegation
bsw@211 21
bsw@211 22 for i, delegation in ipairs(issue.outgoing_delegations) do
bsw@211 23 if delegation.scope == "global" then global_delegation = delegation
bsw@211 24 elseif delegation.scope == "area" then area_delegation = delegation
bsw@211 25 elseif delegation.scope == "issue" then issue_delegation = delegation
bsw@211 26 end
bsw@211 27 end
bsw@211 28
bsw@211 29 local delegation = issue_delegation or area_delegation or global_delegation
bsw@211 30
bsw@211 31 local delegating_interest = issue.delegating_interest
bsw@215 32 --[[
bsw@215 33 local current_delegating_interest = false
bsw@211 34
bsw@215 35 for i, trustee in ipairs(trustees) do
bsw@215 36 if i > 1 and trustee.participation then
bsw@215 37 delegating_interest = true
bsw@215 38 end
bsw@215 39 end
bsw@215 40 --]]
bsw@215 41 local row_count = #initiatives + 3
bsw@215 42 if #trustees > 1 then
bsw@215 43 row_count = row_count + 1
bsw@215 44 end
bsw@215 45
bsw@215 46 ui.box{ class = "issue", row_count = row_count, content = function()
bsw@211 47
bsw@215 48 ui.box_row{ class = "head2", content = function()
bsw@211 49
bsw@212 50 ui.box_col{ class = "issue_id left head", content = function()
bsw@211 51 ui.link{
bsw@211 52 module = "lf2", view = "issue", id = issue.id,
bsw@211 53 content = _("Issue ##{id}", { id = issue.id })
bsw@211 54 }
bsw@211 55 end }
bsw@211 56
bsw@212 57 ui.box_col{ class = "policy_name right", content = function()
bsw@211 58 ui.link{
bsw@211 59 module = "lf2", view = "policy", id = issue.policy_id,
bsw@211 60 content = issue.policy.name
bsw@211 61 }
bsw@211 62 end }
bsw@211 63
bsw@211 64 end }
bsw@211 65
bsw@216 66 ui.box_row{ class = "head2", content = function()
bsw@211 67
bsw@211 68 ui.box_col{ class = "state_name left", content = function()
bsw@211 69 ui.tag{ content = issue.state_name }
bsw@212 70 end }
bsw@212 71 ui.box_col{ class = "state_time_left right", content = function()
bsw@211 72 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@211 73 end }
bsw@211 74 end }
bsw@211 75
bsw@212 76 if #trustees > 1 then
bsw@216 77 local class = "head"
bsw@216 78 if not issue.closed and not issue.fully_frozen then
bsw@216 79 class = "head2"
bsw@215 80 end
bsw@216 81 ui.box_row{ class = "head2", content = function()
bsw@212 82 ui.box_col{ class = "left", content = function()
bsw@216 83 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
bsw@212 84 end }
bsw@212 85 if not issue.closed and not issue.fully_frozen then
bsw@212 86 if trustees[1].scope_out == "issue" then
bsw@215 87 text = _"Change or revoke issue delegation"
bsw@211 88 else
bsw@215 89 text = _"Set issue delegation"
bsw@212 90 end
bsw@212 91 ui.box_col{ class = "right", content = function()
bsw@212 92 ui.link{
bsw@212 93 text = text,
bsw@212 94 module = "lf2", view = "delegation", params = { issue_id = issue.id }
bsw@212 95 }
bsw@211 96 end }
bsw@211 97 end
bsw@211 98 end }
bsw@211 99 end
bsw@212 100
bsw@215 101 if not issue.closed and not issue.fully_frozen then
bsw@216 102 ui.box_row{ class = "head", content = function()
bsw@215 103 ui.box_col{ class = "interest left", content = function()
bsw@215 104 if interest then
bsw@215 105 ui.image{ static = "lf2/icon_star.png" }
bsw@215 106 if issue.close then
bsw@215 107 slot.put(" ", _"You were interested in this issue")
bsw@215 108 else
bsw@215 109 slot.put(" ", _"You are interested in this issue")
bsw@215 110 end
bsw@215 111 elseif delegating_interest then
bsw@215 112 ui.image{ static = "lf2/icon_delegated_star.png" }
bsw@215 113 if issue.closed then
bsw@215 114 slot.put(" ", _"Someone in your delegation chain was interested")
bsw@215 115 else
bsw@215 116 slot.put(" ", _"Someone in your delegation chain is interested")
bsw@215 117 end
bsw@215 118 elseif not issue.closed and not issue.fully_frozen then
bsw@215 119 ui.link{
bsw@215 120 text = _"Add my interest",
bsw@215 121 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@215 122 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@215 123 }
bsw@212 124 end
bsw@215 125 end }
bsw@212 126
bsw@212 127 ui.box_col{ class = "right", content = function()
bsw@212 128 if interest then
bsw@212 129 ui.link{
bsw@212 130 text = _"Remove interest",
bsw@212 131 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
bsw@212 132 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@212 133 }
bsw@215 134 slot.put(" · ")
bsw@215 135 elseif delegating_interest then
bsw@212 136 ui.link{
bsw@212 137 text = _"Add my interest",
bsw@212 138 module = "interest", action = "update", params = { issue_id = issue.id },
bsw@212 139 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
bsw@212 140 }
bsw@215 141 slot.put(" · ")
bsw@212 142 end
bsw@212 143 if #trustees == 1 then
bsw@212 144 ui.link{
bsw@215 145 text = _"Set issue delegation",
bsw@212 146 module = "lf2", view = "delegation", params = { issue_id = issue.id }
bsw@212 147 }
bsw@212 148 end
bsw@212 149 end }
bsw@215 150 end }
bsw@212 151
bsw@215 152 end
bsw@211 153
bsw@211 154 for i, initiative in ipairs(issue.initiatives) do
bsw@211 155 ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
bsw@211 156 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
bsw@211 157 end } end }
bsw@211 158 end
bsw@211 159
bsw@211 160 end }
bsw@211 161 end

Impressum / About Us