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@278
|
6 ui.partial{
|
bsw@278
|
7 module = "initiative",
|
bsw@278
|
8 view = "show_support",
|
bsw@278
|
9 id = initiative.id,
|
bsw@278
|
10 target = "initiative_" .. tostring(initiative.id) .. "_support",
|
bsw@278
|
11 content = function()
|
bsw/jbe@19
|
12
|
bsw@278
|
13 ui.container{
|
bsw@278
|
14 attr = { class = "actions" },
|
bsw@278
|
15 content = function()
|
bsw@278
|
16
|
bsw@278
|
17 local initiative = param.get("initiative", "table")
|
bsw@278
|
18 local supporter = Supporter:by_pk(initiative.id, app.session.member.id)
|
bsw@278
|
19
|
bsw@278
|
20 local partial = {
|
bsw@278
|
21 routing = {
|
bsw@278
|
22 default = {
|
bsw@278
|
23 mode = "redirect",
|
bsw@278
|
24 module = "initiative",
|
bsw@278
|
25 view = "show_support",
|
bsw@278
|
26 id = initiative.id
|
bsw@278
|
27 }
|
bsw@278
|
28 }
|
bsw@278
|
29 }
|
bsw/jbe@0
|
30
|
bsw@278
|
31 local routing = {
|
bsw@278
|
32 default = {
|
bsw@278
|
33 mode = "redirect",
|
bsw@278
|
34 module = request.get_module(),
|
bsw@278
|
35 view = request.get_view(),
|
bsw@278
|
36 id = param.get_id_cgi(),
|
bsw@278
|
37 params = param.get_all_cgi()
|
bsw@278
|
38 }
|
bsw@278
|
39 }
|
bsw/jbe@19
|
40
|
bsw@278
|
41 if not initiative.issue.fully_frozen and not initiative.issue.closed then
|
bsw@278
|
42 if supporter then
|
bsw@278
|
43 if not supporter:has_critical_opinion() then
|
bsw@278
|
44 ui.container{ attr = { class = "supporter" }, content = function()
|
bsw@278
|
45 ui.image{
|
bsw@278
|
46 static = "icons/16/thumb_up_green.png"
|
bsw@278
|
47 }
|
bsw@278
|
48 slot.put(_"Your are supporter")
|
bsw@278
|
49 end }
|
bsw@278
|
50 else
|
bsw@278
|
51 ui.tag{ attr = { class = "potential_supporter" }, content = function()
|
bsw@278
|
52 ui.image{
|
bsw@278
|
53 static = "icons/16/thumb_up.png"
|
bsw@278
|
54 }
|
bsw@278
|
55 slot.put(_"Your are potential supporter")
|
bsw@278
|
56 end }
|
bsw@278
|
57 end
|
bsw@278
|
58 ui.link{
|
bsw@278
|
59 image = { static = "icons/16/cross.png" },
|
bsw@278
|
60 text = _"Withdraw support",
|
bsw@278
|
61 module = "initiative",
|
bsw@278
|
62 action = "remove_support",
|
bsw@278
|
63 id = initiative.id,
|
bsw@278
|
64 routing = routing,
|
bsw@278
|
65 partial = partial
|
bsw@278
|
66 }
|
bsw@281
|
67 elseif not initiative.revoked and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
|
bsw@281
|
68 local params = param.get_all_cgi()
|
bsw@281
|
69 params.dyn = nil
|
bsw@281
|
70 ui.link{
|
bsw@281
|
71 image = { static = "icons/16/thumb_up_green.png" },
|
bsw@281
|
72 text = _"Support this initiative",
|
bsw@281
|
73 module = "initiative",
|
bsw@281
|
74 action = "add_support",
|
bsw@281
|
75 id = initiative.id,
|
bsw@281
|
76 routing = routing,
|
bsw@281
|
77 partial = partial
|
bsw@281
|
78 }
|
poelzi@148
|
79 end
|
bsw@278
|
80 end
|
bsw@278
|
81
|
bsw@278
|
82
|
bsw@278
|
83 if (initiative.discussion_url and #initiative.discussion_url > 0) then
|
bsw@278
|
84 if initiative.discussion_url:find("^https?://") then
|
bsw@278
|
85 if initiative.discussion_url and #initiative.discussion_url > 0 then
|
bsw@278
|
86 ui.link{
|
bsw@278
|
87 attr = {
|
bsw@278
|
88 target = "_blank",
|
bsw@278
|
89 title = _"Discussion with initiators"
|
bsw@278
|
90 },
|
bsw@278
|
91 image = { static = "icons/16/comments.png" },
|
bsw@278
|
92 text = _"Discuss with initiators",
|
bsw@278
|
93 external = initiative.discussion_url
|
bsw@278
|
94 }
|
bsw@278
|
95 end
|
bsw@278
|
96 else
|
bsw@278
|
97 slot.put(encode.html(initiative.discussion_url))
|
bsw@278
|
98 end
|
bsw@278
|
99 end
|
bsw@278
|
100 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw/jbe@19
|
101 ui.link{
|
bsw@278
|
102 image = { static = "icons/16/comments.png" },
|
bsw@278
|
103 text = _"change discussion URL",
|
bsw@278
|
104 module = "initiative",
|
bsw@278
|
105 view = "edit",
|
bsw@278
|
106 id = initiative.id
|
bsw/jbe@0
|
107 }
|
bsw/jbe@19
|
108 end
|
bsw@280
|
109 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@280
|
110 ui.link{
|
bsw@280
|
111 content = function()
|
bsw@280
|
112 ui.image{ static = "icons/16/script_add.png" }
|
bsw@280
|
113 slot.put(_"Edit draft")
|
bsw@280
|
114 end,
|
bsw@280
|
115 module = "draft",
|
bsw@280
|
116 view = "new",
|
bsw@280
|
117 params = { initiative_id = initiative.id }
|
bsw@280
|
118 }
|
bsw@280
|
119 end
|
bsw@280
|
120
|
bsw@280
|
121 if initiator and initiator.accepted and not initiative.issue.half_frozen and not initiative.issue.closed and not initiative.revoked then
|
bsw@280
|
122 ui.link{
|
bsw@280
|
123 content = function()
|
bsw@280
|
124 ui.image{ static = "icons/16/script_delete.png" }
|
bsw@280
|
125 slot.put(_"Revoke initiative")
|
bsw@280
|
126 end,
|
bsw@280
|
127 module = "initiative",
|
bsw@280
|
128 view = "revoke",
|
bsw@280
|
129 id = initiative.id
|
bsw@280
|
130 }
|
bsw@280
|
131 end
|
bsw/jbe@0
|
132 end
|
bsw/jbe@19
|
133 }
|
bsw@280
|
134
|
bsw@280
|
135
|
bsw@278
|
136 slot.put("<div style='clear: left;'></div>")
|
bsw@10
|
137 end
|
bsw@278
|
138 }
|