liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 323:b4a438ca7756

Reverting to hextriplets
author bsw
date Tue Feb 28 16:08:51 2012 +0100 (2012-02-28)
parents 9c639a2f3262
children 0ec49ed35954
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/jbe@19 4 local head_name = "initiative_head_" .. tostring(initiative.id)
bsw/jbe@19 5 local link_name = "initiative_link_" .. tostring(initiative.id)
bsw/jbe@19 6 local name = "initiative_content_" .. tostring(initiative.id)
bsw/jbe@19 7 local icon_name = "initiative_icon_" .. tostring(initiative.id)
bsw/jbe@19 8
bsw/jbe@19 9 ui.container{
bsw/jbe@19 10 attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") },
bsw/jbe@19 11 content = function()
bsw/jbe@19 12 local module = "initiative"
bsw/jbe@19 13 local view = "show"
bsw/jbe@19 14 local id = initiative.id
bsw/jbe@19 15 local params = {}
bsw/jbe@19 16 ui.container{
bsw/jbe@19 17 attr = {
bsw/jbe@19 18 name = name,
bsw/jbe@19 19 class = "ui_tabs_accordeon_head",
bsw/jbe@19 20 id = head_name,
bsw/jbe@19 21 },
bsw/jbe@19 22 content = function()
bsw/jbe@19 23
bsw@29 24 ui.list{
bsw@29 25 attr = { class = "nohover" },
bsw@29 26 records = { { a = 1} },
bsw@29 27 columns = {
bsw@29 28 {
bsw@280 29 field_attr = { style = "width: 3em; text-align: center;"},
bsw@29 30 content = function()
bsw@29 31 if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then
bsw@29 32 ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank }
bsw@29 33 else
bsw@29 34 slot.put(" ")
bsw@29 35 end
bsw@29 36 end
bsw@29 37 },
bsw/jbe@19 38
bsw@29 39 {
bsw@312 40 field_attr = { style = "width: 100px;"},
bsw@29 41 content = function()
bsw/jbe@48 42 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@29 43 if initiative.issue.ranks_available then
bsw@29 44 if initiative.negative_votes and initiative.positive_votes then
bsw@29 45 local max_value = initiative.issue.voter_count
bsw@29 46 ui.bargraph{
bsw@29 47 max_value = max_value,
bsw@29 48 width = 100,
bsw@29 49 bars = {
bsw@29 50 { color = "#0a0", value = initiative.positive_votes },
bsw@29 51 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
bsw@29 52 { color = "#a00", value = initiative.negative_votes },
bsw@29 53 }
bsw@29 54 }
bsw@29 55 else
bsw@29 56 slot.put(" ")
bsw@29 57 end
bsw@29 58 else
bsw@29 59 slot.put(_"Counting of votes")
bsw@29 60 end
bsw@273 61 else
bsw@273 62 local max_value = initiative.issue.population or 0
bsw/jbe@19 63 ui.bargraph{
bsw/jbe@19 64 max_value = max_value,
bsw/jbe@19 65 width = 100,
poelzi@159 66 quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den),
poelzi@159 67 quorum_color = "#00F",
bsw/jbe@19 68 bars = {
bsw@29 69 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
bsw@29 70 { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
bsw@317 71 { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) },
bsw/jbe@19 72 }
bsw/jbe@19 73 }
bsw/jbe@19 74 end
bsw/jbe@19 75 end
bsw@29 76 },
bsw@312 77 {
bsw@312 78 field_attr = { style = "width: 24px;" },
bsw@312 79 content = function()
bsw@312 80 if initiative.is_initiator then
bsw@312 81 slot.put(" ")
bsw@312 82 local label = _"You are initiator of this initiative"
bsw@312 83 ui.image{
bsw@312 84 attr = { alt = label, title = label },
bsw@312 85 static = "icons/16/user_edit.png"
bsw@312 86 }
bsw@312 87 elseif initiative.is_supporter then
bsw@312 88 slot.put(" ")
bsw@312 89 local label = _"You are supporter of this initiative"
bsw@312 90 ui.image{
bsw@312 91 attr = { alt = label, title = label },
bsw@312 92 static = "icons/16/thumb_up_green.png"
bsw@312 93 }
bsw@312 94 elseif initiative.is_potential_supporter then
bsw@312 95 slot.put(" ")
bsw@312 96 local label = _"You are potentially supporter of this initiative"
bsw@312 97 ui.image{
bsw@312 98 attr = { alt = label, title = label },
bsw@312 99 static = "icons/16/thumb_up.png"
bsw@312 100 }
bsw@312 101 elseif initiative.is_supporter_via_delegation then
bsw@312 102 slot.put(" ")
bsw@312 103 local label = _"You are supporter of this initiative via delegation"
bsw@312 104 ui.image{
bsw@312 105 attr = { alt = label, title = label },
bsw@312 106 static = "icons/16/thumb_up_green.png"
bsw@312 107 }
bsw@312 108 end
bsw@29 109
bsw@312 110 end
bsw@312 111 },
bsw@29 112 {
bsw/jbe@19 113 content = function()
bsw@274 114 local link_class = "initiative_link"
bsw@29 115 if initiative.revoked then
bsw@29 116 link_class = "revoked"
bsw/jbe@19 117 end
bsw@274 118 if selected then
bsw@274 119 link_class = link_class .. " selected"
bsw@274 120 end
bsw@274 121 if initiative.is_supporter then
bsw@274 122 link_class = link_class .. " supported"
bsw@274 123 end
bsw@274 124 if initiative.is_potential_supporter then
bsw@274 125 link_class = link_class .. " potentially_supported"
bsw@274 126 end
bsw@285 127 if initiative.is_supporter_via_delegation then
bsw@285 128 link_class = link_class .. " supported"
bsw@285 129 end
bsw@29 130 ui.link{
bsw@29 131 attr = { id = link_name, class = link_class },
bsw@29 132 content = function()
bsw@29 133 local name
bsw@29 134 if initiative.name_highlighted then
bsw@29 135 name = encode.highlight(initiative.name_highlighted)
bsw@29 136 else
bsw@29 137 name = encode.html(initiative.shortened_name)
bsw@29 138 end
bsw@274 139 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@29 140 slot.put(name)
bsw@29 141 end,
bsw@29 142 module = module,
bsw@29 143 view = view,
bsw@29 144 id = id,
bsw@29 145 params = params,
bsw@29 146 }
bsw@292 147
bsw@29 148 end
bsw/jbe@19 149 }
bsw/jbe@19 150 }
bsw@29 151 }
bsw/jbe@19 152 end
bsw/jbe@19 153 }
bsw/jbe@19 154 end
bsw/jbe@19 155 }
bsw/jbe@19 156
bsw/jbe@19 157 if ui.is_partial_loading_enabled() then
bsw/jbe@19 158 ui.container{
bsw/jbe@19 159 attr = {
bsw/jbe@19 160 id = name,
bsw/jbe@19 161 class = "ui_tabs_accordeon_content",
bsw/jbe@19 162 },
bsw/jbe@19 163 content = function()
bsw/jbe@19 164 ui.container{
bsw/jbe@19 165 attr = { id = name .. "_content", style = "clear: left;" },
bsw/jbe@19 166 content = function()
bsw/jbe@19 167 execute.view{
bsw/jbe@19 168 module = "initiative",
bsw/jbe@19 169 view = "show_partial",
bsw/jbe@19 170 params = {
bsw/jbe@19 171 initiative = initiative,
bsw/jbe@19 172 }
bsw/jbe@19 173 }
bsw/jbe@19 174 end
bsw/jbe@19 175 }
bsw/jbe@19 176 end
bsw/jbe@19 177 }
bsw/jbe@19 178 end

Impressum / About Us