liquid_feedback_frontend

annotate app/main/lf2/initiative.lua @ 213:acf92c2d33f4

Seperated css and fixed issue delegations for second generation frontend
author bsw
date Thu Mar 03 21:26:35 2011 +0100 (2011-03-03)
parents 3e4ad069847a
children 1dab81353eb1
rev   line source
bsw@211 1 slot.set_layout("lf2")
bsw@211 2
bsw@213 3 slot.put_into("leftright_pre", '<div class="sidebar_right">')
bsw@213 4 slot.put_into("leftright_post", '</div>')
bsw@213 5
bsw@211 6 local initiative = Initiative:by_id(param.get_id())
bsw@211 7
bsw@211 8 local issue = initiative.issue
bsw@213 9 issue:load("interest_for_member", { member_id = app.session.member_id }, "interest")
bsw@211 10
bsw@211 11 local supporting_members_selector = Member:new_selector()
bsw@211 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 })
bsw@211 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 })
bsw@211 14 :add_field("dis.weight", "weight")
bsw@211 15 :add_order_by("dis.weight DESC")
bsw@211 16 local supporting_members = supporting_members_selector:exec()
bsw@211 17
bsw@211 18 local voting_members_selector = Member:new_selector()
bsw@211 19 :join("direct_voter", nil, { "direct_voter.issue_id = ? AND direct_voter.member_id = member.id", issue.id })
bsw@211 20 :add_field("direct_voter.weight", "weight")
bsw@211 21 :add_order_by("direct_voter.weight DESC")
bsw@211 22 local voting_members = voting_members_selector:exec()
bsw@211 23
bsw@211 24 local alternative_initiatives = initiative.issue.initiatives
bsw@211 25 alternative_initiatives:load("initiating_members", nil, "initiating_members")
bsw@211 26
bsw@211 27
bsw@211 28 slot.select("sidebar", function()
bsw@211 29
bsw@213 30 execute.view{ module = "lf2", view = "_sidebar_issue", params = { issue = issue, initiative_id = initiative.id } }
bsw@211 31
bsw@211 32 execute.view{ module = "lf2", view = "_sidebar_initiatives", params = {
bsw@212 33 initiatives = alternative_initiatives,
bsw@212 34 head_content = function() ui.tag{ content = _"Alternative initiatives" } end
bsw@211 35 } }
bsw@211 36
bsw@211 37 execute.view{ module = "lf2", view = "_sidebar_drafts", params = {
bsw@211 38 initiative = initiative
bsw@211 39 } }
bsw@211 40
bsw@211 41 end)
bsw@211 42
bsw@211 43 local draft = initiative.current_draft
bsw@211 44
bsw@211 45 ui.box{
bsw@211 46 content = function()
bsw@211 47
bsw@211 48 ui.box_row{ class = "initiative head", content = function() ui.box_col { content = function()
bsw@211 49 execute.view{ module = "lf2", view = "_initiative", params = { initiative = initiative } }
bsw@211 50 end } end }
bsw@211 51
bsw@211 52 ui.box_row{ class = "head2", content = function() ui.box_col{ content = function()
bsw@211 53 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@211 54 ui.link{ external = "#votes", text = _("#{vote_count} votes", { vote_count = #voting_members }) }
bsw@211 55 slot.put(" &middot; ")
bsw@211 56 end
bsw@211 57 ui.link{ external = "#suggestions", text = _("#{suggestion_count} suggestions", { suggestion_count = 23 }) }
bsw@211 58 slot.put(" &middot; ")
bsw@211 59 ui.link{ external = "#supporters", text = _("#{supporter_count} supporters", { supporter_count = #supporting_members }) }
bsw@211 60 end } end }
bsw@211 61
bsw@211 62 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@211 63 execute.view{ module = "lf2", view = "_draft", params = { draft = draft } }
bsw@211 64 end } end }
bsw@211 65 end
bsw@211 66 }
bsw@211 67
bsw@211 68 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@211 69 ui.boxhead{ name = "votes", content = _"Votes" }
bsw@211 70 ui.box{
bsw@211 71 content = function()
bsw@211 72 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@211 73 execute.view{ module = "lf2", view = "_avatars", params = { members = voting_members } }
bsw@211 74 end } end }
bsw@211 75 end
bsw@211 76 }
bsw@211 77 end
bsw@211 78
bsw@211 79 ui.boxhead{ name = "suggestions", content = _"Suggestions" }
bsw@211 80 ui.box{
bsw@211 81 content = function()
bsw@211 82 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@211 83 slot.put("suggestions")
bsw@211 84 end } end }
bsw@211 85 end
bsw@211 86 }
bsw@211 87
bsw@211 88 ui.boxhead{ name = "supporters", content = _"Supporters" }
bsw@211 89 ui.box{
bsw@211 90 content = function()
bsw@211 91 ui.box_row{ content = function() ui.box_col{ content = function()
bsw@211 92 execute.view{ module = "lf2", view = "_avatars", params = { members = supporting_members } }
bsw@211 93 end } end }
bsw@211 94 end
bsw@211 95 }
bsw@211 96

Impressum / About Us