bsw@211: local initiatives = param.get("initiatives", "table") bsw@215: local current_initiative_id = param.get("current_initiative_id", atom.integer) bsw@211: bsw@211: for i, initiative in ipairs(initiatives) do bsw@211: bsw@215: local class = "initiative" bsw@215: if i == 1 then class = class .. " first" end bsw@215: if initiative.id == current_initiative_id then class = class .. " active" end bsw@211: bsw@215: ui.box_row{ class = class, content = function() ui.box_col { content = function() bsw@211: bsw@211: ui.link{ bsw@211: module = "lf2", view = "initiative", id = initiative.id, bsw@215: attr = { class = "name" }, bsw@211: text = initiative.name bsw@211: } bsw@211: bsw@211: ui.container{ attr = { class = "bar" }, content = function() bsw@211: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@211: if initiative.issue.ranks_available then bsw@211: if initiative.negative_votes and initiative.positive_votes then bsw@211: local max_value = initiative.issue.voter_count bsw@211: ui.bargraph{ bsw@211: max_value = max_value, bsw@211: width = 100, bsw@211: bars = { bsw@211: { color = "#0a0", value = initiative.positive_votes }, bsw@211: { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, bsw@211: { color = "#a00", value = initiative.negative_votes }, bsw@211: } bsw@211: } bsw@211: else bsw@211: slot.put(" ") bsw@211: end bsw@211: else bsw@211: slot.put(_"Counting of votes") bsw@211: end bsw@211: elseif initiative.issue.population then bsw@211: local max_value = initiative.issue.population bsw@211: ui.bargraph{ bsw@211: max_value = max_value, bsw@211: width = 100, bsw@211: quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), bsw@211: quorum_color = "#00F", bsw@211: bars = { bsw@211: { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, bsw@211: { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@211: { color = "#eee", value = max_value - (initiative.supporter_count or 0) }, bsw@211: } bsw@211: } bsw@211: else bsw@211: slot.put(" ") bsw@211: end bsw@211: end } bsw@211: bsw@211: ui.container{ attr = { class = "authors" }, content = function() bsw@211: local members = initiative.initiating_members bsw@211: slot.put(_"by", " ") bsw@211: for i, member in ipairs(members) do bsw@211: if i > 1 and i < #members then bsw@211: slot.put(", ") bsw@211: elseif i > 1 then bsw@211: slot.put(" ", _"and", " ") bsw@211: end bsw@211: ui.link{ bsw@211: module = "lf2", view = "initiative", id = initiative.id, bsw@211: params = { member_id = member.id }, text = member.name bsw@211: } bsw@211: end bsw@211: end } bsw@211: bsw@211: end } end } bsw@211: bsw@211: end