liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 549:42d070777353

Optimized fetching of calculated state_time_left attribute of issue
author bsw
date Tue May 29 20:52:20 2012 +0200 (2012-05-29)
parents 3e4f6534bb15
children c1dc3b14a4f3
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
bsw@373 5 ui.container{ attr = { class = "initiative" }, content = function()
bsw/jbe@19 6
bsw@373 7 ui.container{ attr = { class = "rank" }, content = function()
bsw@373 8 if initiative.issue.accepted and initiative.issue.closed
bsw@373 9 and initiative.issue.ranks_available or initiative.admitted == false
bsw@373 10 then
bsw@373 11 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
bsw@414 12 elseif not initiative.issue.closed then
bsw@414 13 ui.image{ static = "icons/16/script.png" }
bsw@373 14 else
bsw@414 15 ui.image{ static = "icons/16/cross.png" }
bsw@373 16 end
bsw@373 17 end }
bsw@373 18
bsw@373 19 ui.container{ attr = { class = "bar" }, content = function()
bsw@373 20 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@373 21 if initiative.issue.ranks_available then
bsw@373 22 if initiative.negative_votes and initiative.positive_votes then
bsw@373 23 local max_value = initiative.issue.voter_count
bsw@345 24 ui.bargraph{
bsw@345 25 max_value = max_value,
bsw@345 26 width = 100,
bsw@345 27 bars = {
bsw@373 28 { color = "#0a0", value = initiative.positive_votes },
bsw@373 29 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
bsw@373 30 { color = "#a00", value = initiative.negative_votes },
bsw/jbe@19 31 }
bsw/jbe@19 32 }
bsw@373 33 else
bsw@345 34 slot.put(" ")
bsw@345 35 end
bsw@373 36 else
bsw@373 37 slot.put(_"Counting of votes")
bsw/jbe@19 38 end
bsw@373 39 else
bsw@373 40 local max_value = initiative.issue.population or 0
bsw@534 41 local quorum
bsw@534 42 if initiative.issue.accepted then
bsw@534 43 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
bsw@534 44 else
bsw@534 45 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
bsw@534 46 end
bsw@373 47 ui.bargraph{
bsw@373 48 max_value = max_value,
bsw@373 49 width = 100,
bsw@534 50 quorum = max_value * quorum,
bsw@373 51 quorum_color = "#00F",
bsw@373 52 bars = {
bsw@373 53 { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) },
bsw@501 54 { color = "#999", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
bsw@501 55 { color = "#ddd", value = max_value - (initiative.supporter_count or 0) },
bsw@373 56 }
bsw/jbe@19 57 }
bsw/jbe@19 58 end
bsw@373 59 end }
bsw@373 60
bsw@373 61 ui.container{ attr = { class = "interest" }, content = function()
bsw@373 62 if initiative.is_initiator then
bsw@373 63 local label = _"You are initiator of this initiative"
bsw@373 64 ui.image{
bsw@373 65 attr = { alt = label, title = label },
bsw@373 66 static = "icons/16/user_edit.png"
bsw@373 67 }
bsw@373 68 elseif initiative.is_supporter then
bsw@373 69 local label = _"You are supporter of this initiative"
bsw@373 70 ui.image{
bsw@373 71 attr = { alt = label, title = label },
bsw@373 72 static = "icons/16/thumb_up_green.png"
bsw@373 73 }
bsw@373 74 elseif initiative.is_potential_supporter then
bsw@373 75 local label = _"You are potentially supporter of this initiative"
bsw@373 76 ui.image{
bsw@373 77 attr = { alt = label, title = label },
bsw@373 78 static = "icons/16/thumb_up.png"
bsw@373 79 }
bsw@373 80 elseif initiative.is_supporter_via_delegation then
bsw@373 81 local label = _"You are supporter of this initiative via delegation"
bsw@373 82 ui.image{
bsw@373 83 attr = { alt = label, title = label },
bsw@373 84 static = "icons/16/thumb_up_green.png"
bsw@373 85 }
bsw@373 86 end
bsw@373 87 end }
bsw@373 88
bsw@373 89 ui.container{ attr = { class = "name" }, content = function()
bsw@373 90 local link_class = "initiative_link"
bsw@373 91 if initiative.revoked then
bsw@373 92 link_class = "revoked"
bsw@373 93 end
bsw@373 94 if selected then
bsw@373 95 link_class = link_class .. " selected"
bsw@373 96 end
bsw@373 97 if initiative.is_supporter then
bsw@373 98 link_class = link_class .. " supported"
bsw@373 99 end
bsw@373 100 if initiative.is_potential_supporter then
bsw@373 101 link_class = link_class .. " potentially_supported"
bsw@373 102 end
bsw@373 103 if initiative.is_supporter_via_delegation then
bsw@373 104 link_class = link_class .. " supported"
bsw@373 105 end
bsw@373 106 ui.link{
bsw@373 107 attr = { class = link_class },
bsw@345 108 content = function()
bsw@373 109 local name
bsw@373 110 if initiative.name_highlighted then
bsw@373 111 name = encode.highlight(initiative.name_highlighted)
bsw@373 112 else
bsw@373 113 name = encode.html(initiative.shortened_name)
bsw@345 114 end
bsw@373 115 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@373 116 slot.put(name)
bsw@373 117 end,
bsw@373 118 module = "initiative",
bsw@373 119 view = "show",
bsw@373 120 id = initiative.id
bsw@345 121 }
bsw@373 122
bsw@373 123 end }
bsw@373 124
bsw@534 125 end }

Impressum / About Us