rev |
line source |
bsw/jbe@0
|
1
|
bsw/jbe@19
|
2 local initiative = param.get("initiative", "table")
|
bsw/jbe@19
|
3 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
|
bsw/jbe@19
|
4
|
bsw/jbe@19
|
5 local unique_string = multirand.string(16, '0123456789abcdef')
|
bsw/jbe@19
|
6
|
bsw/jbe@19
|
7
|
bsw/jbe@19
|
8 local partial = {
|
bsw/jbe@19
|
9 routing = {
|
bsw/jbe@19
|
10 default = {
|
bsw/jbe@19
|
11 mode = "redirect",
|
bsw/jbe@19
|
12 module = "initiative",
|
bsw/jbe@19
|
13 view = "show_support",
|
bsw/jbe@19
|
14 id = initiative.id
|
bsw/jbe@19
|
15 }
|
bsw/jbe@19
|
16 }
|
bsw/jbe@19
|
17 }
|
bsw/jbe@0
|
18
|
bsw/jbe@19
|
19 local routing = {
|
bsw/jbe@19
|
20 default = {
|
bsw/jbe@19
|
21 mode = "redirect",
|
bsw/jbe@19
|
22 module = request.get_module(),
|
bsw/jbe@19
|
23 view = request.get_view(),
|
bsw/jbe@19
|
24 id = param.get_id_cgi(),
|
bsw/jbe@19
|
25 params = param.get_all_cgi()
|
bsw/jbe@19
|
26 }
|
bsw/jbe@19
|
27 }
|
bsw/jbe@19
|
28
|
bsw/jbe@19
|
29 if not initiative.issue.fully_frozen and not initiative.issue.closed then
|
bsw/jbe@19
|
30 if supporter then
|
bsw/jbe@19
|
31 if not supporter:has_critical_opinion() then
|
bsw@10
|
32 ui.container{
|
bsw/jbe@19
|
33 attr = {
|
bsw/jbe@19
|
34 class = "head head_supporter",
|
bsw/jbe@19
|
35 style = "cursor: pointer;",
|
bsw/jbe@19
|
36 onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';"
|
bsw/jbe@19
|
37 },
|
bsw@10
|
38 content = function()
|
bsw/jbe@19
|
39 ui.image{
|
bsw/jbe@19
|
40 static = "icons/16/thumb_up_green.png"
|
bsw/jbe@0
|
41 }
|
poelzi@148
|
42 if supporter.auto_support then
|
poelzi@148
|
43 slot.put(_"Your are supporter (Autosupport enabled)")
|
poelzi@148
|
44 else
|
poelzi@148
|
45 slot.put(_"Your are supporter")
|
poelzi@148
|
46 end
|
bsw/jbe@19
|
47 ui.image{
|
bsw/jbe@19
|
48 static = "icons/16/dropdown.png"
|
bsw/jbe@19
|
49 }
|
bsw@10
|
50 end
|
bsw@10
|
51 }
|
bsw@10
|
52 else
|
bsw/jbe@19
|
53 ui.container{
|
bsw/jbe@19
|
54 attr = {
|
bsw/jbe@19
|
55 class = "head head_potential_supporter",
|
bsw/jbe@19
|
56 style = "cursor: pointer;",
|
bsw/jbe@19
|
57 onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'block';"
|
bsw/jbe@19
|
58 },
|
bsw/jbe@19
|
59 content = function()
|
bsw/jbe@19
|
60 ui.image{
|
bsw/jbe@19
|
61 static = "icons/16/thumb_up.png"
|
bsw/jbe@19
|
62 }
|
poelzi@148
|
63 if supporter.auto_support then
|
poelzi@148
|
64 slot.put(_"Your are potential supporter (WARNING: Autosupport enabled)")
|
poelzi@148
|
65 else
|
poelzi@148
|
66 slot.put(_"Your are potential supporter")
|
poelzi@148
|
67 end
|
bsw/jbe@19
|
68 ui.image{
|
bsw/jbe@19
|
69 static = "icons/16/dropdown.png"
|
bsw/jbe@19
|
70 }
|
bsw/jbe@19
|
71 end
|
bsw/jbe@19
|
72 }
|
bsw/jbe@19
|
73 end
|
bsw/jbe@19
|
74 ui.container{
|
bsw/jbe@19
|
75 attr = { class = "content", id = "support_content_" .. unique_string .. "" },
|
bsw/jbe@19
|
76 content = function()
|
bsw/jbe@19
|
77 ui.container{
|
bsw/jbe@19
|
78 attr = {
|
bsw/jbe@19
|
79 class = "close",
|
bsw/jbe@19
|
80 style = "cursor: pointer;",
|
bsw/jbe@19
|
81 onclick = "document.getElementById('support_content_" .. unique_string .. "').style.display = 'none';"
|
bsw/jbe@19
|
82 },
|
bsw@10
|
83 content = function()
|
bsw/jbe@19
|
84 ui.image{ static = "icons/16/cross.png" }
|
bsw/jbe@19
|
85 end
|
bsw/jbe@19
|
86 }
|
bsw/jbe@19
|
87 if supporter then
|
poelzi@148
|
88 if config.auto_support then
|
poelzi@148
|
89 if supporter.auto_support then
|
poelzi@148
|
90 ui.link{
|
poelzi@148
|
91 image = { static = "icons/16/cancel.png" },
|
poelzi@148
|
92 text = _"Disable autosupport for this initiative",
|
poelzi@148
|
93 module = "initiative",
|
poelzi@148
|
94 action = "add_support",
|
poelzi@148
|
95 id = initiative.id,
|
poelzi@148
|
96 routing = routing,
|
poelzi@148
|
97 partial = partial,
|
poelzi@148
|
98 params = { auto_support = false }
|
poelzi@148
|
99 }
|
poelzi@148
|
100 else
|
poelzi@148
|
101 ui.link{
|
poelzi@168
|
102 image = { static = "icons/16/arrow_refresh.png" },
|
poelzi@148
|
103 text = _"Enable autosupport for this initiative",
|
poelzi@148
|
104 module = "initiative",
|
poelzi@148
|
105 action = "add_support",
|
poelzi@148
|
106 id = initiative.id,
|
poelzi@148
|
107 routing = routing,
|
poelzi@148
|
108 partial = partial,
|
poelzi@148
|
109 params = { auto_support = true }
|
poelzi@148
|
110 }
|
poelzi@148
|
111 end
|
poelzi@148
|
112 end
|
bsw/jbe@19
|
113 ui.link{
|
bsw/jbe@19
|
114 image = { static = "icons/16/thumb_down_red.png" },
|
bsw/jbe@19
|
115 text = _"Remove my support from this initiative",
|
bsw/jbe@19
|
116 module = "initiative",
|
bsw/jbe@19
|
117 action = "remove_support",
|
bsw/jbe@19
|
118 id = initiative.id,
|
bsw/jbe@19
|
119 routing = routing,
|
bsw/jbe@19
|
120 partial = partial
|
bsw/jbe@0
|
121 }
|
bsw/jbe@19
|
122 else
|
bsw/jbe@19
|
123 end
|
bsw/jbe@0
|
124 end
|
bsw/jbe@19
|
125 }
|
bsw/jbe@19
|
126 else
|
bsw/jbe@19
|
127 if not initiative.revoked then
|
bsw/jbe@19
|
128 local params = param.get_all_cgi()
|
bsw/jbe@19
|
129 params.dyn = nil
|
bsw/jbe@19
|
130 ui.link{
|
bsw/jbe@19
|
131 image = { static = "icons/16/thumb_up_green.png" },
|
bsw/jbe@19
|
132 text = _"Support this initiative",
|
bsw/jbe@19
|
133 module = "initiative",
|
bsw/jbe@19
|
134 action = "add_support",
|
bsw/jbe@19
|
135 id = initiative.id,
|
bsw/jbe@19
|
136 routing = routing,
|
bsw/jbe@19
|
137 partial = partial
|
bsw/jbe@19
|
138 }
|
bsw/jbe@4
|
139 end
|
bsw@10
|
140 end
|
bsw/jbe@19
|
141 end
|
bsw@10
|
142
|