liquid_feedback_frontend

view app/main/lf2/_issues.lua @ 212:3e4ad069847a

Some more work at 2nd generation frontend code
author bsw
date Thu Mar 03 18:39:00 2011 +0100 (2011-03-03)
parents 4993b71b383f
children acf92c2d33f4
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
33 ui.box{ class = "issue", content = function()
35 ui.box_row{ class = "head", content = function()
37 ui.box_col{ class = "issue_id left head", content = function()
38 ui.link{
39 module = "lf2", view = "issue", id = issue.id,
40 content = _("Issue ##{id}", { id = issue.id })
41 }
42 end }
44 ui.box_col{ class = "policy_name right", content = function()
45 ui.link{
46 module = "lf2", view = "policy", id = issue.policy_id,
47 content = issue.policy.name
48 }
49 end }
51 end }
53 ui.box_row{ class = "head2", content = function()
55 ui.box_col{ class = "state_name left", content = function()
56 ui.tag{ content = issue.state_name }
57 end }
58 ui.box_col{ class = "state_time_left right", content = function()
59 ui.tag{ content = issue.closed and _("since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left = issue.state_time_left }) }
60 end }
61 end }
63 if #trustees > 1 then
64 ui.box_row{ class = "head2", content = function()
65 ui.box_col{ class = "left", content = function()
66 execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
67 end }
68 if not issue.closed and not issue.fully_frozen then
69 if trustees[1].scope_out == "issue" then
70 text = _"Change or revoke issue delegation..."
71 else
72 text = _"Set issue delegation..."
73 end
74 ui.box_col{ class = "right", content = function()
75 ui.link{
76 text = text,
77 module = "lf2", view = "delegation", params = { issue_id = issue.id }
78 }
79 end }
80 end
81 end }
82 end
84 ui.box_row{ class = "head2", content = function()
85 ui.box_col{ class = "interest left", content = function()
86 if interest then
87 ui.image{ static = "lf2/icon_star.png" }
88 if issue.closed then
89 slot.put(" ", _"You were interested in this issue")
90 else
91 slot.put(" ", _"You are interested in this issue")
92 end
93 elseif delegating_interest then
94 ui.image{ static = "lf2/icon_delegated_star.png" }
95 if issue.closed then
96 slot.put(" ", _"You were interested in this issue by delegation")
97 else
98 slot.put(" ", _"You are interested in this issue by delegation")
99 end
100 else
101 slot.put(_"You are not interested in this issue")
102 end
103 end }
105 if not issue.closed and not issue.fully_frozen then
106 ui.box_col{ class = "right", content = function()
107 if interest then
108 ui.link{
109 text = _"Remove interest",
110 module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
111 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
112 }
113 else
114 ui.link{
115 text = _"Add my interest",
116 module = "interest", action = "update", params = { issue_id = issue.id },
117 routing = { default = { mode = "redirect", module = "lf2", view = "issue", id = issue.id } }
118 }
119 end
120 if #trustees == 1 then
121 slot.put(" · ")
122 ui.link{
123 text = _"Set issue delegation...",
124 module = "lf2", view = "delegation", params = { issue_id = issue.id }
125 }
126 end
127 end }
128 end
130 end }
132 for i, initiative in ipairs(issue.initiatives) do
133 ui.box_row{ class = "initiative", content = function() ui.box_col { content = function()
134 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
135 end } end }
136 end
138 end }
139 end

Impressum / About Us