liquid_feedback_frontend

annotate app/main/supporter/_show_box.lua @ 685:bbf4d18db524

Optical improvements
author bsw
date Tue Jun 26 17:56:29 2012 +0200 (2012-06-26)
parents 5ca9de94cb13
children cdd0bcbbef8b
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 app.session.member_id
bsw@525 81 and not initiative.issue.half_frozen
bsw@525 82 and not initiative.issue.closed
bsw@525 83 and not initiative.revoked
bsw@525 84 and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
bsw@525 85 then
bsw@525 86 ui.link{
bsw@525 87 content = function()
bsw@525 88 slot.put(_"Add suggestion")
bsw@525 89 end,
bsw@525 90 module = "suggestion",
bsw@525 91 view = "new",
bsw@525 92 params = {
bsw@525 93 initiative_id = initiative.id
bsw@525 94 }
bsw@525 95 }
bsw@525 96 slot.put(" ")
bsw@525 97 end
bsw@278 98
bsw@525 99 if (initiative.discussion_url and #initiative.discussion_url > 0) then
bsw@525 100 if initiative.discussion_url:find("^https?://") then
bsw@525 101 if initiative.discussion_url and #initiative.discussion_url > 0 then
bsw@525 102 ui.link{
bsw@525 103 attr = {
bsw@525 104 target = "_blank",
bsw@525 105 title = _"Discussion with initiators"
bsw@525 106 },
bsw@525 107 text = _"Discuss with initiators",
bsw@525 108 external = initiative.discussion_url
bsw@525 109 }
bsw@525 110 slot.put(" ")
bsw@525 111 end
bsw@525 112 else
bsw@525 113 slot.put(encode.html(initiative.discussion_url))
bsw@525 114 end
bsw@525 115 end
bsw@525 116 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 117 ui.link{
bsw@525 118 image = { static = "icons/16/comments.png" },
bsw@525 119 text = _"change discussion URL",
bsw@525 120 module = "initiative",
bsw@525 121 view = "edit",
bsw@525 122 id = initiative.id
bsw@525 123 }
bsw@525 124 slot.put(" ")
bsw@525 125 end
bsw@525 126 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 127 ui.link{
bsw@525 128 content = function()
bsw@525 129 ui.image{ static = "icons/16/script_add.png" }
bsw@525 130 slot.put(_"Edit draft")
bsw@525 131 end,
bsw@525 132 module = "draft",
bsw@525 133 view = "new",
bsw@525 134 params = { initiative_id = initiative.id }
bsw@525 135 }
bsw@525 136 slot.put(" ")
bsw@525 137 end
bsw@280 138
bsw@525 139 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
bsw@525 140 ui.link{
bsw@525 141 content = function()
bsw@525 142 ui.image{ static = "icons/16/script_delete.png" }
bsw@525 143 slot.put(_"Revoke initiative")
bsw@525 144 end,
bsw@525 145 module = "initiative",
bsw@525 146 view = "revoke",
bsw@525 147 id = initiative.id
bsw@525 148 }
bsw@525 149 slot.put(" ")
bsw@525 150 end
bsw@525 151
bsw@525 152 if not initiative.issue.closed then
bsw@525 153 local ignored_initiative = IgnoredInitiative:by_pk(app.session.member.id, initiative.id)
bsw@525 154 if ignored_initiative then
bsw@525 155 ui.tag{
bsw@525 156 content = _"You have ignored this initiative"
bsw/jbe@19 157 }
bsw@525 158 ui.link{
bsw@525 159 text = _"Stop ignoring initiative",
bsw@525 160 module = "initiative",
bsw@525 161 action = "update_ignore",
bsw@525 162 id = initiative.id,
bsw@525 163 params = { delete = true },
bsw@525 164 routing = {
bsw@525 165 default = {
bsw@525 166 mode = "redirect",
bsw@525 167 module = request.get_module(),
bsw@525 168 view = request.get_view(),
bsw@525 169 id = param.get_id_cgi(),
bsw@525 170 params = param.get_all_cgi()
bsw@525 171 }
bsw@525 172 }
bsw@525 173 }
bsw@525 174 else
bsw@525 175 ui.link{
bsw@525 176 text = _"Ignore initiative",
bsw@525 177 module = "initiative",
bsw@525 178 action = "update_ignore",
bsw@525 179 id = initiative.id,
bsw@525 180 routing = {
bsw@525 181 default = {
bsw@525 182 mode = "redirect",
bsw@525 183 module = request.get_module(),
bsw@525 184 view = request.get_view(),
bsw@525 185 id = param.get_id_cgi(),
bsw@525 186 params = param.get_all_cgi()
bsw@525 187 }
bsw@525 188 }
bsw@525 189 }
bsw@10 190 end
bsw@525 191 end

Impressum / About Us