liquid_feedback_frontend

view app/main/initiative/_list_element.lua @ 1668:6d75df24e66e

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

Impressum / About Us