liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 359:5831e41daa61

Fixed typo
author bsw
date Wed Feb 29 22:53:20 2012 +0100 (2012-02-29)
parents 7d6a3c411f99
children 76d7eafb3893
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw@274 2 local selected = param.get("selected", atom.boolean)
bsw/jbe@19 3
bsw@345 4 ui.list{
bsw@345 5 attr = { class = "nohover" },
bsw@345 6 records = { { a = 1} },
bsw@345 7 columns = {
bsw@345 8 {
bsw@345 9 field_attr = { style = "width: 3em; text-align: center;"},
bsw/jbe@19 10 content = function()
bsw@345 11 if
bsw@345 12 initiative.issue.accepted and initiative.issue.closed
bsw@345 13 and initiative.issue.ranks_available or initiative.admitted == false
bsw@345 14 then
bsw@345 15 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
bsw@345 16 else
bsw@345 17 slot.put(" ")
bsw@345 18 end
bsw@345 19 end
bsw@345 20 },
bsw/jbe@19 21
bsw@345 22 {
bsw@345 23 field_attr = { style = "width: 100px;"},
bsw@345 24 content = function()
bsw@345 25 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@345 26 if initiative.issue.ranks_available then
bsw@345 27 if initiative.negative_votes and initiative.positive_votes then
bsw@345 28 local max_value = initiative.issue.voter_count
bsw@345 29 ui.bargraph{
bsw@345 30 max_value = max_value,
bsw@345 31 width = 100,
bsw@345 32 bars = {
bsw@345 33 { color = "#0a0", value = initiative.positive_votes },
bsw@345 34 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
bsw@345 35 { color = "#a00", value = initiative.negative_votes },
bsw@29 36 }
bsw@345 37 }
bsw@345 38 else
bsw@345 39 slot.put(" ")
bsw@345 40 end
bsw@345 41 else
bsw@345 42 slot.put(_"Counting of votes")
bsw@345 43 end
bsw@345 44 else
bsw@345 45 local max_value = initiative.issue.population or 0
bsw@345 46 ui.bargraph{
bsw@345 47 max_value = max_value,
bsw@345 48 width = 100,
bsw@345 49 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
bsw@345 50 quorum_color = "#00F",
bsw@345 51 bars = {
bsw@345 52 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
bsw@345 53 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
bsw@345 54 { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
bsw/jbe@19 55 }
bsw/jbe@19 56 }
bsw/jbe@19 57 end
bsw@345 58 end
bsw@345 59 },
bsw@345 60 {
bsw@345 61 field_attr = { style = "width: 24px;" },
bsw@345 62 content = function()
bsw@345 63 if initiative.is_initiator then
bsw@345 64 slot.put(" ")
bsw@345 65 local label = _"You are initiator of this initiative"
bsw@345 66 ui.image{
bsw@345 67 attr = { alt = label, title = label },
bsw@345 68 static = "icons/16/user_edit.png"
bsw@345 69 }
bsw@345 70 elseif initiative.is_supporter then
bsw@345 71 slot.put(" ")
bsw@345 72 local label = _"You are supporter of this initiative"
bsw@345 73 ui.image{
bsw@345 74 attr = { alt = label, title = label },
bsw@345 75 static = "icons/16/thumb_up_green.png"
bsw@345 76 }
bsw@345 77 elseif initiative.is_potential_supporter then
bsw@345 78 slot.put(" ")
bsw@345 79 local label = _"You are potentially supporter of this initiative"
bsw@345 80 ui.image{
bsw@345 81 attr = { alt = label, title = label },
bsw@345 82 static = "icons/16/thumb_up.png"
bsw@345 83 }
bsw@345 84 elseif initiative.is_supporter_via_delegation then
bsw@345 85 slot.put(" ")
bsw@345 86 local label = _"You are supporter of this initiative via delegation"
bsw@345 87 ui.image{
bsw@345 88 attr = { alt = label, title = label },
bsw@345 89 static = "icons/16/thumb_up_green.png"
bsw@345 90 }
bsw@345 91 end
bsw@345 92
bsw@345 93 end
bsw@345 94 },
bsw@345 95 {
bsw@345 96 content = function()
bsw@345 97 local link_class = "initiative_link"
bsw@345 98 if initiative.revoked then
bsw@345 99 link_class = "revoked"
bsw@345 100 end
bsw@345 101 if selected then
bsw@345 102 link_class = link_class .. " selected"
bsw@345 103 end
bsw@345 104 if initiative.is_supporter then
bsw@345 105 link_class = link_class .. " supported"
bsw@345 106 end
bsw@345 107 if initiative.is_potential_supporter then
bsw@345 108 link_class = link_class .. " potentially_supported"
bsw@345 109 end
bsw@345 110 if initiative.is_supporter_via_delegation then
bsw@345 111 link_class = link_class .. " supported"
bsw@345 112 end
bsw@345 113 ui.link{
bsw@345 114 attr = { class = link_class },
bsw@345 115 content = function()
bsw@345 116 local name
bsw@345 117 if initiative.name_highlighted then
bsw@345 118 name = encode.highlight(initiative.name_highlighted)
bsw@345 119 else
bsw@345 120 name = encode.html(initiative.shortened_name)
bsw@345 121 end
bsw@345 122 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@345 123 slot.put(name)
bsw@345 124 end,
bsw@345 125 module = "initiative",
bsw@345 126 view = "show",
bsw@345 127 id = initiative.id
bsw@345 128 }
bsw@345 129
bsw@345 130 end
bsw@345 131 }
bsw/jbe@19 132 }
bsw@345 133 }

Impressum / About Us