liquid_feedback_frontend

annotate app/main/supporter/_show_box.lua @ 722:b1ba5d237b6d

Optical improvements
author bsw
date Wed Jun 27 22:19:49 2012 +0200 (2012-06-27)
parents cdd0bcbbef8b
children 344e5fdce8c9
rev   line source
bsw@278 1 local initiative = param.get("initiative", "table") or Initiative:by_id(param.get_id())
bsw/jbe@0 2
bsw@278 3 -- TODO performance
bsw@278 4 local initiator = Initiator:by_pk(initiative.id, app.session.member.id)
bsw/jbe@19 5
bsw@525 6 local initiative = param.get("initiative", "table")
bsw@525 7 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
bsw@278 8
bsw@525 9 local partial = {
bsw@525 10 routing = {
bsw@525 11 default = {
bsw@525 12 mode = "redirect",
bsw@525 13 module = "initiative",
bsw@525 14 view = "show_support",
bsw@525 15 id = initiative.id
bsw@525 16 }
bsw@525 17 }
bsw@525 18 }
bsw/jbe@0 19
bsw@525 20 local routing = {
bsw@525 21 default = {
bsw@525 22 mode = "redirect",
bsw@525 23 module = request.get_module(),
bsw@525 24 view = request.get_view(),
bsw@525 25 id = param.get_id_cgi(),
bsw@525 26 params = param.get_all_cgi()
bsw@525 27 }
bsw@525 28 }
bsw/jbe@19 29
bsw@525 30 if not initiative.issue.fully_frozen and not initiative.issue.closed then
bsw@525 31 if supporter then
bsw@525 32 if not supporter:has_critical_opinion() then
bsw@525 33 ui.tag{ content = function()
bsw@525 34 ui.image{
bsw@525 35 static = "icons/16/thumb_up_green.png"
bsw@525 36 }
bsw@529 37 if initiative.issue.closed then
bsw@529 38 slot.put(_"You were supporter")
bsw@529 39 else
bsw@529 40 slot.put(_"You are supporter")
bsw@529 41 end
bsw@525 42 end }
bsw@525 43 else
bsw@525 44 ui.tag{ attr = { class = "potential_supporter" }, content = function()
bsw@525 45 ui.image{
bsw@525 46 static = "icons/16/thumb_up.png"
bsw@525 47 }
bsw@529 48 if initiative.issue.closed then
bsw@529 49 slot.put(_"You were potential supporter")
bsw@529 50 else
bsw@529 51 slot.put(_"You are potential supporter")
bsw@529 52 end
bsw@525 53 end }
bsw@525 54 end
bsw@525 55 slot.put(" (")
bsw@525 56 ui.link{
bsw@525 57 text = _"Withdraw",
bsw@525 58 module = "initiative",
bsw@525 59 action = "remove_support",
bsw@525 60 id = initiative.id,
bsw@525 61 routing = routing,
bsw@525 62 partial = partial
bsw@525 63 }
bsw@525 64 slot.put(") ")
bsw@525 65 elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
bsw@525 66 local params = param.get_all_cgi()
bsw@525 67 params.dyn = nil
bsw@525 68 ui.link{
bsw@525 69 text = _"Support this initiative",
bsw@525 70 module = "initiative",
bsw@525 71 action = "add_support",
bsw@525 72 id = initiative.id,
bsw@525 73 routing = routing,
bsw@525 74 partial = partial
bsw@525 75 }
bsw@525 76 slot.put(" ")
bsw@525 77 end
bsw@525 78 end
bsw@278 79
bsw@525 80 if (initiative.discussion_url and #initiative.discussion_url > 0) then
bsw@525 81 if initiative.discussion_url:find("^https?://") then
bsw@525 82 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw@525 83 ui.link{
bsw@525 84 attr = {
bsw@525 85 target = "_blank",
bsw@525 86 title = _"Discussion with initiators"
bsw@525 87 },
bsw@525 88 text = _"Discuss with initiators",
bsw@525 89 external = initiative.discussion_url
bsw@525 90 }
bsw@525 91 slot.put(" ")
bsw@525 92 end
bsw@525 93 else
bsw@525 94 slot.put(encode.html(initiative.discussion_url))
bsw@525 95 end
bsw@525 96 end
bsw@525 97 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 98 ui.link{
bsw@525 99 text = _"change discussion URL",
bsw@525 100 module = "initiative",
bsw@525 101 view = "edit",
bsw@525 102 id = initiative.id
bsw@525 103 }
bsw@525 104 slot.put(" ")
bsw@525 105 end
bsw@525 106 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 107 ui.link{
bsw@525 108 content = function()
bsw@525 109 slot.put(_"Edit draft")
bsw@525 110 end,
bsw@525 111 module = "draft",
bsw@525 112 view = "new",
bsw@525 113 params = { initiative_id = initiative.id }
bsw@525 114 }
bsw@525 115 slot.put(" ")
bsw@525 116 end
bsw@280 117
bsw@525 118 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 119 ui.link{
bsw@525 120 content = function()
bsw@525 121 slot.put(_"Revoke initiative")
bsw@525 122 end,
bsw@525 123 module = "initiative",
bsw@525 124 view = "revoke",
bsw@525 125 id = initiative.id
bsw@525 126 }
bsw@525 127 slot.put(" ")
bsw@525 128 end
bsw@525 129
bsw@525 130 if not initiative.issue.closed then
bsw@525 131 local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
bsw@525 132 if ignored_initiative then
bsw@525 133 ui.tag{
bsw@525 134 content = _"You have ignored this initiative"
bsw/jbe@19 135 }
bsw@525 136 ui.link{
bsw@525 137 text = _"Stop ignoring initiative",
bsw@525 138 module = "initiative",
bsw@525 139 action = "update_ignore",
bsw@525 140 id = initiative.id,
bsw@525 141 params = { delete = true },
bsw@525 142 routing = {
bsw@525 143 default = {
bsw@525 144 mode = "redirect",
bsw@525 145 module = request.get_module(),
bsw@525 146 view = request.get_view(),
bsw@525 147 id = param.get_id_cgi(),
bsw@525 148 params = param.get_all_cgi()
bsw@525 149 }
bsw@525 150 }
bsw@525 151 }
bsw@525 152 else
bsw@525 153 ui.link{
bsw@525 154 text = _"Ignore initiative",
bsw@525 155 module = "initiative",
bsw@525 156 action = "update_ignore",
bsw@525 157 id = initiative.id,
bsw@525 158 routing = {
bsw@525 159 default = {
bsw@525 160 mode = "redirect",
bsw@525 161 module = request.get_module(),
bsw@525 162 view = request.get_view(),
bsw@525 163 id = param.get_id_cgi(),
bsw@525 164 params = param.get_all_cgi()
bsw@525 165 }
bsw@525 166 }
bsw@525 167 }
bsw@10 168 end
bsw@525 169 end

Impressum / About Us