| 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 partial = {
|
|
bsw@273
|
21 routing = {
|
|
bsw@273
|
22 default = {
|
|
bsw@273
|
23 mode = "redirect",
|
|
bsw@273
|
24 module = "initiative",
|
|
bsw@273
|
25 view = "show_support",
|
|
bsw@273
|
26 id = initiative.id
|
|
bsw/jbe@19
|
27 }
|
|
bsw@273
|
28 }
|
|
bsw@273
|
29 }
|
|
bsw@273
|
30
|
|
bsw@273
|
31 local routing = {
|
|
bsw@273
|
32 default = {
|
|
bsw@273
|
33 mode = "redirect",
|
|
bsw@273
|
34 module = request.get_module(),
|
|
bsw@273
|
35 view = request.get_view(),
|
|
bsw@273
|
36 id = param.get_id_cgi(),
|
|
bsw@273
|
37 params = param.get_all_cgi()
|
|
bsw@273
|
38 }
|
|
bsw@273
|
39 }
|
|
bsw@273
|
40
|
|
bsw@273
|
41 if not initiative.issue.fully_frozen and not initiative.issue.closed then
|
|
bsw@273
|
42 if supporter then
|
|
bsw@273
|
43 if not supporter:has_critical_opinion() then
|
|
bsw@277
|
44 ui.container{ attr = { class = "supporter" }, content = function()
|
|
bsw@273
|
45 ui.image{
|
|
bsw@273
|
46 static = "icons/16/thumb_up_green.png"
|
|
bsw@273
|
47 }
|
|
bsw@273
|
48 slot.put(_"Your are supporter")
|
|
bsw@273
|
49 end }
|
|
bsw@273
|
50 else
|
|
bsw@275
|
51 ui.tag{ attr = { class = "potential_supporter" }, content = function()
|
|
bsw@273
|
52 ui.image{
|
|
bsw@273
|
53 static = "icons/16/thumb_up.png"
|
|
bsw@273
|
54 }
|
|
bsw@273
|
55 slot.put(_"Your are potential supporter")
|
|
bsw@273
|
56 end }
|
|
bsw@273
|
57 end
|
|
bsw@273
|
58 ui.link{
|
|
bsw@277
|
59 image = { static = "icons/16/cross.png" },
|
|
bsw@277
|
60 text = _"Withdraw support",
|
|
bsw@273
|
61 module = "initiative",
|
|
bsw@273
|
62 action = "remove_support",
|
|
bsw@273
|
63 id = initiative.id,
|
|
bsw@273
|
64 routing = routing,
|
|
bsw@273
|
65 partial = partial
|
|
bsw@273
|
66 }
|
|
bsw@273
|
67 else
|
|
bsw@273
|
68
|
|
bsw@273
|
69 if not initiative.revoked then
|
|
bsw@273
|
70 local params = param.get_all_cgi()
|
|
bsw@273
|
71 params.dyn = nil
|
|
bsw@273
|
72 ui.link{
|
|
bsw@277
|
73 image = { static = "icons/16/thumb_up_green.png" },
|
|
bsw@273
|
74 text = _"Support this initiative",
|
|
bsw@273
|
75 module = "initiative",
|
|
bsw@273
|
76 action = "add_support",
|
|
bsw@273
|
77 id = initiative.id,
|
|
bsw@273
|
78 routing = routing,
|
|
bsw@273
|
79 partial = partial
|
|
bsw@273
|
80 }
|
|
bsw@273
|
81 end
|
|
bsw/jbe@19
|
82 end
|
|
bsw@273
|
83 end
|
|
bsw@273
|
84
|
|
bsw@273
|
85
|
|
bsw@273
|
86 if (initiative.discussion_url and #initiative.discussion_url > 0) then
|
|
bsw@273
|
87 if initiative.discussion_url:find("^https?://") then
|
|
bsw@273
|
88 if initiative.discussion_url and #initiative.discussion_url > 0 then
|
|
bsw@273
|
89 ui.link{
|
|
bsw@273
|
90 attr = {
|
|
bsw@273
|
91 target = "_blank",
|
|
bsw@273
|
92 title = _"Discussion with initiators"
|
|
bsw@273
|
93 },
|
|
bsw@273
|
94 image = { static = "icons/16/comments.png" },
|
|
bsw@273
|
95 text = _"Discuss with initiators",
|
|
bsw@273
|
96 external = initiative.discussion_url
|
|
bsw@273
|
97 }
|
|
bsw@273
|
98 end
|
|
bsw@273
|
99 else
|
|
bsw@273
|
100 slot.put(encode.html(initiative.discussion_url))
|
|
bsw@273
|
101 end
|
|
bsw@273
|
102 end
|
|
bsw@273
|
103 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
|
bsw@273
|
104 ui.link{
|
|
bsw@277
|
105 image = { static = "icons/16/comments.png" },
|
|
bsw@273
|
106 text = _"change discussion URL",
|
|
bsw@273
|
107 module = "initiative",
|
|
bsw@273
|
108 view = "edit",
|
|
bsw@273
|
109 id = initiative.id
|
|
bsw@273
|
110 }
|
|
bsw@273
|
111 end
|
|
bsw/jbe@19
|
112 end
|
|
bsw/jbe@19
|
113 }
|
|
bsw/jbe@19
|
114 slot.put("<div style='clear: left;'></div>")
|
|
bsw/jbe@19
|
115 end
|
|
bsw/jbe@19
|
116 }
|