| rev | 
   line source | 
| 
bsw@211
 | 
     1 slot.set_layout("lf2")
 | 
| 
bsw@211
 | 
     2 
 | 
| 
bsw@211
 | 
     3 local initiative = Initiative:by_id(param.get_id())
 | 
| 
bsw@211
 | 
     4 
 | 
| 
bsw@211
 | 
     5 local issue = initiative.issue
 | 
| 
bsw@211
 | 
     6 
 | 
| 
bsw@211
 | 
     7 local supporting_members_selector = Member:new_selector()
 | 
| 
bsw@211
 | 
     8   :join("direct_supporter_snapshot", "dss", { "dss.issue_id = ? AND dss.initiative_id = ? AND dss.member_id = member.id and dss.event = (select latest_snapshot_event from issue where id = ?)", issue.id, initiative.id, issue.id })
 | 
| 
bsw@211
 | 
     9   :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 })
 | 
| 
bsw@211
 | 
    10   :add_field("dis.weight", "weight")
 | 
| 
bsw@211
 | 
    11   :add_order_by("dis.weight DESC")
 | 
| 
bsw@211
 | 
    12 local supporting_members = supporting_members_selector:exec()
 | 
| 
bsw@211
 | 
    13 
 | 
| 
bsw@211
 | 
    14 local voting_members_selector = Member:new_selector()
 | 
| 
bsw@211
 | 
    15   :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id })
 | 
| 
bsw@211
 | 
    16   :add_field("direct_voter.weight", "weight")
 | 
| 
bsw@211
 | 
    17   :add_order_by("direct_voter.weight DESC")
 | 
| 
bsw@211
 | 
    18 local voting_members = voting_members_selector:exec()
 | 
| 
bsw@211
 | 
    19 
 | 
| 
bsw@211
 | 
    20 local alternative_initiatives = initiative.issue.initiatives
 | 
| 
bsw@211
 | 
    21 alternative_initiatives:load("initiating_members", nil, "initiating_members")
 | 
| 
bsw@211
 | 
    22 
 | 
| 
bsw@211
 | 
    23 
 | 
| 
bsw@211
 | 
    24 slot.select("sidebar", function()
 | 
| 
bsw@211
 | 
    25   
 | 
| 
bsw@211
 | 
    26   execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue } }
 | 
| 
bsw@211
 | 
    27   ui.container{ attr = { class = "boxhead" }, content = _"Alternative initiatives" }
 | 
| 
bsw@211
 | 
    28   
 | 
| 
bsw@211
 | 
    29   execute.view{ module = "lf2", view = "_sidebar_initiatives", params = {
 | 
| 
bsw@211
 | 
    30     initiatives = alternative_initiatives
 | 
| 
bsw@211
 | 
    31   } }
 | 
| 
bsw@211
 | 
    32   
 | 
| 
bsw@211
 | 
    33   execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
 | 
| 
bsw@211
 | 
    34     initiative = initiative
 | 
| 
bsw@211
 | 
    35   } }
 | 
| 
bsw@211
 | 
    36 
 | 
| 
bsw@211
 | 
    37 end)
 | 
| 
bsw@211
 | 
    38 
 | 
| 
bsw@211
 | 
    39 local draft = initiative.current_draft
 | 
| 
bsw@211
 | 
    40 
 | 
| 
bsw@211
 | 
    41 ui.box{
 | 
| 
bsw@211
 | 
    42   content = function()
 | 
| 
bsw@211
 | 
    43 
 | 
| 
bsw@211
 | 
    44     ui.box_row{ class = "initiative head", content = function() ui.box_col { content = function()
 | 
| 
bsw@211
 | 
    45       execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
 | 
| 
bsw@211
 | 
    46     end } end }
 | 
| 
bsw@211
 | 
    47     
 | 
| 
bsw@211
 | 
    48     ui.box_row{ class = "head2", content = function() ui.box_col{ content = function()
 | 
| 
bsw@211
 | 
    49       if initiative.issue.fully_frozen and initiative.issue.closed then
 | 
| 
bsw@211
 | 
    50         ui.link{ external = "#votes", text = _("#{vote_count} votes", { vote_count = #voting_members }) }
 | 
| 
bsw@211
 | 
    51         slot.put(" · ")
 | 
| 
bsw@211
 | 
    52       end
 | 
| 
bsw@211
 | 
    53       ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 })  }
 | 
| 
bsw@211
 | 
    54       slot.put(" · ")
 | 
| 
bsw@211
 | 
    55       ui.link{ external = "#supporters", text = _("#{supporter_count} supporters", { supporter_count = #supporting_members }) }
 | 
| 
bsw@211
 | 
    56     end } end }
 | 
| 
bsw@211
 | 
    57 
 | 
| 
bsw@211
 | 
    58     ui.box_row{ content = function() ui.box_col{ content = function()
 | 
| 
bsw@211
 | 
    59       execute.view{ module = "lf2", view = "_draft", params = { draft = draft } }
 | 
| 
bsw@211
 | 
    60     end } end }
 | 
| 
bsw@211
 | 
    61   end
 | 
| 
bsw@211
 | 
    62 }
 | 
| 
bsw@211
 | 
    63 
 | 
| 
bsw@211
 | 
    64 if initiative.issue.fully_frozen and initiative.issue.closed then
 | 
| 
bsw@211
 | 
    65   ui.boxhead{ name = "votes", content = _"Votes" }
 | 
| 
bsw@211
 | 
    66   ui.box{
 | 
| 
bsw@211
 | 
    67     content = function()
 | 
| 
bsw@211
 | 
    68       ui.box_row{ content = function() ui.box_col{ content = function()
 | 
| 
bsw@211
 | 
    69         execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members } }
 | 
| 
bsw@211
 | 
    70       end } end }
 | 
| 
bsw@211
 | 
    71     end
 | 
| 
bsw@211
 | 
    72   }
 | 
| 
bsw@211
 | 
    73 end
 | 
| 
bsw@211
 | 
    74 
 | 
| 
bsw@211
 | 
    75 ui.boxhead{ name = "suggestions", content = _"Suggestions" }
 | 
| 
bsw@211
 | 
    76 ui.box{
 | 
| 
bsw@211
 | 
    77   content = function()
 | 
| 
bsw@211
 | 
    78     ui.box_row{ content = function() ui.box_col{ content = function()
 | 
| 
bsw@211
 | 
    79       slot.put("suggestions")
 | 
| 
bsw@211
 | 
    80     end } end }
 | 
| 
bsw@211
 | 
    81   end
 | 
| 
bsw@211
 | 
    82 }
 | 
| 
bsw@211
 | 
    83     
 | 
| 
bsw@211
 | 
    84 ui.boxhead{ name = "supporters", content = _"Supporters" }
 | 
| 
bsw@211
 | 
    85 ui.box{
 | 
| 
bsw@211
 | 
    86   content = function()
 | 
| 
bsw@211
 | 
    87     ui.box_row{ content = function() ui.box_col{ content = function()
 | 
| 
bsw@211
 | 
    88       execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members } }
 | 
| 
bsw@211
 | 
    89     end } end }
 | 
| 
bsw@211
 | 
    90   end
 | 
| 
bsw@211
 | 
    91 }
 | 
| 
bsw@211
 | 
    92     
 |