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