liquid_feedback_frontend

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

Impressum / About Us