liquid_feedback_frontend
view app/main/lf2/interest.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 | 
 line source
     1 slot.set_layout("lf2")
     3 slot.put_into("leftright_pre", '<div class="sidebar_right">')
     4 slot.put_into("leftright_post", '</div>')
     6 local issue = Issue:by_id(param.get("issue_id", atom.integer))
     7 local member = Member:by_id(param.get("member_id", atom.integer))
     9 local area = issue.area
    11 -- TODO broken
    12 --issue:load("interested_members_snapshot", {}, "interested_members")
    13 issue:load("delegating_interest_snapshot_for_member", { member_id = member.id }, "delegating_interest")
    14 issue:load("interest_for_member", { member_id = member.id }, "interest")
    15 issue:load("outgoing_delegations_for_member", { member_id = member.id }, "outgoing_delegations")
    16 issue:load("trusters_for_member", { member_id = member.id }, "trusters")
    18 local initiatives = issue.initiatives
    20 local supported_initiatives = Initiative:new_selector()
    21   :add_where{ "initiative.issue_id = ?", issue.id }
    22   :join("supporter", nil, { "supporter.initiative_id = initiative.id AND supporter.member_id = ?", member.id })
    23   :exec()
    26 local interest = issue.interest
    28 local delegations = issue.delegations
    30 local trustees = Member:new_selector()
    31   :add_field("delegation_chain.*")
    32   :join({ "delegation_chain(?, null, ?, ?)", member.id, issue.area_id, issue_id }, "delegation_chain", "member.id = delegation_chain.member_id")
    33   :add_order_by("index")
    34   :exec()
    36 local global_delegation
    37 local area_delegation
    38 local issue_delegation
    40 for i, delegation in ipairs(issue.delegations) do
    41   if delegation.scope == "global" then global_delegation = delegation
    42   elseif delegation.scope == "area" then area_delegation = delegation
    43   elseif delegation.scope == "issue" then issue_delegation = delegation
    44   end
    45 end
    47 local delegation = issue_delegation or area_delegation or global_delegation
    49 local delegating_interest = issue.delegating_interest
    51 app.topnav_phase = issue.phase
    52 app.topnav_area_id = issue.area_id
    54 slot.select("sidebar", function()
    55   execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, alternative_initiatives = initiatives } }
    57 end)
    59 ui.box{ content = function()
    60   ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
    61     ui.link{ module = "lf2", view = "member", id = member.id, content = function()
    62       ui.avatar(member)
    63       slot.put(" ")
    64       ui.tag{ content = member.name }
    65     end }
    66   end } end }
    67   if not member.active then
    68     ui.box_row{ class = "head", content = function() ui.box_col{ class = "head", content = function()
    69       ui.tag{ content = _"Member is deactivated" }
    70     end } end }
    71   end
    72   ui.box_row{ content = function() ui.box_col{ content = function()
    73     if interest then
    74       ui.image{ static = "lf2/icon_star.png" }
    75       slot.put(" ")
    76       ui.tag{ content = _"Member is interested in this issue" }
    77     elseif delegating_interest then
    78       ui.image{ static = "lf2/icon_delegated_star.png" }
    79       slot.put(" ")
    80       ui.tag{ content = _"Someone in members delegation chain is interested" }
    81     else
    82       ui.image{ static = "lf2/icon_star_grey.png" }
    83       slot.put(" ")
    84       ui.tag{ content = _"Member is not interested" }
    85     end
    86   end } end }
    87   if #trustees > 1 then
    88     ui.box_row{ content = function() ui.box_col{ content = function()
    89       execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small", issue_id = issue.id } }
    90     end } end }
    91   end
    93   if statement then
    94     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Statement about issue" } end }  
    95   end
    97   if #supported_initiatives > 0 then
    98     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Supported initiatives" } end }
    99     execute.view{ module = "lf2", view = "_initiatives", params = { initiatives = supported_initiatives } }
   100   end
   102   if #(issue.trusters) > 0 then
   103     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Incoming delegations" } end }
   104     ui.box_row{ content = function() ui.box_col{ content = function()
   105       execute.view{ module = "lf2", view = "_avatars", params = { members = issue.trusters, size = "small", issue_id = issue.id } }
   106     end } end }
   107   end
   109 end }
