liquid_feedback_frontend

annotate app/main/initiative/show_support.lua @ 275:fc14e76afe31

Made filter better useable
author bsw
date Sun Feb 12 13:42:08 2012 +0100 (2012-02-12)
parents 7196685f9dd7
children bde068b37608
rev   line source
bsw/jbe@19 1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
bsw/jbe@19 2
bsw/jbe@19 3 -- TODO performance
bsw/jbe@19 4 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw/jbe@19 5
bsw/jbe@19 6 ui.partial{
bsw/jbe@19 7 module = "initiative",
bsw/jbe@19 8 view = "show_support",
bsw/jbe@19 9 id = initiative.id,
bsw/jbe@19 10 target = "initiative_" .. tostring(initiative.id) .. "_support",
bsw/jbe@19 11 content = function()
bsw@273 12
bsw/jbe@19 13 ui.container{
bsw@273 14 attr = { class = "actions" },
bsw/jbe@19 15 content = function()
bsw@273 16
bsw@273 17 local initiative = param.get("initiative", "table")
bsw@273 18 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
bsw@273 19
bsw@273 20 local unique_string = multirand.string(16, '0123456789abcdef')
bsw@273 21
bsw@273 22
bsw@273 23 local partial = {
bsw@273 24 routing = {
bsw@273 25 default = {
bsw@273 26 mode = "redirect",
bsw@273 27 module = "initiative",
bsw@273 28 view = "show_support",
bsw@273 29 id = initiative.id
bsw/jbe@19 30 }
bsw@273 31 }
bsw@273 32 }
bsw@273 33
bsw@273 34 local routing = {
bsw@273 35 default = {
bsw@273 36 mode = "redirect",
bsw@273 37 module = request.get_module(),
bsw@273 38 view = request.get_view(),
bsw@273 39 id = param.get_id_cgi(),
bsw@273 40 params = param.get_all_cgi()
bsw@273 41 }
bsw@273 42 }
bsw@273 43
bsw@273 44 if not initiative.issue.fully_frozen and not initiative.issue.closed then
bsw@273 45 if supporter then
bsw@273 46 if not supporter:has_critical_opinion() then
bsw@275 47 ui.tag{ attr = { class = "supporter" }, content = function()
bsw@273 48 ui.image{
bsw@273 49 static = "icons/16/thumb_up_green.png"
bsw@273 50 }
bsw@273 51 slot.put(_"Your are supporter")
bsw@273 52 end }
bsw@273 53 else
bsw@275 54 ui.tag{ attr = { class = "potential_supporter" }, content = function()
bsw@273 55 ui.image{
bsw@273 56 static = "icons/16/thumb_up.png"
bsw@273 57 }
bsw@273 58 slot.put(_"Your are potential supporter")
bsw@273 59 end }
bsw@273 60 end
bsw@273 61 slot.put(" · ")
bsw@273 62 ui.link{
bsw@273 63 text = _"Remove my support from this initiative",
bsw@273 64 module = "initiative",
bsw@273 65 action = "remove_support",
bsw@273 66 id = initiative.id,
bsw@273 67 routing = routing,
bsw@273 68 partial = partial
bsw@273 69 }
bsw@273 70 else
bsw@273 71
bsw@273 72 if not initiative.revoked then
bsw@273 73 local params = param.get_all_cgi()
bsw@273 74 params.dyn = nil
bsw@273 75 ui.link{
bsw@273 76 text = _"Support this initiative",
bsw@273 77 module = "initiative",
bsw@273 78 action = "add_support",
bsw@273 79 id = initiative.id,
bsw@273 80 routing = routing,
bsw@273 81 partial = partial
bsw@273 82 }
bsw@273 83 end
bsw/jbe@19 84 end
bsw@273 85 end
bsw@273 86
bsw@273 87
bsw@273 88 if (initiative.discussion_url and #initiative.discussion_url > 0) then
bsw@273 89 if initiative.discussion_url:find("^https?://") then
bsw@273 90 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw@273 91 ui.link{
bsw@273 92 attr = {
bsw@273 93 target = "_blank",
bsw@273 94 title = _"Discussion with initiators"
bsw@273 95 },
bsw@273 96 image = { static = "icons/16/comments.png" },
bsw@273 97 text = _"Discuss with initiators",
bsw@273 98 external = initiative.discussion_url
bsw@273 99 }
bsw@273 100 end
bsw@273 101 else
bsw@273 102 slot.put(encode.html(initiative.discussion_url))
bsw@273 103 end
bsw@273 104 end
bsw@273 105 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@273 106 ui.link{
bsw@273 107 text = _"change discussion URL",
bsw@273 108 module = "initiative",
bsw@273 109 view = "edit",
bsw@273 110 id = initiative.id
bsw@273 111 }
bsw@273 112 end
bsw/jbe@19 113 end
bsw/jbe@19 114 }
bsw/jbe@19 115 slot.put("<div style='clear: left;'></div>")
bsw/jbe@19 116 end
bsw/jbe@19 117 }

Impressum / About Us