liquid_feedback_frontend

annotate app/main/report/area.lua @ 119:915cc0341538

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

Impressum / About Us