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