liquid_feedback_frontend

annotate app/main/initiative/_list_element.lua @ 898:ae9ab3edff89

Added polling support
author bsw
date Mon Aug 20 03:54:20 2012 +0200 (2012-08-20)
parents a1ff5d08f0f4
children c7215c18168b
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table")
bsw@274 2 local selected = param.get("selected", atom.boolean)
bsw@862 3 local for_member = param.get("for_member", "table") or app.session.member
bsw/jbe@19 4
bsw@715 5 local class = "initiative"
bsw/jbe@19 6
bsw@715 7 if selected then
bsw@715 8 class = class .. " selected"
bsw@715 9 end
bsw@715 10
bsw@898 11 if initiative.polling then
bsw@898 12 class = class .. " polling"
bsw@898 13 end
bsw@898 14
bsw@715 15 ui.container{ attr = { class = class }, content = function()
bsw/jbe@19 16
bsw@373 17 ui.container{ attr = { class = "rank" }, content = function()
bsw@373 18 if initiative.issue.accepted and initiative.issue.closed
bsw@373 19 and initiative.issue.ranks_available or initiative.admitted == false
bsw@373 20 then
bsw@373 21 ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible }
bsw@414 22 elseif not initiative.issue.closed then
bsw@414 23 ui.image{ static = "icons/16/script.png" }
bsw@373 24 else
bsw@414 25 ui.image{ static = "icons/16/cross.png" }
bsw@373 26 end
bsw@373 27 end }
bsw@373 28
bsw@373 29 ui.container{ attr = { class = "bar" }, content = function()
bsw@373 30 if initiative.issue.fully_frozen and initiative.issue.closed then
bsw@373 31 if initiative.issue.ranks_available then
bsw@373 32 if initiative.negative_votes and initiative.positive_votes then
bsw@373 33 local max_value = initiative.issue.voter_count
bsw@345 34 ui.bargraph{
bsw@345 35 max_value = max_value,
bsw@345 36 width = 100,
bsw@345 37 bars = {
bsw@674 38 { color = "#0a5", value = initiative.positive_votes },
bsw@373 39 { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes },
bsw@373 40 { color = "#a00", value = initiative.negative_votes },
bsw/jbe@19 41 }
bsw/jbe@19 42 }
bsw@373 43 else
bsw@345 44 slot.put(" ")
bsw@345 45 end
bsw@373 46 else
bsw@373 47 slot.put(_"Counting of votes")
bsw/jbe@19 48 end
bsw@373 49 else
bsw@373 50 local max_value = initiative.issue.population or 0
bsw@534 51 local quorum
bsw@534 52 if initiative.issue.accepted then
bsw@534 53 quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den
bsw@534 54 else
bsw@534 55 quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den
bsw@534 56 end
bsw@373 57 ui.bargraph{
bsw@373 58 max_value = max_value,
bsw@373 59 width = 100,
bsw@534 60 quorum = max_value * quorum,
bsw@373 61 quorum_color = "#00F",
bsw@373 62 bars = {
bsw@642 63 { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) },
bsw@642 64 { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) },
bsw@642 65 { color = "#fff", value = max_value - (initiative.supporter_count or 0) },
bsw@373 66 }
bsw/jbe@19 67 }
bsw/jbe@19 68 end
bsw@373 69 end }
bsw@373 70
bsw@556 71 if app.session.member_id then
bsw@556 72 ui.container{ attr = { class = "interest" }, content = function()
bsw@556 73 if initiative.member_info.initiated then
bsw@862 74 local label
bsw@862 75 if for_member and for_member.id ~= app.session.member_id then
bsw@862 76 label = _"This member is initiator of this initiative"
bsw@862 77 else
bsw@862 78 label = _"You are initiator of this initiative"
bsw@862 79 end
bsw@551 80 ui.image{
bsw@551 81 attr = { alt = label, title = label },
bsw@556 82 static = "icons/16/user_edit.png"
bsw@551 83 }
bsw@556 84 elseif initiative.member_info.directly_supported then
bsw@556 85 if initiative.member_info.satisfied then
bsw@862 86 if for_member and for_member.id ~= app.session.member_id then
bsw@862 87 label = _"This member is supporter of this initiative"
bsw@862 88 else
bsw@862 89 local label = _"You are supporter of this initiative"
bsw@862 90 end
bsw@556 91 ui.image{
bsw@556 92 attr = { alt = label, title = label },
bsw@556 93 static = "icons/16/thumb_up_green.png"
bsw@556 94 }
bsw@556 95 else
bsw@862 96 if for_member and for_member.id ~= app.session.member_id then
bsw@862 97 label = _"This member is potential supporter of this initiative"
bsw@862 98 else
bsw@862 99 local label = _"You are potential supporter of this initiative"
bsw@862 100 end
bsw@556 101 ui.image{
bsw@556 102 attr = { alt = label, title = label },
bsw@556 103 static = "icons/16/thumb_up.png"
bsw@556 104 }
bsw@556 105 end
bsw@556 106 elseif initiative.member_info.supported then
bsw@556 107 if initiative.member_info.satisfied then
bsw@862 108 if for_member and for_member.id ~= app.session.member_id then
bsw@862 109 label = _"This member is supporter of this initiative via delegation"
bsw@862 110 else
bsw@862 111 local label = _"You are supporter of this initiative via delegation"
bsw@862 112 end
bsw@556 113 ui.image{
bsw@556 114 attr = { alt = label, title = label },
bsw@556 115 static = "icons/16/thumb_up_green_arrow.png"
bsw@556 116 }
bsw@556 117 else
bsw@862 118 if for_member and for_member.id ~= app.session.member_id then
bsw@862 119 label = _"This member is potential supporter of this initiative via delegation"
bsw@862 120 else
bsw@862 121 local label = _"You are potential supporter of this initiative via delegation"
bsw@862 122 end
bsw@556 123 ui.image{
bsw@556 124 attr = { alt = label, title = label },
bsw@556 125 static = "icons/16/thumb_up_arrow.png"
bsw@556 126 }
bsw@556 127 end
bsw@551 128 end
bsw@556 129 end }
bsw@556 130 end
bsw@556 131
bsw@373 132 ui.container{ attr = { class = "name" }, content = function()
bsw@373 133 local link_class = "initiative_link"
bsw@373 134 if initiative.revoked then
bsw@373 135 link_class = "revoked"
bsw@373 136 end
bsw@373 137 ui.link{
bsw@373 138 attr = { class = link_class },
bsw@345 139 content = function()
bsw@373 140 local name
bsw@373 141 if initiative.name_highlighted then
bsw@373 142 name = encode.highlight(initiative.name_highlighted)
bsw@373 143 else
bsw@373 144 name = encode.html(initiative.shortened_name)
bsw@345 145 end
bsw@373 146 ui.tag{ content = "i" .. initiative.id .. ": " }
bsw@373 147 slot.put(name)
bsw@373 148 end,
bsw@373 149 module = "initiative",
bsw@373 150 view = "show",
bsw@373 151 id = initiative.id
bsw@345 152 }
bsw@373 153
bsw@373 154 end }
bsw@373 155
bsw@534 156 end }

Impressum / About Us