bsw/jbe@19: local initiative = param.get("initiative", "table") bsw@274: local selected = param.get("selected", atom.boolean) bsw/jbe@19: bsw@373: bsw@373: ui.container{ attr = { class = "initiative" }, content = function() bsw/jbe@19: bsw@373: ui.container{ attr = { class = "rank" }, content = function() bsw@373: if initiative.issue.accepted and initiative.issue.closed bsw@373: and initiative.issue.ranks_available or initiative.admitted == false bsw@373: then bsw@373: ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible } bsw@373: else bsw@375: ui.image{ static = "icons/16/script.png" } bsw@373: end bsw@373: end } bsw@373: bsw@373: ui.container{ attr = { class = "bar" }, content = function() bsw@373: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@373: if initiative.issue.ranks_available then bsw@373: if initiative.negative_votes and initiative.positive_votes then bsw@373: local max_value = initiative.issue.voter_count bsw@345: ui.bargraph{ bsw@345: max_value = max_value, bsw@345: width = 100, bsw@345: bars = { bsw@373: { color = "#0a0", value = initiative.positive_votes }, bsw@373: { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, bsw@373: { color = "#a00", value = initiative.negative_votes }, bsw/jbe@19: } bsw/jbe@19: } bsw@373: else bsw@345: slot.put(" ") bsw@345: end bsw@373: else bsw@373: slot.put(_"Counting of votes") bsw@345: end bsw@373: else bsw@373: local max_value = initiative.issue.population or 0 bsw@373: ui.bargraph{ bsw@373: max_value = max_value, bsw@373: width = 100, bsw@373: quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), bsw@373: quorum_color = "#00F", bsw@373: bars = { bsw@373: { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, bsw@373: { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@373: { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) }, bsw@373: } bsw@373: } bsw@373: end bsw@373: end } bsw@373: bsw@373: ui.container{ attr = { class = "interest" }, content = function() bsw@373: if initiative.is_initiator then bsw@373: local label = _"You are initiator of this initiative" bsw@373: ui.image{ bsw@373: attr = { alt = label, title = label }, bsw@373: static = "icons/16/user_edit.png" bsw@373: } bsw@373: elseif initiative.is_supporter then bsw@373: local label = _"You are supporter of this initiative" bsw@373: ui.image{ bsw@373: attr = { alt = label, title = label }, bsw@373: static = "icons/16/thumb_up_green.png" bsw@373: } bsw@373: elseif initiative.is_potential_supporter then bsw@373: local label = _"You are potentially supporter of this initiative" bsw@373: ui.image{ bsw@373: attr = { alt = label, title = label }, bsw@373: static = "icons/16/thumb_up.png" bsw@373: } bsw@373: elseif initiative.is_supporter_via_delegation then bsw@373: local label = _"You are supporter of this initiative via delegation" bsw@373: ui.image{ bsw@373: attr = { alt = label, title = label }, bsw@373: static = "icons/16/thumb_up_green.png" bsw@373: } bsw@373: end bsw@373: end } bsw@373: bsw@373: ui.container{ attr = { class = "name" }, content = function() bsw@373: local link_class = "initiative_link" bsw@373: if initiative.revoked then bsw@373: link_class = "revoked" bsw@373: end bsw@373: if selected then bsw@373: link_class = link_class .. " selected" bsw@373: end bsw@373: if initiative.is_supporter then bsw@373: link_class = link_class .. " supported" bsw@373: end bsw@373: if initiative.is_potential_supporter then bsw@373: link_class = link_class .. " potentially_supported" bsw@373: end bsw@373: if initiative.is_supporter_via_delegation then bsw@373: link_class = link_class .. " supported" bsw@373: end bsw@373: ui.link{ bsw@373: attr = { class = link_class }, bsw@345: content = function() bsw@373: local name bsw@373: if initiative.name_highlighted then bsw@373: name = encode.highlight(initiative.name_highlighted) bsw@373: else bsw@373: name = encode.html(initiative.shortened_name) bsw@345: end bsw@373: ui.tag{ content = "i" .. initiative.id .. ": " } bsw@373: slot.put(name) bsw@373: end, bsw@373: module = "initiative", bsw@373: view = "show", bsw@373: id = initiative.id bsw@345: } bsw@373: bsw@373: end } bsw@373: bsw@373: end }