annotate app/main/lf2/index.lua @ 223:979f456672c5
Added unit support to interest.lua
 | author | 
 bsw | 
 | date | 
 Mon Mar 14 11:30:17 2011 +0100 (2011-03-14) | 
 | parents | 
 73dbc9e2bfd4  | 
 | children | 
  | 
 
 | rev | 
   line source | 
| 
bsw@211
 | 
     1 slot.set_layout("lf2")
 | 
| 
bsw@211
 | 
     2 
 | 
| 
bsw@217
 | 
     3 local unit = Unit:by_id(param.get_id())
 | 
| 
bsw@217
 | 
     4 
 | 
| 
bsw@217
 | 
     5 local current_phase = param.get("phase") or "closed"
 | 
| 
bsw@217
 | 
     6 local current_order = param.get("order") or "last_change"
 | 
| 
bsw@217
 | 
     7 
 | 
| 
bsw@217
 | 
     8 if current_phase == "closed" and current_order == "time_left" then
 | 
| 
bsw@217
 | 
     9   current_order = "last_change"
 | 
| 
bsw@217
 | 
    10 end
 | 
| 
bsw@217
 | 
    11 
 | 
| 
bsw@217
 | 
    12 app.topnav_phase = current_phase
 | 
| 
bsw@217
 | 
    13 app.topnav_order = current_order
 | 
| 
bsw@217
 | 
    14 if unit then
 | 
| 
bsw@217
 | 
    15   app.topnav_unit_id = unit.id
 | 
| 
bsw@217
 | 
    16 end
 | 
| 
bsw@217
 | 
    17 
 | 
| 
bsw@211
 | 
    18 
 | 
| 
bsw@211
 | 
    19 local issues_selector = Issue:build_selector{
 | 
| 
bsw@217
 | 
    20   unit_id = unit and unit.id or nil,
 | 
| 
bsw@215
 | 
    21   phase = current_phase,
 | 
| 
bsw@215
 | 
    22   order = current_order
 | 
| 
bsw@211
 | 
    23 }:limit(25)
 | 
| 
bsw@211
 | 
    24 
 | 
| 
bsw@211
 | 
    25 local issues = issues_selector:exec()
 | 
| 
bsw@211
 | 
    26 
 | 
| 
bsw@211
 | 
    27 issues:load("delegating_interest_snapshot_for_member", { member_id = app.session.member_id }, "delegating_interest")
 | 
| 
bsw@211
 | 
    28 issues:load("interest_for_member", { member_id = app.session.member_id }, "interest")
 | 
| 
bsw@211
 | 
    29 issues:load("outgoing_delegations_for_member", { member_id = app.session.member_id }, "outgoing_delegations")
 | 
| 
bsw@211
 | 
    30 
 | 
| 
bsw@215
 | 
    31 
 | 
| 
bsw@215
 | 
    32 slot.select("sidebar", function()
 | 
| 
bsw@217
 | 
    33   execute.view{ module = "lf2", view = "_sidebar_unit", params = { unit = unit } }
 | 
| 
bsw@215
 | 
    34 end)
 | 
| 
bsw@215
 | 
    35 
 | 
| 
bsw@211
 | 
    36 execute.view{ module = "lf2", view = "_issues", params = { issues = issues } }
 |