bsw/jbe@19: local initiative = param.get("initiative", "table") bsw@274: local selected = param.get("selected", atom.boolean) bsw/jbe@19: bsw@345: ui.list{ bsw@345: attr = { class = "nohover" }, bsw@345: records = { { a = 1} }, bsw@345: columns = { bsw@345: { bsw@345: field_attr = { style = "width: 3em; text-align: center;"}, bsw/jbe@19: content = function() bsw@345: if bsw@345: initiative.issue.accepted and initiative.issue.closed bsw@345: and initiative.issue.ranks_available or initiative.admitted == false bsw@345: then bsw@345: ui.field.rank{ attr = { class = "rank" }, value = initiative.rank, eligible = initiative.eligible } bsw@345: else bsw@345: slot.put(" ") bsw@345: end bsw@345: end bsw@345: }, bsw/jbe@19: bsw@345: { bsw@345: field_attr = { style = "width: 100px;"}, bsw@345: content = function() bsw@345: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@345: if initiative.issue.ranks_available then bsw@345: if initiative.negative_votes and initiative.positive_votes then bsw@345: 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@345: { color = "#0a0", value = initiative.positive_votes }, bsw@345: { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, bsw@345: { color = "#a00", value = initiative.negative_votes }, bsw@29: } bsw@345: } bsw@345: else bsw@345: slot.put(" ") bsw@345: end bsw@345: else bsw@345: slot.put(_"Counting of votes") bsw@345: end bsw@345: else bsw@345: local max_value = initiative.issue.population or 0 bsw@345: ui.bargraph{ bsw@345: max_value = max_value, bsw@345: width = 100, bsw@345: quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), bsw@345: quorum_color = "#00F", bsw@345: bars = { bsw@345: { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, bsw@345: { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@345: { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) }, bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: end bsw@345: end bsw@345: }, bsw@345: { bsw@345: field_attr = { style = "width: 24px;" }, bsw@345: content = function() bsw@345: if initiative.is_initiator then bsw@345: slot.put(" ") bsw@345: local label = _"You are initiator of this initiative" bsw@345: ui.image{ bsw@345: attr = { alt = label, title = label }, bsw@345: static = "icons/16/user_edit.png" bsw@345: } bsw@345: elseif initiative.is_supporter then bsw@345: slot.put(" ") bsw@345: local label = _"You are supporter of this initiative" bsw@345: ui.image{ bsw@345: attr = { alt = label, title = label }, bsw@345: static = "icons/16/thumb_up_green.png" bsw@345: } bsw@345: elseif initiative.is_potential_supporter then bsw@345: slot.put(" ") bsw@345: local label = _"You are potentially supporter of this initiative" bsw@345: ui.image{ bsw@345: attr = { alt = label, title = label }, bsw@345: static = "icons/16/thumb_up.png" bsw@345: } bsw@345: elseif initiative.is_supporter_via_delegation then bsw@345: slot.put(" ") bsw@345: local label = _"You are supporter of this initiative via delegation" bsw@345: ui.image{ bsw@345: attr = { alt = label, title = label }, bsw@345: static = "icons/16/thumb_up_green.png" bsw@345: } bsw@345: end bsw@345: bsw@345: end bsw@345: }, bsw@345: { bsw@345: content = function() bsw@345: local link_class = "initiative_link" bsw@345: if initiative.revoked then bsw@345: link_class = "revoked" bsw@345: end bsw@345: if selected then bsw@345: link_class = link_class .. " selected" bsw@345: end bsw@345: if initiative.is_supporter then bsw@345: link_class = link_class .. " supported" bsw@345: end bsw@345: if initiative.is_potential_supporter then bsw@345: link_class = link_class .. " potentially_supported" bsw@345: end bsw@345: if initiative.is_supporter_via_delegation then bsw@345: link_class = link_class .. " supported" bsw@345: end bsw@345: ui.link{ bsw@345: attr = { class = link_class }, bsw@345: content = function() bsw@345: local name bsw@345: if initiative.name_highlighted then bsw@345: name = encode.highlight(initiative.name_highlighted) bsw@345: else bsw@345: name = encode.html(initiative.shortened_name) bsw@345: end bsw@345: ui.tag{ content = "i" .. initiative.id .. ": " } bsw@345: slot.put(name) bsw@345: end, bsw@345: module = "initiative", bsw@345: view = "show", bsw@345: id = initiative.id bsw@345: } bsw@345: bsw@345: end bsw@345: } bsw/jbe@19: } bsw@345: }