liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 552:3344717939f0

Improved interest and support filters for issues
author bsw
date Fri Jun 15 20:46:25 2012 +0200 (2012-06-15)
parents c1dc3b14a4f3
children 53f93f0ffa6e
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@551 62 if initiative.member_info.initiated 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@551 68 elseif initiative.member_info.directly_supported then
bsw@551 69 if initiative.member_info.satisfied then
bsw@551 70 local label = _"You are supporter of this initiative"
bsw@551 71 ui.image{
bsw@551 72 attr = { alt = label, title = label },
bsw@551 73 static = "icons/16/thumb_up_green.png"
bsw@551 74 }
bsw@551 75 else
bsw@551 76 local label = _"You are potential supporter of this initiative"
bsw@551 77 ui.image{
bsw@551 78 attr = { alt = label, title = label },
bsw@551 79 static = "icons/16/thumb_up.png"
bsw@551 80 }
bsw@551 81 end
bsw@551 82 elseif initiative.member_info.supported then
bsw@551 83 if initiative.member_info.satisfied then
bsw@551 84 local label = _"You are supporter of this initiative via delegation"
bsw@551 85 ui.image{
bsw@551 86 attr = { alt = label, title = label },
bsw@551 87 static = "icons/16/thumb_up_green_arrow.png"
bsw@551 88 }
bsw@551 89 else
bsw@551 90 local label = _"You are potential supporter of this initiative via delegation"
bsw@551 91 ui.image{
bsw@551 92 attr = { alt = label, title = label },
bsw@551 93 static = "icons/16/thumb_up_arrow.png"
bsw@551 94 }
bsw@551 95 end
bsw@373 96 end
bsw@373 97 end }
bsw@373 98
bsw@373 99 ui.container{ attr = { class = "name" }, content = function()
bsw@373 100 local link_class = "initiative_link"
bsw@373 101 if initiative.revoked then
bsw@373 102 link_class = "revoked"
bsw@373 103 end
bsw@373 104 if selected then
bsw@373 105 link_class = link_class .. " selected"
bsw@373 106 end
bsw@373 107 if initiative.is_supporter then
bsw@373 108 link_class = link_class .. " supported"
bsw@373 109 end
bsw@373 110 if initiative.is_potential_supporter then
bsw@373 111 link_class = link_class .. " potentially_supported"
bsw@373 112 end
bsw@373 113 if initiative.is_supporter_via_delegation then
bsw@373 114 link_class = link_class .. " supported"
bsw@373 115 end
bsw@373 116 ui.link{
bsw@373 117 attr = { class = link_class },
bsw@345 118 content = function()
bsw@373 119 local name
bsw@373 120 if initiative.name_highlighted then
bsw@373 121 name = encode.highlight(initiative.name_highlighted)
bsw@373 122 else
bsw@373 123 name = encode.html(initiative.shortened_name)
bsw@345 124 end
bsw@373 125 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@373 126 slot.put(name)
bsw@373 127 end,
bsw@373 128 module = "initiative",
bsw@373 129 view = "show",
bsw@373 130 id = initiative.id
bsw@345 131 }
bsw@373 132
bsw@373 133 end }
bsw@373 134
bsw@534 135 end }

Impressum / About Us