liquid_feedback_frontend
diff app/main/initiative/_head.lua @ 1045:701a5cf6b067
Imported LiquidFeedback Frontend 3.0 branch
| author | bsw |
|---|---|
| date | Thu Jul 10 01:19:48 2014 +0200 (2014-07-10) |
| parents | |
| children | 9d901be8ea01 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/initiative/_head.lua Thu Jul 10 01:19:48 2014 +0200 1.3 @@ -0,0 +1,198 @@ 1.4 +local initiative = param.get("initiative", "table") 1.5 +local member = param.get("member", "table") or app.session.member 1.6 + 1.7 +-- TODO performance 1.8 +local initiator 1.9 +if member then 1.10 + initiator = Initiator:by_pk(initiative.id, member.id) 1.11 +end 1.12 + 1.13 +local initiators_members_selector = initiative:get_reference_selector("initiating_members") 1.14 + :add_field("initiator.accepted", "accepted") 1.15 + :add_order_by("member.name") 1.16 +if initiator and initiator.accepted then 1.17 + initiators_members_selector:add_where("initiator.accepted ISNULL OR initiator.accepted") 1.18 +else 1.19 + initiators_members_selector:add_where("initiator.accepted") 1.20 +end 1.21 + 1.22 +local initiators = initiators_members_selector:exec() 1.23 + 1.24 + 1.25 +ui.sectionHead( "initiativeInfo", function () 1.26 + 1.27 + ui.heading { 1.28 + level = 1, 1.29 + content = initiative.display_name 1.30 + } 1.31 + 1.32 + ui.container { attr = { class = "support" }, content = function () 1.33 + if initiative.supporter_count == nil then 1.34 + ui.tag { 1.35 + attr = { class = "supporterCount" }, 1.36 + content = _"[calculating]" 1.37 + } 1.38 + elseif initiative.issue.closed == nil then 1.39 + ui.tag { 1.40 + attr = { class = "satisfiedSupporterCount" }, 1.41 + content = _("#{count} supporter", { count = initiative.satisfied_supporter_count }) 1.42 + } 1.43 + if initiative.potential_supporter_count and 1.44 + initiative.potential_supporter_count > 0 1.45 + then 1.46 + slot.put ( " " ) 1.47 + ui.tag { 1.48 + attr = { class = "potentialSupporterCount" }, 1.49 + content = _("(+ #{count} potential)", { count = initiative.potential_supporter_count }) 1.50 + } 1.51 + end 1.52 + 1.53 + end 1.54 + 1.55 + slot.put ( "<br />" ) 1.56 + 1.57 + execute.view { 1.58 + module = "initiative", view = "_bargraph", params = { 1.59 + initiative = initiative 1.60 + } 1.61 + } 1.62 + end } 1.63 + 1.64 + if member then 1.65 + ui.container { attr = { class = "mySupport right" }, content = function () 1.66 + if initiative.issue.fully_frozen then 1.67 + if initiative.issue.member_info.direct_voted then 1.68 + --ui.image { attr = { class = "icon48 right" }, static = "icons/48/voted_ok.png" } 1.69 + ui.tag { content = _"You have voted" } 1.70 + slot.put("<br />") 1.71 + if not initiative.issue.closed then 1.72 + ui.link { 1.73 + module = "vote", view = "list", 1.74 + params = { issue_id = initiative.issue.id }, 1.75 + text = _"change vote" 1.76 + } 1.77 + else 1.78 + ui.link { 1.79 + module = "vote", view = "list", 1.80 + params = { issue_id = initiative.issue.id }, 1.81 + text = _"show vote" 1.82 + } 1.83 + end 1.84 + slot.put(" ") 1.85 + elseif active_trustee_id then 1.86 + ui.tag { content = _"You have voted via delegation" } 1.87 + ui.link { 1.88 + content = _"Show voting ballot", 1.89 + module = "vote", view = "list", params = { 1.90 + issue_id = initiative.issue.id, member_id = active_trustee_id 1.91 + } 1.92 + } 1.93 + elseif not initiative.issue.closed then 1.94 + ui.link { 1.95 + attr = { class = "btn btn-default" }, 1.96 + module = "vote", view = "list", 1.97 + params = { issue_id = initiative.issue.id }, 1.98 + text = _"vote now" 1.99 + } 1.100 + end 1.101 + elseif initiative.member_info.supported then 1.102 + if initiative.member_info.satisfied then 1.103 + ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_satisfied.png" } 1.104 + else 1.105 + ui.image { attr = { class = "icon48 right" }, static = "icons/32/support_unsatisfied.png" } 1.106 + end 1.107 + ui.container { content = _"You are supporter" } 1.108 + 1.109 + if initiative.issue.member_info.own_participation then 1.110 + ui.link { 1.111 + attr = { class = "btn-link" }, 1.112 + module = "initiative", action = "remove_support", 1.113 + routing = { default = { 1.114 + mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.115 + } }, 1.116 + id = initiative.id, 1.117 + text = "remove my support" 1.118 + } 1.119 + 1.120 + else 1.121 + 1.122 + ui.link { 1.123 + module = "delegation", view = "show", params = { 1.124 + issue_id = initiative.issue_id, 1.125 + initiative_id = initiative.id 1.126 + }, 1.127 + content = _"via delegation" 1.128 + } 1.129 + 1.130 + end 1.131 + 1.132 + slot.put(" ") 1.133 + 1.134 + 1.135 + else 1.136 + ui.link { 1.137 + attr = { class = "btn btn-default" }, 1.138 + module = "initiative", action = "add_support", 1.139 + routing = { default = { 1.140 + mode = "redirect", module = "initiative", view = "show", id = initiative.id 1.141 + } }, 1.142 + id = initiative.id, 1.143 + text = _"add my support" 1.144 + } 1.145 + 1.146 + end 1.147 + end } 1.148 + 1.149 + end 1.150 + 1.151 + slot.put("<br style='clear: both;'/>") 1.152 + 1.153 + ui.container { 1.154 + attr = { class = "initiators" }, 1.155 + content = function () 1.156 + 1.157 + if app.session:has_access("authors_pseudonymous") then 1.158 + for i, member in ipairs(initiators) do 1.159 + if i > 1 then 1.160 + slot.put(" ") 1.161 + end 1.162 + util.micro_avatar(member) 1.163 + if member.accepted == nil then 1.164 + slot.put ( " " ) 1.165 + ui.tag { content = _"(invited)" } 1.166 + end 1.167 + end -- for i, member 1.168 + 1.169 + end 1.170 + 1.171 + end 1.172 + } -- ui.container "initiators" 1.173 + 1.174 + ui.container { 1.175 + attr = { class = "links" }, 1.176 + content = function () 1.177 + 1.178 + local drafts_count = initiative:get_reference_selector("drafts"):count() 1.179 + ui.link { 1.180 + content = _("suggestions (#{count}) ↓", { 1.181 + count = # ( initiative.suggestions ) 1.182 + }), 1.183 + external = "#suggestions" 1.184 + } 1.185 + 1.186 + slot.put ( " | " ) 1.187 + 1.188 + ui.link{ 1.189 + module = "initiative", view = "history", id = initiative.id, 1.190 + content = _("draft history (#{count})", { count = drafts_count }) 1.191 + } 1.192 + 1.193 + end 1.194 + } -- ui.containers "links" 1.195 + end ) 1.196 + 1.197 + execute.view { 1.198 + module = "initiative", view = "_sidebar_state", 1.199 + params = { initiative = initiative } 1.200 + } 1.201 +