liquid_feedback_frontend

diff app/main/report/area.lua @ 31:a6caaff47205

Report view for all closed issues added
author bsw
date Tue Feb 23 21:09:10 2010 +0100 (2010-02-23)
parents
children a851cc1d9903
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/report/area.lua	Tue Feb 23 21:09:10 2010 +0100
     1.3 @@ -0,0 +1,220 @@
     1.4 +function show_issue(issue, initiatives_selector)
     1.5 +  ui.list{
     1.6 +    records = initiatives_selector:exec(),
     1.7 +    columns = {
     1.8 +      {
     1.9 +        label = _"Date",
    1.10 +        label_attr = { style = "width: 7.5em;" },
    1.11 +        content = function(initiative)
    1.12 +          slot.put(format.date(issue.closed))
    1.13 +        end
    1.14 +      },
    1.15 +      {
    1.16 +        label_attr = { style = "width: 8em;" },
    1.17 +        label = _"Id",
    1.18 +        content = function(initiative)
    1.19 +          ui.link{
    1.20 +            external = "",
    1.21 +            text = "#" .. tostring(issue.id) .. "." .. tostring(initiative.id),
    1.22 +            attr = {
    1.23 +              onclick =
    1.24 +                "openEl('initiative_" .. tostring(initiative.id) .. "');" ..
    1.25 +                "return(false);"
    1.26 +            }
    1.27 +          }
    1.28 +        end
    1.29 +      },
    1.30 +      {
    1.31 +        label = _"Rank",
    1.32 +        label_attr = { style = "width: 3em;" },
    1.33 +        field_attr = { style = "text-align: right;" },
    1.34 +        content = function(initiative)
    1.35 +          ui.field.rank{ value = initiative.rank }
    1.36 +        end
    1.37 +      },
    1.38 +      {
    1.39 +        label = _"Name",
    1.40 +        content = function(initiative)
    1.41 +          if initiative.rank and initiative.rank == 1 then
    1.42 +            slot.put("<b>")
    1.43 +          end
    1.44 +          ui.field.text{ value = initiative.name }
    1.45 +          if initiative.rank and initiative.rank == 1 then
    1.46 +            slot.put("</b>")
    1.47 +          end
    1.48 +        end
    1.49 +      }
    1.50 +    }
    1.51 +  }
    1.52 +end
    1.53 +
    1.54 +function link_issue(issue)
    1.55 +  ui.link{
    1.56 +    external = "",
    1.57 +    attr = {
    1.58 +      style = "text-decoration: none;",
    1.59 +      name    = "issue_" .. tostring(issue.id),
    1.60 +      onclick =
    1.61 +        "openEl('issue_" .. tostring(issue.id) .. "');" ..
    1.62 +        "return(false);"
    1.63 +    },
    1.64 +    content = function()
    1.65 +      ui.heading{
    1.66 +        attr = { style = "background-color: #ddd; color: #000;" },
    1.67 +        content = _("##{id}", { id = issue.id })
    1.68 +      }
    1.69 +    end
    1.70 +  }
    1.71 +end
    1.72 +
    1.73 +
    1.74 +local area = param.get("area", "table")
    1.75 +
    1.76 +local issue_selector = Issue:new_selector()
    1.77 +issue_selector:add_where{ "area_id = ?", area.id }
    1.78 +issue_selector:add_where("closed NOTNULL")
    1.79 +issue_selector:add_order_by("id")
    1.80 +
    1.81 +
    1.82 +local issues = issue_selector:exec()
    1.83 +
    1.84 +ui.container{
    1.85 +  attr = {
    1.86 +    id = "area_" .. tostring(area.id)
    1.87 +  },
    1.88 +  content = function()
    1.89 +
    1.90 +    link_area(area)
    1.91 +
    1.92 +    for i, issue in ipairs(issues) do
    1.93 +
    1.94 +      link_issue(issue)
    1.95 +
    1.96 +      local initiatives_selector = issue:get_reference_selector("initiatives")
    1.97 +
    1.98 +      local initiatives_count = initiatives_selector:count()
    1.99 +
   1.100 +      initiatives_selector:add_order_by("rank")
   1.101 +      initiatives_selector:limit(3)
   1.102 +
   1.103 +      show_issue(issue, initiatives_selector)
   1.104 +
   1.105 +      if initiatives_count > 3 then
   1.106 +        ui.link{
   1.107 +          attr = {
   1.108 +            style = "margin-left: 8em; font-style: italic;",
   1.109 +            onclick = "openEl('issue_" .. tostring(issue.id) .. "'); return(false);"
   1.110 +          },
   1.111 +          content = _("and #{count} more initiatives", { count = initiatives_count - 3 }),
   1.112 +          external = ""
   1.113 +        }
   1.114 +      end
   1.115 +
   1.116 +      slot.put("<br />")
   1.117 +
   1.118 +    end
   1.119 +
   1.120 +  end
   1.121 +}
   1.122 +
   1.123 +local next_issue = issues[1]
   1.124 +if next_issue then
   1.125 +  ui.script{ script = "next_issues['area_" .. tostring(area.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   1.126 +end
   1.127 +
   1.128 +if next_issue then
   1.129 +  local next_initiative = next_issue.initiatives[1]
   1.130 +  if next_initiative then
   1.131 +    ui.script{ script = "next_initiatives['area_" .. tostring(area.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   1.132 +  end
   1.133 +end
   1.134 +
   1.135 +
   1.136 +for i, issue in ipairs(issues) do
   1.137 +  local initiatives_selector = issue:get_reference_selector("initiatives")
   1.138 +    :add_order_by("rank")
   1.139 +
   1.140 +  local initiatives = initiatives_selector:exec()
   1.141 +
   1.142 +  ui.container{
   1.143 +    attr = {
   1.144 +      id = "issue_" .. tostring(issue.id)
   1.145 +    },
   1.146 +    content = function()
   1.147 +      link_area(area)
   1.148 +      link_issue(issue)
   1.149 +      show_issue(issue, initiatives_selector)
   1.150 +    end
   1.151 +  }
   1.152 +
   1.153 +  local previous_issue = issues[i-1]
   1.154 +  if previous_issue then
   1.155 +    ui.script{ script = "prev_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
   1.156 +  end
   1.157 +
   1.158 +  local next_initiative = initiatives[1]
   1.159 +  if next_initiative then
   1.160 +    ui.script{ script = "next_initiatives['issue_" .. tostring(issue.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   1.161 +  end
   1.162 +
   1.163 +  local next_issue = issues[i+1]
   1.164 +  if next_issue then
   1.165 +    ui.script{ script = "next_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   1.166 +  end
   1.167 +
   1.168 +  ui.script{
   1.169 +    script = "document.getElementById('issue_" .. tostring(issue.id) .. "').style.display = 'none';"
   1.170 +  }
   1.171 +
   1.172 +
   1.173 +  for j, initiative in ipairs(initiatives) do
   1.174 +
   1.175 +    ui.container{
   1.176 +      attr = {
   1.177 +        id = "initiative_" .. tostring(initiative.id)
   1.178 +      },
   1.179 +      content = function()
   1.180 +        execute.view{
   1.181 +          module = "report",
   1.182 +          view = "initiative",
   1.183 +          params = { initiative = initiative }
   1.184 +        }
   1.185 +        slot.put("<br />")
   1.186 +        slot.put("<br />")
   1.187 +        slot.put("<br />")
   1.188 +        slot.put("<br />")
   1.189 +        slot.put("<br />")
   1.190 +      end
   1.191 +    }
   1.192 +
   1.193 +    local previous_issue = issues[i-1]
   1.194 +    if previous_issue then
   1.195 +      ui.script{ script = "prev_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
   1.196 +    end
   1.197 +
   1.198 +    local previous_initiative = initiatives[j-1]
   1.199 +    if previous_initiative then
   1.200 +      ui.script{ script = "prev_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(previous_initiative.id) .. "';" }
   1.201 +    end
   1.202 +
   1.203 +    local next_initiative = initiatives[j+1]
   1.204 +    if next_initiative then
   1.205 +      ui.script{ script = "next_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   1.206 +    end
   1.207 +
   1.208 +    local next_issue = issues[i+1]
   1.209 +    if next_issue then
   1.210 +      ui.script{ script = "next_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   1.211 +    end
   1.212 +
   1.213 +    ui.script{
   1.214 +      script = "document.getElementById('initiative_" .. tostring(initiative.id) .. "').style.display = 'none';"
   1.215 +    }
   1.216 +
   1.217 +  end
   1.218 +end
   1.219 +
   1.220 +ui.script{
   1.221 +  script = "document.getElementById('area_" .. tostring(area.id) .. "').style.display = 'none';"
   1.222 +}
   1.223 +

Impressum / About Us