liquid_feedback_frontend

view app/main/report/area.lua @ 118:93f4e465b50d

add initiator support in delegation

if a delegation is issued from the initiative view, the initiators
from that one are added to the delegation target list. this makes it easier to delegate to the author without the need to add him to the contact list.
author Daniel Poelzleithner <poelzi@poelzi.org>
date Mon Sep 20 20:32:04 2010 +0200 (2010-09-20)
parents a851cc1d9903
children
line source
1 function show_issue(issue, initiatives_selector)
2 ui.list{
3 records = initiatives_selector:exec(),
4 columns = {
5 {
6 label = _"Date",
7 label_attr = { style = "width: 7.5em;" },
8 content = function(initiative)
9 slot.put(format.date(issue.closed))
10 end
11 },
12 {
13 label_attr = { style = "width: 8em;" },
14 label = _"Id",
15 content = function(initiative)
16 ui.link{
17 external = "",
18 text = "#" .. tostring(issue.id) .. "." .. tostring(initiative.id),
19 attr = {
20 onclick =
21 "openEl('initiative_" .. tostring(initiative.id) .. "');" ..
22 "return(false);"
23 }
24 }
25 end
26 },
27 {
28 label = _"Rank",
29 label_attr = { style = "width: 3em;" },
30 field_attr = { style = "text-align: right;" },
31 content = function(initiative)
32 ui.field.rank{ value = initiative.rank }
33 end
34 },
35 {
36 label = _"Name",
37 content = function(initiative)
38 if initiative.rank and initiative.rank == 1 then
39 slot.put("<b>")
40 end
41 ui.field.text{ value = initiative.name }
42 if initiative.rank and initiative.rank == 1 then
43 slot.put("</b>")
44 end
45 end
46 }
47 }
48 }
49 end
51 function link_issue(issue)
52 ui.link{
53 external = "",
54 attr = {
55 style = "text-decoration: none;",
56 name = "issue_" .. tostring(issue.id),
57 onclick =
58 "openEl('issue_" .. tostring(issue.id) .. "');" ..
59 "return(false);"
60 },
61 content = function()
62 ui.heading{
63 attr = { style = "background-color: #ddd; color: #000;" },
64 content = _("##{id}", { id = issue.id })
65 }
66 end
67 }
68 end
71 local area = param.get("area", "table")
73 local issue_selector = Issue:new_selector()
74 issue_selector:add_where{ "area_id = ?", area.id }
75 issue_selector:add_where("closed NOTNULL")
76 issue_selector:add_order_by("id")
79 local issues = issue_selector:exec()
81 ui.container{
82 attr = {
83 id = "area_" .. tostring(area.id)
84 },
85 content = function()
87 link_area(area)
89 for i, issue in ipairs(issues) do
91 link_issue(issue)
93 local initiatives_selector = issue:get_reference_selector("initiatives")
95 local initiatives_count = initiatives_selector:count()
97 initiatives_selector:add_order_by("rank")
98 initiatives_selector:limit(3)
100 show_issue(issue, initiatives_selector)
102 if initiatives_count > 3 then
103 ui.link{
104 attr = {
105 style = "margin-left: 8em; font-style: italic;",
106 onclick = "openEl('issue_" .. tostring(issue.id) .. "'); return(false);"
107 },
108 content = _("and #{count} more initiatives", { count = initiatives_count - 3 }),
109 external = ""
110 }
111 end
113 slot.put("<br />")
115 end
117 end
118 }
120 ui.script{ script = "parents['area_" .. tostring(area.id) .. "'] = 'areas';" }
122 local next_issue = issues[1]
123 if next_issue then
124 ui.script{ script = "next_issues['area_" .. tostring(area.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
125 end
127 if next_issue then
128 local next_initiative = next_issue.initiatives[1]
129 if next_initiative then
130 ui.script{ script = "next_initiatives['area_" .. tostring(area.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
131 end
132 end
135 for i, issue in ipairs(issues) do
136 local initiatives_selector = issue:get_reference_selector("initiatives")
137 :add_order_by("rank")
139 local initiatives = initiatives_selector:exec()
141 ui.container{
142 attr = {
143 id = "issue_" .. tostring(issue.id)
144 },
145 content = function()
146 link_area(area)
147 link_issue(issue)
148 show_issue(issue, initiatives_selector)
149 end
150 }
152 local previous_issue = issues[i-1]
153 if previous_issue then
154 ui.script{ script = "prev_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
155 end
157 local next_initiative = initiatives[1]
158 if next_initiative then
159 ui.script{ script = "next_initiatives['issue_" .. tostring(issue.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
160 end
162 ui.script{ script = "parents['issue_" .. tostring(issue.id) .. "'] = 'area_" .. tostring(area.id) .. "';" }
164 local next_issue = issues[i+1]
165 if next_issue then
166 ui.script{ script = "next_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
167 end
169 ui.script{
170 script = "document.getElementById('issue_" .. tostring(issue.id) .. "').style.display = 'none';"
171 }
174 for j, initiative in ipairs(initiatives) do
176 ui.container{
177 attr = {
178 id = "initiative_" .. tostring(initiative.id)
179 },
180 content = function()
181 execute.view{
182 module = "report",
183 view = "initiative",
184 params = { initiative = initiative }
185 }
186 slot.put("<br />")
187 slot.put("<br />")
188 slot.put("<br />")
189 slot.put("<br />")
190 slot.put("<br />")
191 end
192 }
194 local previous_issue = issues[i-1]
195 if previous_issue then
196 ui.script{ script = "prev_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
197 end
199 local previous_initiative = initiatives[j-1]
200 if previous_initiative then
201 ui.script{ script = "prev_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(previous_initiative.id) .. "';" }
202 end
204 ui.script{ script = "parents['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(issue.id) .. "';" }
206 local next_initiative = initiatives[j+1]
207 if next_initiative then
208 ui.script{ script = "next_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
209 end
211 local next_issue = issues[i+1]
212 if next_issue then
213 ui.script{ script = "next_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
214 end
216 ui.script{
217 script = "document.getElementById('initiative_" .. tostring(initiative.id) .. "').style.display = 'none';"
218 }
220 end
221 end
223 ui.script{
224 script = "document.getElementById('area_" .. tostring(area.id) .. "').style.display = 'none';"
225 }

Impressum / About Us