liquid_feedback_frontend
view app/main/lf2/_sidebar_issue.lua @ 211:4993b71b383f
First checkin of lf2 (frontend second generation) prototype
| author | bsw | 
|---|---|
| date | Wed Mar 02 20:06:26 2011 +0100 (2011-03-02) | 
| parents | |
| children | 3e4ad069847a | 
 line source
     1 local issue = param.get("issue", "table")
     3 local initiatives = issue.initiatives
     5 local interested_members_selector = Member:new_selector()
     6   :join("direct_interest_snapshot", "dis", { "dis.issue_id = ? AND dis.member_id = member.id and dis.event = (select latest_snapshot_event from issue where id = ?)", issue.id, issue.id })
     7   :add_field("dis.weight", "weight")
     8   :add_order_by("dis.weight DESC")
     9 local interested_members = interested_members_selector:exec()
    11 local interest = issue.interest
    13 local delegations = issue.delegations
    15 local trustees = Member:new_selector()
    16   :add_field("delegation_chain.*")
    17   :join("delegation_chain(" .. tostring(app.session.member.id) .. ", NULL, " .. tostring(issue.id or "NULL") .. ")", "delegation_chain", "member.id = delegation_chain.member_id")
    18   :add_order_by("index")
    19   :exec()
    21 local global_delegation
    22 local area_delegation
    23 local issue_delegation
    25 for i, delegation in ipairs(issue.delegations) do
    26   if delegation.scope == "global" then global_delegation = delegation
    27   elseif delegation.scope == "area" then area_delegation = delegation
    28   elseif delegation.scope == "issue" then issue_delegation = delegation
    29   end
    30 end
    32 local delegation = issue_delegation or area_delegation or global_delegation
    34 local delegating_interest = issue.delegating_interest
    36 ui.box{ class = "issue", content = function()
    38   ui.box_row{ class = "issue_id head", content = function() ui.box_col{ content = function()
    39     ui.link{
    40       module = "lf2", view = "issue", id = issue.id,
    41       content = _("Issue ##{id}", { id = issue.id })
    42     }
    43   end } end }
    45   ui.box_row{ class = "unit_name", content = function() ui.box_col{ content = function()
    46     ui.link{ 
    47       module = "lf2", view = "unit", id = 1,
    48       content = "DE / Berlin / Friedrichshain-Kreuzberg" 
    49     }
    50   end } end }
    52   ui.box_row{ class = "area_name", content = function() ui.box_col{ content = function()
    53     ui.link{
    54       module = "lf2", view = "area", id = issue.area_id,
    55       content = issue.area.name
    56     }
    57   end } end }
    59   ui.box_row{ class = "policy_name", content = function() ui.box_col{ content = function()
    60     ui.link{
    61       module = "lf2", view = "policy", id = issue.policy_id,
    62       content = issue.policy.name
    63     }
    64   end } end }
    66   ui.box_row{ class = "time_left", content = function()
    67     ui.box_col{ content = issue.closed and _("Closed since #{date}", { date = format.date(issue.closed.date) }) or _("#{time_left} left", { time_left =  issue.state_time_left }) }
    68   end }
    70   ui.box_row{ class = "interest hoverbutton_container", content = function() ui.box_col{ content = function()
    71     if interest then
    72       ui.image{ static = "lf2/icon_star.png" }
    73       if issue.closed then
    74         slot.put(" ", _"You were interested in this issue")
    75       else
    76         slot.put(" ", _"You are interested in this issue")
    77       end
    78     else
    79       ui.image{ static = "lf2/icon_star_grey.png" }
    80       slot.put(_"You are not interested in this issue")
    81     end
    83     if issue.closed then
    84       ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
    85         ui.container{ attr = { class = "content"}, content = function()
    86           slot.put(" ", encode.html(_"This issue is closed"))
    87         end }
    88       end }
    89     elseif issue.fully_frozen then
    90       ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
    91         ui.container{ attr = { class = "content"}, content = function()
    92           slot.put(" ", encode.html(_"This issue is in voting"))
    93         end }
    94       end }
    95     else
    96       if interest then
    97         ui.link{
    98           module = "interest", action = "update", params = { issue_id = issue.id, delete = true },
    99           routing = { default = {
   100             mode = "redirect", module = "lf2", view = "issue", id = issue.id
   101           } },
   102           attr = { class = "hoverbutton red"},
   103           content = function()
   104             ui.container{ attr = { class = "content"}, content = function()
   105               ui.image{ static = "lf2/icon_star_crossed.png" }
   106               slot.put(" ", encode.html(_"Remove my interest"))
   107             end }
   108           end 
   109         }
   111       else
   112         ui.link{
   113           module = "interest", action = "update", params = { issue_id = issue.id },
   114           routing = { default = {
   115             mode = "redirect", module = "lf2", view = "issue", id = issue.id
   116           } },
   117           attr = { class = "hoverbutton green"},
   118           content = function()
   119             ui.container{ attr = { class = "content"}, content = function()
   120               ui.image{ static = "lf2/icon_star.png" }
   121               slot.put(" ", encode.html(_"Add my interest"))
   122             end 
   123           }
   124         end }
   126       end
   127     end
   128   end } end }
   130   ui.box_row{ class = "delegation hoverbutton_container", content = function() ui.box_col{ content = function()
   131     if delegation then
   132       if delegation.issue_id then
   133         slot.put(encode.html(_"You have delegated this issue"))
   134       elseif delegation.area_id then
   135         slot.put(encode.html(_"You have delegated this area"))
   136       elseif delegation then
   137         slot.put(encode.html(_"You have delegated globally"))
   138       end
   139     else
   140       slot.put(encode.html(_"No delegation active"))
   141     end
   143     if issue.closed then
   144       ui.container{ attr = { class = "hoverbutton noaction"}, content = function()
   145         ui.container{ attr = { class = "content"}, content = function()
   146           slot.put(" ", encode.html(_"This issue is closed"))
   147         end }
   148       end }
   149     else
   150       if delegation then
   151         ui.link{ attr = { class = "hoverbutton red"}, content = function()
   152           ui.container{ attr = { class = "content"}, content = function()
   153             ui.image{ static = "lf2/icon_delegation.png" }
   154             slot.put(" ", encode.html(_"Change delegation..."))
   155           end }
   156         end }
   158       else
   159         ui.link{ attr = { class = "hoverbutton green"}, content = function()
   160           ui.container{ attr = { class = "content"}, content = function()
   161             ui.image{ static = "lf2/icon_delegation.png" }
   162             slot.put(" ", encode.html(_"Delegate issue"))
   163           end }
   164         end }
   166       end
   167     end
   169   end } end }
   171   if delegation then
   172     ui.box_row{ class = "delegation", content = function() ui.box_col{ content = function()
   173       execute.view{ module = "lf2", view = "_avatars", params = { members = trustees, arrows = true, size = "small" } }
   174     end } end }
   175   end
   177 end }
