bsw/jbe@19: local initiative = param.get("initiative", "table") bsw@274: local selected = param.get("selected", atom.boolean) bsw@862: local for_member = param.get("for_member", "table") or app.session.member bsw/jbe@19: bsw@715: local class = "initiative" bsw/jbe@19: bsw@715: if selected then bsw@715: class = class .. " selected" bsw@715: end bsw@715: bsw@898: if initiative.polling then bsw@898: class = class .. " polling" bsw@898: end bsw@898: bsw@715: ui.container{ attr = { class = class }, 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@414: elseif not initiative.issue.closed then bsw@414: ui.image{ static = "icons/16/script.png" } bsw@373: else bsw@414: ui.image{ static = "icons/16/cross.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@674: { color = "#0a5", 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/jbe@19: end bsw@373: else bsw@373: local max_value = initiative.issue.population or 0 bsw@534: local quorum bsw@534: if initiative.issue.accepted then bsw@534: quorum = initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den bsw@534: else bsw@534: quorum = initiative.issue.policy.issue_quorum_num / initiative.issue.policy.issue_quorum_den bsw@534: end bsw@373: ui.bargraph{ bsw@373: max_value = max_value, bsw@373: width = 100, bsw@534: quorum = max_value * quorum, bsw@373: quorum_color = "#00F", bsw@373: bars = { bsw@642: { color = "#0a5", value = (initiative.satisfied_supporter_count or 0) }, bsw@642: { color = "#aaa", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@642: { color = "#fff", value = max_value - (initiative.supporter_count or 0) }, bsw@373: } bsw/jbe@19: } bsw/jbe@19: end bsw@373: end } bsw@373: bsw@556: if app.session.member_id then bsw@556: ui.container{ attr = { class = "interest" }, content = function() bsw@556: if initiative.member_info.initiated then bsw@862: local label bsw@862: if for_member and for_member.id ~= app.session.member_id then bsw@862: label = _"This member is initiator of this initiative" bsw@862: else bsw@862: label = _"You are initiator of this initiative" bsw@862: end bsw@551: ui.image{ bsw@551: attr = { alt = label, title = label }, bsw@556: static = "icons/16/user_edit.png" bsw@551: } bsw@556: elseif initiative.member_info.directly_supported then bsw@556: if initiative.member_info.satisfied then bsw@862: if for_member and for_member.id ~= app.session.member_id then bsw@862: label = _"This member is supporter of this initiative" bsw@862: else bsw@862: local label = _"You are supporter of this initiative" bsw@862: end bsw@556: ui.image{ bsw@556: attr = { alt = label, title = label }, bsw@556: static = "icons/16/thumb_up_green.png" bsw@556: } bsw@556: else bsw@862: if for_member and for_member.id ~= app.session.member_id then bsw@862: label = _"This member is potential supporter of this initiative" bsw@862: else bsw@862: local label = _"You are potential supporter of this initiative" bsw@862: end bsw@556: ui.image{ bsw@556: attr = { alt = label, title = label }, bsw@556: static = "icons/16/thumb_up.png" bsw@556: } bsw@556: end bsw@556: elseif initiative.member_info.supported then bsw@556: if initiative.member_info.satisfied then bsw@862: if for_member and for_member.id ~= app.session.member_id then bsw@862: label = _"This member is supporter of this initiative via delegation" bsw@862: else bsw@862: local label = _"You are supporter of this initiative via delegation" bsw@862: end bsw@556: ui.image{ bsw@556: attr = { alt = label, title = label }, bsw@556: static = "icons/16/thumb_up_green_arrow.png" bsw@556: } bsw@556: else bsw@862: if for_member and for_member.id ~= app.session.member_id then bsw@862: label = _"This member is potential supporter of this initiative via delegation" bsw@862: else bsw@862: local label = _"You are potential supporter of this initiative via delegation" bsw@862: end bsw@556: ui.image{ bsw@556: attr = { alt = label, title = label }, bsw@556: static = "icons/16/thumb_up_arrow.png" bsw@556: } bsw@556: end bsw@551: end bsw@556: end } bsw@556: end bsw@556: 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: 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@534: end }