liquid_feedback_frontend

view 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 source
1 local initiatives = param.get("initiatives", "table")
3 for i, initiative in ipairs(initiatives) do
5 local first = ""
6 if i == 1 then first = " first" end
8 ui.box_row{ class = "initiative" .. first, content = function() ui.box_col { content = function()
10 ui.link{
11 module = "lf2", view = "initiative", id = initiative.id,
12 params = { tab = "draft" }, attr = { class = "name" },
13 text = initiative.name
14 }
16 ui.container{ attr = { class = "bar" }, content = function()
17 if initiative.issue.fully_frozen and initiative.issue.closed then
18 if initiative.issue.ranks_available then
19 if initiative.negative_votes and initiative.positive_votes then
20 local max_value = initiative.issue.voter_count
21 ui.bargraph{
22 max_value = max_value,
23 width = 100,
24 bars = {
25 { color = "#0a0", value = initiative.positive_votes },
26 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
27 { color = "#a00", value = initiative.negative_votes },
28 }
29 }
30 else
31 slot.put(" ")
32 end
33 else
34 slot.put(_"Counting of votes")
35 end
36 elseif initiative.issue.population then
37 local max_value = initiative.issue.population
38 ui.bargraph{
39 max_value = max_value,
40 width = 100,
41 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
42 quorum_color = "#00F",
43 bars = {
44 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
45 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
46 { color = "#eee", value = max_value - (initiative.supporter_count or 0) },
47 }
48 }
49 else
50 slot.put(" ")
51 end
52 end }
54 ui.container{ attr = { class = "authors" }, content = function()
55 local members = initiative.initiating_members
56 slot.put(_"by", " ")
57 for i, member in ipairs(members) do
58 if i > 1 and i < #members then
59 slot.put(", ")
60 elseif i > 1 then
61 slot.put(" ", _"and", " ")
62 end
63 ui.link{
64 module = "lf2", view = "initiative", id = initiative.id,
65 params = { member_id = member.id }, text = member.name
66 }
67 end
68 end }
70 end } end }
72 end

Impressum / About Us