liquid_feedback_frontend

diff app/main/lf2/_issue_initiatives.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 1dab81353eb1
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/lf2/_issue_initiatives.lua	Wed Mar 02 20:06:26 2011 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +local initiatives = param.get("initiatives", "table")
     1.5 +
     1.6 +for i, initiative in ipairs(initiatives) do
     1.7 +
     1.8 +  local first = ""
     1.9 +  if i == 1 then first = " first" end
    1.10 +  
    1.11 +  ui.box_row{ class = "initiative" .. first, content = function() ui.box_col { content = function()
    1.12 +
    1.13 +    ui.link{ 
    1.14 +      module = "lf2", view = "initiative", id = initiative.id,
    1.15 +      params = { tab = "draft" }, attr = { class = "name" }, 
    1.16 +      text = initiative.name
    1.17 +    }
    1.18 +
    1.19 +    ui.container{ attr = { class = "bar" }, content = function()
    1.20 +      if initiative.issue.fully_frozen and initiative.issue.closed then
    1.21 +        if initiative.issue.ranks_available then 
    1.22 +          if initiative.negative_votes and initiative.positive_votes then
    1.23 +            local max_value = initiative.issue.voter_count
    1.24 +            ui.bargraph{
    1.25 +              max_value = max_value,
    1.26 +              width = 100,
    1.27 +              bars = {
    1.28 +                { color = "#0a0", value = initiative.positive_votes },
    1.29 +                { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
    1.30 +                { color = "#a00", value = initiative.negative_votes },
    1.31 +              }
    1.32 +            }
    1.33 +          else
    1.34 +            slot.put(" ")
    1.35 +          end
    1.36 +        else
    1.37 +          slot.put(_"Counting of votes")
    1.38 +        end
    1.39 +      elseif initiative.issue.population then
    1.40 +        local max_value = initiative.issue.population
    1.41 +        ui.bargraph{
    1.42 +          max_value = max_value,
    1.43 +          width = 100,
    1.44 +          quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
    1.45 +          quorum_color = "#00F",
    1.46 +          bars = {
    1.47 +            { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
    1.48 +            { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
    1.49 +            { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
    1.50 +          }
    1.51 +        }
    1.52 +      else
    1.53 +        slot.put(" ")
    1.54 +      end
    1.55 +    end }
    1.56 +
    1.57 +    ui.container{ attr = { class = "authors" }, content = function()
    1.58 +      local members = initiative.initiating_members
    1.59 +      slot.put(_"by", " ")
    1.60 +      for i, member in ipairs(members) do
    1.61 +        if i > 1 and i < #members then
    1.62 +          slot.put(", ")
    1.63 +        elseif i > 1 then
    1.64 +          slot.put(" ", _"and", " ")
    1.65 +        end
    1.66 +        ui.link{
    1.67 +          module = "lf2", view = "initiative", id = initiative.id,
    1.68 +          params = { member_id = member.id }, text = member.name
    1.69 +        }
    1.70 +      end
    1.71 +    end }
    1.72 +
    1.73 +  end } end }
    1.74 +
    1.75 +end
    1.76 \ No newline at end of file

Impressum / About Us