bsw/jbe@19: local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id()) bsw/jbe@19: bsw/jbe@19: -- TODO performance bsw/jbe@19: local initiator = Initiator:by_pk(initiative.id, app.session.member.id) bsw/jbe@19: bsw/jbe@19: ui.partial{ bsw/jbe@19: module = "initiative", bsw/jbe@19: view = "show_support", bsw/jbe@19: id = initiative.id, bsw/jbe@19: target = "initiative_" .. tostring(initiative.id) .. "_support", bsw/jbe@19: content = function() bsw@273: bsw/jbe@19: ui.container{ bsw@273: attr = { class = "actions" }, bsw/jbe@19: content = function() bsw@273: bsw@273: local initiative = param.get("initiative", "table") bsw@273: local supporter = Supporter:by_pk(initiative.id, app.session.member.id) bsw@273: bsw@273: local unique_string = multirand.string(16, '0123456789abcdef') bsw@273: bsw@273: bsw@273: local partial = { bsw@273: routing = { bsw@273: default = { bsw@273: mode = "redirect", bsw@273: module = "initiative", bsw@273: view = "show_support", bsw@273: id = initiative.id bsw/jbe@19: } bsw@273: } bsw@273: } bsw@273: bsw@273: local routing = { bsw@273: default = { bsw@273: mode = "redirect", bsw@273: module = request.get_module(), bsw@273: view = request.get_view(), bsw@273: id = param.get_id_cgi(), bsw@273: params = param.get_all_cgi() bsw@273: } bsw@273: } bsw@273: bsw@273: if not initiative.issue.fully_frozen and not initiative.issue.closed then bsw@273: if supporter then bsw@273: if not supporter:has_critical_opinion() then bsw@273: ui.tag{ content = function() bsw@273: ui.image{ bsw@273: static = "icons/16/thumb_up_green.png" bsw@273: } bsw@273: slot.put(_"Your are supporter") bsw@273: end } bsw@273: else bsw@273: ui.tag{ content = function() bsw@273: ui.image{ bsw@273: static = "icons/16/thumb_up.png" bsw@273: } bsw@273: slot.put(_"Your are potential supporter") bsw@273: end } bsw@273: end bsw@273: slot.put(" · ") bsw@273: ui.link{ bsw@273: text = _"Remove my support from this initiative", bsw@273: module = "initiative", bsw@273: action = "remove_support", bsw@273: id = initiative.id, bsw@273: routing = routing, bsw@273: partial = partial bsw@273: } bsw@273: else bsw@273: bsw@273: if not initiative.revoked then bsw@273: local params = param.get_all_cgi() bsw@273: params.dyn = nil bsw@273: ui.link{ bsw@273: text = _"Support this initiative", bsw@273: module = "initiative", bsw@273: action = "add_support", bsw@273: id = initiative.id, bsw@273: routing = routing, bsw@273: partial = partial bsw@273: } bsw@273: end bsw/jbe@19: end bsw@273: end bsw@273: bsw@273: bsw@273: if (initiative.discussion_url and #initiative.discussion_url > 0) then bsw@273: if initiative.discussion_url:find("^https?://") then bsw@273: if initiative.discussion_url and #initiative.discussion_url > 0 then bsw@273: ui.link{ bsw@273: attr = { bsw@273: target = "_blank", bsw@273: title = _"Discussion with initiators" bsw@273: }, bsw@273: image = { static = "icons/16/comments.png" }, bsw@273: text = _"Discuss with initiators", bsw@273: external = initiative.discussion_url bsw@273: } bsw@273: end bsw@273: else bsw@273: slot.put(encode.html(initiative.discussion_url)) bsw@273: end bsw@273: end bsw@273: if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then bsw@273: ui.link{ bsw@273: text = _"change discussion URL", bsw@273: module = "initiative", bsw@273: view = "edit", bsw@273: id = initiative.id bsw@273: } bsw@273: end bsw/jbe@19: end bsw/jbe@19: } bsw/jbe@19: slot.put("
") bsw/jbe@19: end bsw/jbe@19: }