rev |
line source |
bsw/jbe@19
|
1 local initiative = param.get("initiative", "table")
|
bsw@1045
|
2 local for_event = param.get("for_event", atom.boolean)
|
bsw/jbe@1309
|
3 local for_member = param.get("for_member", "table")
|
bsw@1045
|
4
|
bsw@1045
|
5 local issue = initiative.issue
|
bsw/jbe@19
|
6
|
bsw@1666
|
7 local position = param.get("position", atom.number)
|
bsw@1666
|
8
|
bsw@1665
|
9 local class = "initiative mdl-list__item-primary-content"
|
bsw@1045
|
10 if initiative.rank == 1 then
|
bsw@1045
|
11 class = class .. " rank1"
|
bsw@715
|
12 end
|
bsw@1045
|
13 if initiative.revoked then
|
bsw@1045
|
14 class = class .. " revoked"
|
bsw@898
|
15 end
|
bsw@898
|
16
|
bsw@1045
|
17 ui.container{
|
bsw@1045
|
18 attr = { class = class },
|
bsw@1045
|
19 content = function ()
|
bsw@1666
|
20 if position == 1 and not for_member and (
|
bsw@1666
|
21 initiative.issue.state == "finished_with_winner"
|
bsw@1666
|
22 or initiative.issue.state == "finished_without_winner"
|
bsw@1666
|
23 ) then
|
bsw@1666
|
24 util.initiative_pie(initiative)
|
bsw@1666
|
25 end
|
bsw/jbe@1309
|
26 ui.container {
|
bsw@1045
|
27 attr = { class = "initiative_name" },
|
bsw@1045
|
28 content = function()
|
bsw@1826
|
29 if initiative.vote_grade ~= nil then
|
bsw@1826
|
30 if initiative.vote_grade > 0 then
|
bsw@1826
|
31 local text = _"voted yes"
|
bsw@1826
|
32 ui.container{ attr = { class = "mdl-list__item-avatar positive" }, content = function()
|
bsw@1826
|
33 ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_up" }
|
bsw@1826
|
34 end }
|
bsw@1826
|
35 elseif initiative.vote_grade == 0 then
|
bsw@1826
|
36 elseif initiative.vote_grade < 0 then
|
bsw@1826
|
37 local text = _"voted no"
|
bsw@1826
|
38 ui.container{ attr = { class = "mdl-list__item-avatar negative" }, content = function()
|
bsw@1826
|
39 ui.tag{ tag = "i", attr = { class = "material-icons", title = text }, content = "thumb_down" }
|
bsw@1826
|
40 end }
|
bsw@1826
|
41 end
|
bsw@1826
|
42 end
|
bsw/jbe@1309
|
43 if not for_member and app.session.member then
|
bsw/jbe@1309
|
44 if initiative.member_info.supported then
|
bsw/jbe@1309
|
45 if initiative.member_info.satisfied then
|
bsw/jbe@1309
|
46 ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small" }, content = "thumb_up" }
|
bsw/jbe@1309
|
47 --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"You are supporter of this initiative" }
|
bsw/jbe@1309
|
48 else
|
bsw/jbe@1309
|
49 ui.tag{ tag = "i", attr = { id = "lf-initiative__support-" .. initiative.id, class = "material-icons material-icons-small mdl-color-text--orange-500" }, content = "thumb_up" }
|
bsw/jbe@1309
|
50 --ui.container { attr = { class = "mdl-tooltip", ["for"] = "lf-initiative__support-" .. initiative.id }, content = _"supporter with restricting suggestions" }
|
bsw/jbe@1309
|
51 end
|
bsw/jbe@1309
|
52 slot.put(" ")
|
bsw/jbe@1309
|
53 end
|
bsw/jbe@1309
|
54 end
|
bsw@1045
|
55 ui.link {
|
bsw@1045
|
56 text = initiative.display_name,
|
bsw@1045
|
57 module = "initiative", view = "show", id = initiative.id
|
bsw@551
|
58 }
|
bsw/jbe@1309
|
59 end
|
bsw/jbe@1309
|
60 }
|
bsw/jbe@1309
|
61 ui.container{ attr = { class = "mdl-list__item-text-body" }, content = function()
|
bsw/jbe@1309
|
62 local draft_content = initiative.current_draft.content
|
bsw/jbe@1309
|
63 if config.initiative_abstract then
|
bsw/jbe@1309
|
64 local abstract = string.match(draft_content, "(.+)<!%--END_OF_ABSTRACT%-->")
|
bsw/jbe@1309
|
65 if abstract then
|
bsw/jbe@1309
|
66 slot.put(abstract)
|
bsw/jbe@1309
|
67 end
|
bsw/jbe@1309
|
68 end
|
bsw/jbe@1309
|
69 if not config.voting_only then
|
bsw/jbe@1309
|
70 if app.session:has_access("authors_pseudonymous") then
|
bsw/jbe@1309
|
71 local initiator_members = initiative:get_reference_selector("initiating_members")
|
bsw/jbe@1309
|
72 :add_field("initiator.accepted", "accepted")
|
bsw/jbe@1309
|
73 :add_order_by("member.name")
|
bsw/jbe@1309
|
74 :add_where("initiator.accepted")
|
bsw/jbe@1309
|
75 :exec()
|
bsw/jbe@1309
|
76
|
bsw/jbe@1309
|
77 local initiators = {}
|
bsw/jbe@1309
|
78 for i, member in ipairs(initiator_members) do
|
bsw/jbe@1309
|
79 if member.accepted then
|
bsw/jbe@1309
|
80 initiators[#initiators+1] = member.name
|
bsw/jbe@1309
|
81 end
|
bsw@862
|
82 end
|
bsw/jbe@1309
|
83 ui.tag{ content = _"by" }
|
bsw/jbe@1309
|
84 slot.put(" ")
|
bsw/jbe@1309
|
85 ui.tag{ content = table.concat(initiators, ", ") }
|
bsw/jbe@1309
|
86 slot.put("<br />")
|
bsw@556
|
87 end
|
bsw@551
|
88 end
|
bsw/jbe@1309
|
89 if initiative.rank ~= 1 and (issue.voter_count == nil or issue.voter_count > 0) and not for_event then
|
bsw/jbe@1309
|
90 if not config.voting_only or issue.closed then
|
bsw/jbe@1309
|
91 execute.view {
|
bsw/jbe@1309
|
92 module = "initiative", view = "_bargraph", params = {
|
bsw/jbe@1309
|
93 initiative = initiative,
|
bsw/jbe@1309
|
94 battled_initiative = issue.initiatives[1]
|
bsw/jbe@1309
|
95 }
|
bsw/jbe@1309
|
96 }
|
bsw/jbe@1309
|
97
|
bsw/jbe@1309
|
98 slot.put(" ")
|
bsw/jbe@1309
|
99
|
bsw/jbe@1309
|
100 ui.supporter_count(initiative)
|
bsw/jbe@1309
|
101 end
|
bsw/jbe@1309
|
102 end
|
bsw/jbe@1309
|
103
|
bsw/jbe@1309
|
104 if initiative.positive_votes ~= nil then
|
bsw/jbe@1309
|
105
|
bsw@1826
|
106 local result_text = ""
|
bsw/jbe@1309
|
107
|
bsw/jbe@1309
|
108 if issue.voter_count == 0 then
|
bsw/jbe@1309
|
109 result_text = _("No votes (0)", { result = result })
|
bsw/jbe@1309
|
110
|
bsw/jbe@1309
|
111 elseif initiative.rank == 1 and not for_event then
|
bsw/jbe@1309
|
112 local result = ""
|
bsw/jbe@1309
|
113 if initiative.eligible then
|
bsw/jbe@1309
|
114 result = _("Reached #{sign}#{num}/#{den}", {
|
bsw/jbe@1309
|
115 sign = issue.policy.direct_majority_strict and ">" or "≥",
|
bsw/jbe@1309
|
116 num = issue.policy.direct_majority_num,
|
bsw/jbe@1309
|
117 den = issue.policy.direct_majority_den
|
bsw/jbe@1309
|
118 })
|
bsw/jbe@1309
|
119 else
|
bsw/jbe@1309
|
120 result = _("Failed #{sign}#{num}/#{den}", {
|
bsw/jbe@1309
|
121 sign = issue.policy.direct_majority_strict and ">" or "≥",
|
bsw/jbe@1309
|
122 num = issue.policy.direct_majority_num,
|
bsw/jbe@1309
|
123 den = issue.policy.direct_majority_den
|
bsw/jbe@1309
|
124 })
|
bsw/jbe@1309
|
125 end
|
bsw/jbe@1309
|
126 local neutral_count = issue.voter_count - initiative.positive_votes - initiative.negative_votes
|
bsw/jbe@1309
|
127
|
bsw/jbe@1309
|
128 result_text = _("#{result}: #{yes_count} Yes (#{yes_percent}), #{no_count} No (#{no_percent}), #{neutral_count} Abstention (#{neutral_percent})", {
|
bsw/jbe@1309
|
129 result = result,
|
bsw/jbe@1309
|
130 yes_count = initiative.positive_votes,
|
bsw/jbe@1309
|
131 yes_percent = format.percent_floor(initiative.positive_votes, issue.voter_count),
|
bsw/jbe@1309
|
132 neutral_count = neutral_count,
|
bsw/jbe@1309
|
133 neutral_percent = format.percent_floor(neutral_count, issue.voter_count),
|
bsw/jbe@1309
|
134 no_count = initiative.negative_votes,
|
bsw/jbe@1309
|
135 no_percent = format.percent_floor(initiative.negative_votes, issue.voter_count)
|
bsw/jbe@1309
|
136 })
|
bsw@1826
|
137
|
bsw/jbe@1309
|
138 end
|
bsw/jbe@1309
|
139
|
bsw/jbe@1309
|
140 ui.container { attr = { class = "result" }, content = result_text }
|
bsw@1826
|
141
|
bsw/jbe@1309
|
142 end
|
bsw/jbe@1309
|
143
|
bsw/jbe@1309
|
144 end }
|
bsw@556
|
145 end
|
bsw@1045
|
146 }
|
bsw@1045
|
147
|
bsw@1665
|
148 if config.attachments and config.attachments.preview_in_listing then
|
bsw@1665
|
149
|
bsw@1665
|
150 local file = File:new_selector()
|
bsw@1665
|
151 :left_join("draft_attachment", nil, "draft_attachment.file_id = file.id")
|
bsw@1665
|
152 :add_where{ "draft_attachment.draft_id = ?", initiative.current_draft.id }
|
bsw@1665
|
153 :reset_fields()
|
bsw@1665
|
154 :add_field("file.id")
|
bsw@1665
|
155 :add_field("draft_attachment.title")
|
bsw@1665
|
156 :add_field("draft_attachment.description")
|
bsw@1665
|
157 :add_order_by("draft_attachment.id")
|
bsw@1665
|
158 :limit(1)
|
bsw@1665
|
159 :optional_object_mode()
|
bsw@1665
|
160 :exec()
|
bsw@1665
|
161
|
bsw@1665
|
162 if file then
|
bsw@1665
|
163 ui.image{ attr = { class = "attachment" }, module = "file", view = "show.jpg", id = file.id, params = { preview = true } }
|
bsw@1665
|
164 end
|
bsw@1665
|
165 end
|
bsw@1665
|
166
|
bsw@1665
|
167
|