bsw@278: local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id()) bsw/jbe@0: bsw@278: -- TODO performance bsw@278: local initiator = Initiator:by_pk(initiative.id, app.session.member.id) 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@525: if app.session.member_id bsw@525: and not initiative.issue.half_frozen bsw@525: and not initiative.issue.closed bsw@525: and not initiative.revoked bsw@525: and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) bsw@525: then bsw@525: ui.link{ bsw@525: content = function() bsw@525: slot.put(_"Add suggestion") bsw@525: end, bsw@525: module = "suggestion", bsw@525: view = "new", bsw@525: params = { bsw@525: initiative_id = initiative.id bsw@525: } bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@278: bsw@525: if (initiative.discussion_url and #initiative.discussion_url > 0) then bsw@525: if initiative.discussion_url:find("^https?://") then bsw@525: if initiative.discussion_url and #initiative.discussion_url > 0 then bsw@525: ui.link{ bsw@525: attr = { bsw@525: target = "_blank", bsw@525: title = _"Discussion with initiators" bsw@525: }, bsw@525: text = _"Discuss with initiators", bsw@525: external = initiative.discussion_url bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@525: else bsw@525: slot.put(encode.html(initiative.discussion_url)) bsw@525: end bsw@525: end bsw@525: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@525: ui.link{ bsw@525: image = { static = "icons/16/comments.png" }, bsw@525: text = _"change discussion URL", bsw@525: module = "initiative", bsw@525: view = "edit", bsw@525: id = initiative.id bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@525: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@525: ui.link{ bsw@525: content = function() bsw@525: ui.image{ static = "icons/16/script_add.png" } bsw@525: slot.put(_"Edit draft") bsw@525: end, bsw@525: module = "draft", bsw@525: view = "new", bsw@525: params = { initiative_id = initiative.id } bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@280: bsw@525: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@525: ui.link{ bsw@525: content = function() bsw@525: ui.image{ static = "icons/16/script_delete.png" } bsw@525: slot.put(_"Revoke initiative") bsw@525: end, bsw@525: module = "initiative", bsw@525: view = "revoke", bsw@525: id = initiative.id bsw@525: } bsw@525: slot.put(" ") bsw@525: end bsw@525: bsw@525: if not initiative.issue.closed then 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@525: content = _"You have ignored this initiative" bsw/jbe@19: } bsw@525: ui.link{ bsw@525: text = _"Stop ignoring initiative", 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@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