liquid_feedback_frontend
view app/main/report/area.lua @ 32:4ae09a588103
Changed style.css: Member thumb a bit smaller
| author | bsw | 
|---|---|
| date | Tue Feb 23 21:10:23 2010 +0100 (2010-02-23) | 
| parents | a6caaff47205 | 
| children | a851cc1d9903 | 
 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 local next_issue = issues[1]
   121 if next_issue then
   122   ui.script{ script = "next_issues['area_" .. tostring(area.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   123 end
   125 if next_issue then
   126   local next_initiative = next_issue.initiatives[1]
   127   if next_initiative then
   128     ui.script{ script = "next_initiatives['area_" .. tostring(area.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   129   end
   130 end
   133 for i, issue in ipairs(issues) do
   134   local initiatives_selector = issue:get_reference_selector("initiatives")
   135     :add_order_by("rank")
   137   local initiatives = initiatives_selector:exec()
   139   ui.container{
   140     attr = {
   141       id = "issue_" .. tostring(issue.id)
   142     },
   143     content = function()
   144       link_area(area)
   145       link_issue(issue)
   146       show_issue(issue, initiatives_selector)
   147     end
   148   }
   150   local previous_issue = issues[i-1]
   151   if previous_issue then
   152     ui.script{ script = "prev_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
   153   end
   155   local next_initiative = initiatives[1]
   156   if next_initiative then
   157     ui.script{ script = "next_initiatives['issue_" .. tostring(issue.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   158   end
   160   local next_issue = issues[i+1]
   161   if next_issue then
   162     ui.script{ script = "next_issues['issue_" .. tostring(issue.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   163   end
   165   ui.script{
   166     script = "document.getElementById('issue_" .. tostring(issue.id) .. "').style.display = 'none';"
   167   }
   170   for j, initiative in ipairs(initiatives) do
   172     ui.container{
   173       attr = {
   174         id = "initiative_" .. tostring(initiative.id)
   175       },
   176       content = function()
   177         execute.view{
   178           module = "report",
   179           view = "initiative",
   180           params = { initiative = initiative }
   181         }
   182         slot.put("<br />")
   183         slot.put("<br />")
   184         slot.put("<br />")
   185         slot.put("<br />")
   186         slot.put("<br />")
   187       end
   188     }
   190     local previous_issue = issues[i-1]
   191     if previous_issue then
   192       ui.script{ script = "prev_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(previous_issue.id) .. "';" }
   193     end
   195     local previous_initiative = initiatives[j-1]
   196     if previous_initiative then
   197       ui.script{ script = "prev_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(previous_initiative.id) .. "';" }
   198     end
   200     local next_initiative = initiatives[j+1]
   201     if next_initiative then
   202       ui.script{ script = "next_initiatives['initiative_" .. tostring(initiative.id) .. "'] = 'initiative_" .. tostring(next_initiative.id) .. "';" }
   203     end
   205     local next_issue = issues[i+1]
   206     if next_issue then
   207       ui.script{ script = "next_issues['initiative_" .. tostring(initiative.id) .. "'] = 'issue_" .. tostring(next_issue.id) .. "';" }
   208     end
   210     ui.script{
   211       script = "document.getElementById('initiative_" .. tostring(initiative.id) .. "').style.display = 'none';"
   212     }
   214   end
   215 end
   217 ui.script{
   218   script = "document.getElementById('area_" .. tostring(area.id) .. "').style.display = 'none';"
   219 }
