liquid_feedback_frontend

diff app/main/initiative/_sidebar_state.lua @ 1045:701a5cf6b067

Imported LiquidFeedback Frontend 3.0 branch
author bsw
date Thu Jul 10 01:19:48 2014 +0200 (2014-07-10)
parents
children ba47b1e9ab00
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/initiative/_sidebar_state.lua	Thu Jul 10 01:19:48 2014 +0200
     1.3 @@ -0,0 +1,111 @@
     1.4 +local initiative = param.get("initiative", "table")
     1.5 +
     1.6 +
     1.7 +-- voting results
     1.8 +if initiative.issue.fully_frozen and initiative.issue.closed and initiative.admitted
     1.9 +  and initiative.issue.voter_count then
    1.10 +  local class = initiative.winner and "sectionRow admitted_info" or "sectionRow not_admitted_info"
    1.11 +  ui.container{
    1.12 +    attr = { class = class },
    1.13 +    content = function()
    1.14 +      local max_value = initiative.issue.voter_count
    1.15 +      local positive_votes = initiative.positive_votes
    1.16 +      local negative_votes = initiative.negative_votes
    1.17 +      local abstention_votes = max_value - 
    1.18 +              negative_votes - 
    1.19 +              positive_votes
    1.20 +      local function perc(votes, sum)
    1.21 +        if sum > 0 then return string.format( "%.f", votes * 100 / sum ) .. "%" end
    1.22 +        return ""
    1.23 +      end
    1.24 +      local head_text
    1.25 +      if initiative.winner then
    1.26 +        head_text = _"Approved"
    1.27 +      elseif initiative.rank then
    1.28 +        head_text = _("Rejected (rank #{rank})", { rank = initiative.rank })
    1.29 +      else
    1.30 +        head_text = _"Rejected"
    1.31 +      end
    1.32 +
    1.33 +      util.initiative_pie( initiative )
    1.34 +      
    1.35 +      ui.heading { level = 1, content = head_text }
    1.36 +      
    1.37 +      ui.tag { tag = "table", content = function ()
    1.38 +        ui.tag { tag = "tr", attr = { class = "yes" }, content = function ()
    1.39 +          ui.tag { tag = "td", content = 
    1.40 +            tostring(positive_votes) 
    1.41 +          }
    1.42 +          ui.tag { tag = "th", content = _"Yes" }
    1.43 +          ui.tag { tag = "td", content = 
    1.44 +            perc(positive_votes, max_value) 
    1.45 +          }
    1.46 +          ui.tag { tag = "th", content = _"Yes" }
    1.47 +        end }
    1.48 +        ui.tag { tag = "tr", attr = { class = "abstention" }, content = function ()
    1.49 +          ui.tag { tag = "td", content = 
    1.50 +            tostring(abstention_votes)
    1.51 +          }
    1.52 +          ui.tag { tag = "th", content = _"Abstention" }
    1.53 +          ui.tag { tag = "td", content =
    1.54 +            perc(abstention_votes, max_value) 
    1.55 +          }
    1.56 +          ui.tag { tag = "th", content = _"Abstention" }
    1.57 +        end }
    1.58 +        ui.tag { tag = "tr", attr = { class = "no" }, content = function ()
    1.59 +          ui.tag { tag = "td", content = 
    1.60 +            tostring(negative_votes)
    1.61 +          }
    1.62 +          ui.tag { tag = "th", content = _"No" }
    1.63 +          ui.tag { tag = "td", content =
    1.64 +            perc(negative_votes, max_value) 
    1.65 +          }
    1.66 +          ui.tag { tag = "th", content = _"No" }
    1.67 +        end }
    1.68 +      end }
    1.69 +    end
    1.70 +  }
    1.71 +end
    1.72 +  
    1.73 +-- initiative not admitted info
    1.74 +if initiative.admitted == false then
    1.75 +  local policy = initiative.issue.policy
    1.76 +  ui.container{
    1.77 +    attr = { class = "sectionRow not_admitted_info" },
    1.78 +    content = function ()
    1.79 +      ui.heading { level = 1, content = _"Initiative not admitted" }
    1.80 +      ui.container { content = _("This initiative has not been admitted! It failed the 2nd quorum of #{quorum}.", { quorum = format.percentage ( policy.initiative_quorum_num / policy.initiative_quorum_den ) } ) }
    1.81 +    end
    1.82 +  }
    1.83 +end
    1.84 +
    1.85 +-- initiative revoked info
    1.86 +if initiative.revoked then
    1.87 +  ui.container{
    1.88 +    attr = { class = "sectionRow revoked_info" },
    1.89 +    content = function()
    1.90 +      ui.heading { level = 1, content = _"Initiative revoked" }
    1.91 +      slot.put(_("This initiative has been revoked at #{revoked} by:", {
    1.92 +        revoked = format.timestamp(initiative.revoked)
    1.93 +      }))
    1.94 +      slot.put(" ")
    1.95 +      ui.link{
    1.96 +        module = "member", view = "show", id = initiative.revoked_by_member_id,
    1.97 +        content = initiative.revoked_by_member.name
    1.98 +      }
    1.99 +      local suggested_initiative = initiative.suggested_initiative
   1.100 +      if suggested_initiative then
   1.101 +        slot.put("<br /><br />")
   1.102 +        slot.put(_("The initiators suggest to support the following initiative:"))
   1.103 +        slot.put("<br />")
   1.104 +        ui.link{
   1.105 +          content = suggested_initiative.display_name,
   1.106 +          module = "initiative",
   1.107 +          view = "show",
   1.108 +          id = suggested_initiative.id
   1.109 +        }
   1.110 +      end
   1.111 +    end
   1.112 +  }
   1.113 +end
   1.114 + 
   1.115 \ No newline at end of file

Impressum / About Us