bsw/jbe@19: local initiative = param.get("initiative", "table") bsw@274: local selected = param.get("selected", atom.boolean) bsw/jbe@19: bsw/jbe@19: local head_name = "initiative_head_" .. tostring(initiative.id) bsw/jbe@19: local link_name = "initiative_link_" .. tostring(initiative.id) bsw/jbe@19: local name = "initiative_content_" .. tostring(initiative.id) bsw/jbe@19: local icon_name = "initiative_icon_" .. tostring(initiative.id) bsw/jbe@19: bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { class = "ui_tabs" .. (initiative.id == for_initiative_id and " active" or "") }, bsw/jbe@19: content = function() bsw/jbe@19: local module = "initiative" bsw/jbe@19: local view = "show" bsw/jbe@19: local id = initiative.id bsw/jbe@19: local params = {} bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: name = name, bsw/jbe@19: class = "ui_tabs_accordeon_head", bsw/jbe@19: id = head_name, bsw/jbe@19: }, bsw/jbe@19: content = function() bsw/jbe@19: bsw@29: ui.list{ bsw@29: attr = { class = "nohover" }, bsw@29: records = { { a = 1} }, bsw@29: columns = { bsw@29: { bsw@280: field_attr = { style = "width: 3em; text-align: center;"}, bsw@29: content = function() bsw@29: if initiative.issue.accepted and initiative.issue.closed and initiative.issue.ranks_available or initiative.admitted == false then bsw@29: ui.field.rank{ image_attr = { id = icon_name }, attr = { class = "rank" }, value = initiative.rank } bsw@29: else bsw@29: slot.put(" ") bsw@29: end bsw@29: end bsw@29: }, bsw/jbe@19: bsw@29: { bsw@312: field_attr = { style = "width: 100px;"}, bsw@29: content = function() bsw/jbe@48: if initiative.issue.fully_frozen and initiative.issue.closed then bsw@29: if initiative.issue.ranks_available then bsw@29: if initiative.negative_votes and initiative.positive_votes then bsw@29: local max_value = initiative.issue.voter_count bsw@29: ui.bargraph{ bsw@29: max_value = max_value, bsw@29: width = 100, bsw@29: bars = { bsw@29: { color = "#0a0", value = initiative.positive_votes }, bsw@29: { color = "#aaa", value = max_value - initiative.negative_votes - initiative.positive_votes }, bsw@29: { color = "#a00", value = initiative.negative_votes }, bsw@29: } bsw@29: } bsw@29: else bsw@29: slot.put(" ") bsw@29: end bsw@29: else bsw@29: slot.put(_"Counting of votes") bsw@29: end bsw@273: else bsw@273: local max_value = initiative.issue.population or 0 bsw/jbe@19: ui.bargraph{ bsw/jbe@19: max_value = max_value, bsw/jbe@19: width = 100, poelzi@159: quorum = max_value * (initiative.issue.policy.initiative_quorum_num / initiative.issue.policy.initiative_quorum_den), poelzi@159: quorum_color = "#00F", bsw/jbe@19: bars = { bsw@29: { color = "#0a0", value = (initiative.satisfied_supporter_count or 0) }, bsw@29: { color = "#bbb", value = (initiative.supporter_count or 0) - (initiative.satisfied_supporter_count or 0) }, bsw@317: { color = "#f7f7f7", value = max_value - (initiative.supporter_count or 0) }, bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: end bsw@29: }, bsw@312: { bsw@312: field_attr = { style = "width: 24px;" }, bsw@312: content = function() bsw@312: if initiative.is_initiator then bsw@312: slot.put(" ") bsw@312: local label = _"You are initiator of this initiative" bsw@312: ui.image{ bsw@312: attr = { alt = label, title = label }, bsw@312: static = "icons/16/user_edit.png" bsw@312: } bsw@312: elseif initiative.is_supporter then bsw@312: slot.put(" ") bsw@312: local label = _"You are supporter of this initiative" bsw@312: ui.image{ bsw@312: attr = { alt = label, title = label }, bsw@312: static = "icons/16/thumb_up_green.png" bsw@312: } bsw@312: elseif initiative.is_potential_supporter then bsw@312: slot.put(" ") bsw@312: local label = _"You are potentially supporter of this initiative" bsw@312: ui.image{ bsw@312: attr = { alt = label, title = label }, bsw@312: static = "icons/16/thumb_up.png" bsw@312: } bsw@312: elseif initiative.is_supporter_via_delegation then bsw@312: slot.put(" ") bsw@312: local label = _"You are supporter of this initiative via delegation" bsw@312: ui.image{ bsw@312: attr = { alt = label, title = label }, bsw@312: static = "icons/16/thumb_up_green.png" bsw@312: } bsw@312: end bsw@29: bsw@312: end bsw@312: }, bsw@29: { bsw/jbe@19: content = function() bsw@274: local link_class = "initiative_link" bsw@29: if initiative.revoked then bsw@29: link_class = "revoked" bsw/jbe@19: end bsw@274: if selected then bsw@274: link_class = link_class .. " selected" bsw@274: end bsw@274: if initiative.is_supporter then bsw@274: link_class = link_class .. " supported" bsw@274: end bsw@274: if initiative.is_potential_supporter then bsw@274: link_class = link_class .. " potentially_supported" bsw@274: end bsw@285: if initiative.is_supporter_via_delegation then bsw@285: link_class = link_class .. " supported" bsw@285: end bsw@29: ui.link{ bsw@29: attr = { id = link_name, class = link_class }, bsw@29: content = function() bsw@29: local name bsw@29: if initiative.name_highlighted then bsw@29: name = encode.highlight(initiative.name_highlighted) bsw@29: else bsw@29: name = encode.html(initiative.shortened_name) bsw@29: end bsw@274: ui.tag{ content = "i" .. initiative.id .. ": " } bsw@29: slot.put(name) bsw@29: end, bsw@29: module = module, bsw@29: view = view, bsw@29: id = id, bsw@29: params = params, bsw@29: } bsw@292: bsw@29: end bsw/jbe@19: } bsw/jbe@19: } bsw@29: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: bsw/jbe@19: if ui.is_partial_loading_enabled() then bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { bsw/jbe@19: id = name, bsw/jbe@19: class = "ui_tabs_accordeon_content", bsw/jbe@19: }, bsw/jbe@19: content = function() bsw/jbe@19: ui.container{ bsw/jbe@19: attr = { id = name .. "_content", style = "clear: left;" }, bsw/jbe@19: content = function() bsw/jbe@19: execute.view{ bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show_partial", bsw/jbe@19: params = { bsw/jbe@19: initiative = initiative, bsw/jbe@19: } bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: end