liquid_feedback_frontend
view app/main/lf2/initiative.lua @ 217:73dbc9e2bfd4
Cummulative patch for enhancements at next generation frontend
| author | bsw | 
|---|---|
| date | Sat Mar 12 19:22:50 2011 +0100 (2011-03-12) | 
| parents | 4f6e6b213fb8 | 
| 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 initiative = Initiative:by_id(param.get_id())
     8 local issue = initiative.issue
     9 issue:load("interest_for_member", { member_id = app.session.member_id }, "interest")
    11 local supporting_members_selector = Member:new_selector()
    12   :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 })
    13   :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 })
    14   :add_field("dis.weight", "weight")
    15   :add_order_by("dis.weight DESC")
    16 local supporting_members = supporting_members_selector:exec()
    18 local voting_members_selector = Member:new_selector()
    19   :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id })
    20   :add_field("direct_voter.weight", "weight")
    21   :add_order_by("direct_voter.weight DESC")
    22 local voting_members = voting_members_selector:exec()
    24 local alternative_initiatives = initiative.issue.initiatives
    25 alternative_initiatives:load("initiating_members", nil, "initiating_members")
    27 local support = Supporter:by_pk(initiative.id, app.session.member.id)
    29 app.topnav_phase = issue.phase
    30 app.topnav_area_id = issue.area_id
    31 app.topnav_unit_id = issue.area.unit_id
    33 slot.select("sidebar", function()
    35   execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id, alternative_initiatives = alternative_initiatives } }
    37   execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
    38     initiative = initiative
    39   } }
    41 end)
    43 local draft = initiative.current_draft
    45 ui.box{
    46   content = function()
    48     ui.box_row{ class = "initiative head", content = function() ui.box_col { content = function()
    49       execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
    50     end } end }
    52     if initiative.issue.closed then
    53       ui.box_row{ content = function() ui.box_col{ content = function()
    54         if initiative.issue.accepted then
    55           if initiative.admitted then
    56             if initiative.agreed then
    57               if initiative.rank == 1 then
    58                 ui.image{ static = "lf2/icon_award_gold.png" }
    59                 slot.put(" ")
    60                 ui.tag{ content = _"Approved" }
    61              else
    62                 ui.image{ static = "lf2/icon_award_silver.png" }
    63                 slot.put(" ")
    64                 ui.tag{ content = _("Not approved (rank #{rank})", { rank = initiative.rank }) }
    65               end
    66             else
    67             ui.image{ static = "lf2/icon_cross.png" }
    68             slot.put(" ")
    69             ui.tag{ content = _"Initiative not approved (no majority)" }
    70             end
    71             slot.put(" · ")
    72             ui.tag{ class = "yes_count", content = _("#{count} Yes", { count = initiative.positive_votes }) }
    73             slot.put(" · ")
    74             ui.tag{ class = "no_count", content = _("#{count} No", { count = initiative.negative_votes }) }
    75             slot.put(" · ")
    76             ui.tag{ class = "abstention_count", content = _("#{count} Abstention", { count = initiative.issue.voter_count - initiative.positive_votes - initiative.negative_votes }) }
    78           else
    79             ui.image{ static = "lf2/icon_cross.png" }
    80             slot.put(" ")
    81             ui.tag{ content = _"Initiative not admitted (quorum failed)" }
    82           end
    83         else
    84         ui.image{ static = "lf2/icon_cross.png" }
    85         slot.put(" ")
    86         ui.tag{ content = _"Issue not accepted (quorum failed)" }
    87         end
    88       end } end }
    89     end
    91     ui.box_row{ class = "", content = function() ui.box_col{ content = function()
    92       if initiative.issue.fully_frozen and initiative.issue.closed then
    93         if initiative.admitted and initiative.issue.ranks_available then
    94           ui.link{ external = "#votes", text = _("#{vote_count}+#{delegated_weight} votes", { vote_count = #voting_members, delegated_weight = initiative.issue.voter_count - #voting_members }) }
    95           slot.put(" · ")
    96         end
    97       end
    98       ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 })  }
    99       slot.put(" · ")
   100       ui.link{ external = "#supporters", text = _("#{supporter_count}+#{delegated_weight} supporters", { supporter_count = #supporting_members, delegated_weight = initiative.supporter_count - #supporting_members }) }
   101     end } end }
   103     execute.view{ module = "lf2", view = "_initiative_support", params = {
   104       initiative = initiative
   105     } }
   107     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Current draft" } end }
   108     ui.box_row{ class = "member_content", content = function() ui.box_col{ class = "draft", content = function()
   109       execute.view{ module = "lf2", view = "_draft", params = { draft = draft } }
   110     end } end }
   112     if initiative.issue.fully_frozen and initiative.issue.closed then
   113       ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Voters" } end }
   114       ui.box_row{ content = function() ui.box_col{ content = function()
   115         execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members, issue_id = initiative.issue_id } }
   116       end } end }
   117     end
   119     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Suggestions" } end }
   120     ui.box_row{ content = function() ui.box_col{ content = function()
   121       slot.put("suggestions")
   122     end } end }
   124     ui.box_row{ class = "subhead", content = function() ui.box_col{ class = "head", content = _"Supporters" } end }
   125     ui.box_row{ content = function() ui.box_col{ content = function()
   126       execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members, issue_id = initiative.issue_id } }
   127     end } end }
   129 end }
