liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 280:808269b7f41c

More repositioning and optical enhancements
author bsw
date Thu Feb 16 14:08:55 2012 +0100 (2012-02-16)
parents fecd4c13054a
children 6c88b4bfb56c
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@280 40 field_attr = { style = "width: 110px;"},
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@29 71 { color = "#eee", 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@29 77
bsw@29 78 {
bsw/jbe@19 79 content = function()
bsw@274 80 local link_class = "initiative_link"
bsw@29 81 if initiative.revoked then
bsw@29 82 link_class = "revoked"
bsw/jbe@19 83 end
bsw@274 84 if selected then
bsw@274 85 link_class = link_class .. " selected"
bsw@274 86 end
bsw@274 87 if initiative.is_supporter then
bsw@274 88 link_class = link_class .. " supported"
bsw@274 89 end
bsw@274 90 if initiative.is_potential_supporter then
bsw@274 91 link_class = link_class .. " potentially_supported"
bsw@274 92 end
bsw@29 93 ui.link{
bsw@29 94 attr = { id = link_name, class = link_class },
bsw@29 95 content = function()
bsw@29 96 local name
bsw@29 97 if initiative.name_highlighted then
bsw@29 98 name = encode.highlight(initiative.name_highlighted)
bsw@29 99 else
bsw@29 100 name = encode.html(initiative.shortened_name)
bsw@29 101 end
bsw@274 102 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@29 103 slot.put(name)
bsw@29 104 end,
bsw@29 105 module = module,
bsw@29 106 view = view,
bsw@29 107 id = id,
bsw@29 108 params = params,
bsw@29 109 }
bsw@29 110
bsw@29 111 if initiative.is_initiator then
bsw@29 112 slot.put(" ")
mail@239 113 local label = _"You are initiator of this initiative"
bsw@29 114 ui.image{
bsw@29 115 attr = { alt = label, title = label },
bsw@29 116 static = "icons/16/user_edit.png"
bsw@29 117 }
bsw@29 118 end
bsw@29 119
bsw@29 120 end
bsw/jbe@19 121 }
bsw/jbe@19 122 }
bsw@29 123 }
bsw/jbe@19 124 end
bsw/jbe@19 125 }
bsw/jbe@19 126 end
bsw/jbe@19 127 }
bsw/jbe@19 128
bsw/jbe@19 129 if ui.is_partial_loading_enabled() then
bsw/jbe@19 130 ui.container{
bsw/jbe@19 131 attr = {
bsw/jbe@19 132 id = name,
bsw/jbe@19 133 class = "ui_tabs_accordeon_content",
bsw/jbe@19 134 },
bsw/jbe@19 135 content = function()
bsw/jbe@19 136 ui.container{
bsw/jbe@19 137 attr = { id = name .. "_content", style = "clear: left;" },
bsw/jbe@19 138 content = function()
bsw/jbe@19 139 execute.view{
bsw/jbe@19 140 module = "initiative",
bsw/jbe@19 141 view = "show_partial",
bsw/jbe@19 142 params = {
bsw/jbe@19 143 initiative = initiative,
bsw/jbe@19 144 }
bsw/jbe@19 145 }
bsw/jbe@19 146 end
bsw/jbe@19 147 }
bsw/jbe@19 148 end
bsw/jbe@19 149 }
bsw/jbe@19 150 end

Impressum / About Us