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@278: ui.partial{ bsw@278: module = "initiative", bsw@278: view = "show_support", bsw@278: id = initiative.id, bsw@278: target = "initiative_" .. tostring(initiative.id) .. "_support", bsw@278: content = function() bsw/jbe@19: bsw@278: ui.container{ bsw@278: attr = { class = "actions" }, bsw@278: content = function() bsw@278: bsw@278: local initiative = param.get("initiative", "table") bsw@278: local supporter = Supporter:by_pk(initiative.id, app.session.member.id) bsw@278: bsw@278: local partial = { bsw@278: routing = { bsw@278: default = { bsw@278: mode = "redirect", bsw@278: module = "initiative", bsw@278: view = "show_support", bsw@278: id = initiative.id bsw@278: } bsw@278: } bsw@278: } bsw/jbe@0: bsw@278: local routing = { bsw@278: default = { bsw@278: mode = "redirect", bsw@278: module = request.get_module(), bsw@278: view = request.get_view(), bsw@278: id = param.get_id_cgi(), bsw@278: params = param.get_all_cgi() bsw@278: } bsw@278: } bsw/jbe@19: bsw@278: if not initiative.issue.fully_frozen and not initiative.issue.closed then bsw@278: if supporter then bsw@278: if not supporter:has_critical_opinion() then bsw@278: ui.container{ attr = { class = "supporter" }, content = function() bsw@278: ui.image{ bsw@278: static = "icons/16/thumb_up_green.png" bsw@278: } bsw@278: slot.put(_"Your are supporter") bsw@278: end } bsw@278: else bsw@278: ui.tag{ attr = { class = "potential_supporter" }, content = function() bsw@278: ui.image{ bsw@278: static = "icons/16/thumb_up.png" bsw@278: } bsw@278: slot.put(_"Your are potential supporter") bsw@278: end } bsw@278: end bsw@278: ui.link{ bsw@278: image = { static = "icons/16/cross.png" }, bsw@278: text = _"Withdraw support", bsw@278: module = "initiative", bsw@278: action = "remove_support", bsw@278: id = initiative.id, bsw@278: routing = routing, bsw@278: partial = partial bsw@278: } bsw@281: elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then bsw@281: local params = param.get_all_cgi() bsw@281: params.dyn = nil bsw@281: ui.link{ bsw@281: image = { static = "icons/16/thumb_up_green.png" }, bsw@281: text = _"Support this initiative", bsw@281: module = "initiative", bsw@281: action = "add_support", bsw@281: id = initiative.id, bsw@281: routing = routing, bsw@281: partial = partial bsw@281: } poelzi@148: end bsw@278: end bsw@278: bsw@278: bsw@278: if (initiative.discussion_url and #initiative.discussion_url > 0) then bsw@278: if initiative.discussion_url:find("^https?://") then bsw@278: if initiative.discussion_url and #initiative.discussion_url > 0 then bsw@278: ui.link{ bsw@278: attr = { bsw@278: target = "_blank", bsw@278: title = _"Discussion with initiators" bsw@278: }, bsw@278: image = { static = "icons/16/comments.png" }, bsw@278: text = _"Discuss with initiators", bsw@278: external = initiative.discussion_url bsw@278: } bsw@278: end bsw@278: else bsw@278: slot.put(encode.html(initiative.discussion_url)) bsw@278: end bsw@278: end bsw@278: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw/jbe@19: ui.link{ bsw@278: image = { static = "icons/16/comments.png" }, bsw@278: text = _"change discussion URL", bsw@278: module = "initiative", bsw@278: view = "edit", bsw@278: id = initiative.id bsw/jbe@0: } bsw/jbe@19: end bsw@280: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@280: ui.link{ bsw@280: content = function() bsw@280: ui.image{ static = "icons/16/script_add.png" } bsw@280: slot.put(_"Edit draft") bsw@280: end, bsw@280: module = "draft", bsw@280: view = "new", bsw@280: params = { initiative_id = initiative.id } bsw@280: } bsw@280: end bsw@280: bsw@280: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@280: ui.link{ bsw@280: content = function() bsw@280: ui.image{ static = "icons/16/script_delete.png" } bsw@280: slot.put(_"Revoke initiative") bsw@280: end, bsw@280: module = "initiative", bsw@280: view = "revoke", bsw@280: id = initiative.id bsw@280: } bsw@280: end bsw@450: bsw@450: local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id) bsw@450: if ignored_initiative then bsw@450: ui.container{ bsw@450: attr = { class = "interest" }, bsw@450: content = _"You have ignored this initiative" bsw@450: } bsw@450: ui.link{ bsw@450: text = _"Stop ignoring initiative", bsw@450: module = "initiative", bsw@450: action = "update_ignore", bsw@450: id = initiative.id, bsw@450: params = { delete = true }, bsw@450: routing = { bsw@450: default = { bsw@450: mode = "redirect", bsw@450: module = request.get_module(), bsw@450: view = request.get_view(), bsw@450: id = param.get_id_cgi(), bsw@450: params = param.get_all_cgi() bsw@450: } bsw@450: } bsw@450: } bsw@450: else bsw@450: ui.link{ bsw@450: attr = { class = "interest" }, bsw@450: text = _"Ignore initiative", bsw@450: module = "initiative", bsw@450: action = "update_ignore", bsw@450: id = initiative.id, bsw@450: routing = { bsw@450: default = { bsw@450: mode = "redirect", bsw@450: module = request.get_module(), bsw@450: view = request.get_view(), bsw@450: id = param.get_id_cgi(), bsw@450: params = param.get_all_cgi() bsw@450: } bsw@450: } bsw@450: } bsw@450: end bsw@450: bsw@450: bsw/jbe@0: end bsw/jbe@19: } bsw@280: bsw@280: bsw@278: slot.put("
") bsw@10: end bsw@278: }