bsw@278: local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id()) bsw/jbe@0: bsw/jbe@19: bsw@525: local initiative = param.get("initiative", "table") bsw@525: local supporter = Supporter:by_pk(initiative.id, app.session.member.id) bsw@278: bsw@525: local partial = { bsw@525: routing = { bsw@525: default = { bsw@525: mode = "redirect", bsw@525: module = "initiative", bsw@525: view = "show_support", bsw@525: id = initiative.id bsw@525: } bsw@525: } bsw@525: } bsw/jbe@0: bsw@525: local routing = { bsw@525: default = { bsw@525: mode = "redirect", bsw@525: module = request.get_module(), bsw@525: view = request.get_view(), bsw@525: id = param.get_id_cgi(), bsw@525: params = param.get_all_cgi() bsw@525: } bsw@525: } bsw/jbe@19: bsw@525: if not initiative.issue.fully_frozen and not initiative.issue.closed then bsw@525: if supporter then bsw@525: if not supporter:has_critical_opinion() then bsw@525: ui.tag{ content = function() bsw@525: ui.image{ bsw@525: static = "icons/16/thumb_up_green.png" bsw@525: } bsw@529: if initiative.issue.closed then bsw@529: slot.put(_"You were supporter") bsw@529: else bsw@529: slot.put(_"You are supporter") bsw@529: end bsw@525: end } bsw@525: else bsw@525: ui.tag{ attr = { class = "potential_supporter" }, content = function() bsw@525: ui.image{ bsw@525: static = "icons/16/thumb_up.png" bsw@525: } bsw@529: if initiative.issue.closed then bsw@529: slot.put(_"You were potential supporter") bsw@529: else bsw@529: slot.put(_"You are potential supporter") bsw@529: end bsw@525: end } bsw@525: end bsw@525: slot.put(" (") bsw@525: ui.link{ bsw@525: text = _"Withdraw", bsw@525: module = "initiative", bsw@525: action = "remove_support", bsw@525: id = initiative.id, bsw@525: routing = routing, bsw@525: partial = partial bsw@525: } bsw@525: slot.put(") ") bsw@525: elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then bsw@525: local params = param.get_all_cgi() bsw@525: params.dyn = nil bsw@525: ui.link{ bsw@525: text = _"Support this initiative", bsw@525: module = "initiative", bsw@525: action = "add_support", bsw@525: id = initiative.id, bsw@525: routing = routing, bsw@525: partial = partial bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@525: end bsw@278: bsw@280: bsw@525: bsw@525: if not initiative.issue.closed then bsw@887: if not initiative.issue.fully_frozen and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then bsw@887: slot.put(" · ") bsw@887: end bsw@525: local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id) bsw@525: if ignored_initiative then bsw@525: ui.tag{ bsw@887: content = _"Ignore initiative" bsw/jbe@19: } bsw@887: slot.put(" (") bsw@525: ui.link{ bsw@887: text = _"Cancel [nullify]", bsw@525: module = "initiative", bsw@525: action = "update_ignore", bsw@525: id = initiative.id, bsw@525: params = { delete = true }, bsw@525: routing = { bsw@525: default = { bsw@525: mode = "redirect", bsw@525: module = request.get_module(), bsw@525: view = request.get_view(), bsw@525: id = param.get_id_cgi(), bsw@525: params = param.get_all_cgi() bsw@525: } bsw@525: } bsw@525: } bsw@887: slot.put(")") bsw@525: else bsw@525: ui.link{ bsw@525: text = _"Ignore initiative", bsw@525: module = "initiative", bsw@525: action = "update_ignore", bsw@525: id = initiative.id, bsw@525: routing = { bsw@525: default = { bsw@525: mode = "redirect", bsw@525: module = request.get_module(), bsw@525: view = request.get_view(), bsw@525: id = param.get_id_cgi(), bsw@525: params = param.get_all_cgi() bsw@525: } bsw@525: } bsw@525: } bsw@10: end bsw@525: end