liquid_feedback_frontend
view app/main/initiative/_list.lua @ 1751:ddbd46a34b6a
Allow API lookup of member profile fields
author | bsw |
---|---|
date | Tue Oct 12 15:37:28 2021 +0200 (2021-10-12) |
parents | f582e3d6434c |
children | 9043f24d872b |
line source
1 local for_member = param.get("for_member", "table")
3 local initiatives = param.get("initiatives", "table")
4 local ommit_initiative_id = param.get ( "ommit_initiative_id", "number" )
7 local for_initiative = param.get("initiative", "table")
9 local for_event = param.get("for_event", atom.boolean)
11 if for_initiative then
12 initiatives = { for_initiative }
13 end
15 ui.tag {
16 tag = "ul",
17 attr = { class = "initiatives mdl-list" },
18 content = function ()
19 local last_group
20 for i, initiative in ipairs(initiatives) do
21 local group
22 if initiative.issue.closed then
23 if initiative.rank == 1 then
24 group = "1st_rank"
25 elseif initiative.admitted then
26 group = "admitted"
27 elseif initiative.revoked_by_member_id then
28 group = "revoked"
29 else
30 group = "not_admitted"
31 end
32 end
33 if not for_initiative and group ~= last_group and not for_event and not for_member then
35 local text
36 if group == "admitted" then
37 if initiative.issue.state == "finished_with_winner" then
38 text = _"Competing initiatives in pairwise comparison to winner:"
39 elseif initiative.issue.voter_count and initiative.issue.voter_count > 0 then
40 text = _"Competing initiatives in pairwise comparison to best initiative:"
41 end
42 end
43 if group == "not_admitted" and initiative.issue.state ~= "canceled_no_initiative_admitted" then
44 text = _("Competing initiatives failed the 2nd quorum (#{num}/#{den}):", {
45 num = initiative.issue.policy.initiative_quorum_num,
46 den = initiative.issue.policy.initiative_quorum_den
47 } )
48 end
49 if text then
50 ui.tag{ tag = "li", attr = { class = "mdl-list__item" }, content = function()
51 ui.container{ attr = { class = "mdl-list__item-primary-content" }, content = text }
52 end }
53 end
54 last_group = group
55 end
57 if ommit_initiative_id ~= initiative.id then
58 local class = "mdl-list__item mdl-list__item--three-line"
59 if app.session.member then
60 if initiative.member_info.supported then
61 class = class .. " supported"
62 end
63 if initiative.member_info.satisfied then
64 class = class .. " satisfied"
65 end
66 end
67 local position
68 if not ommit_initiative_id then
69 position = i
70 end
71 ui.tag {
72 tag = "li", attr = { class = class },
73 content = function ()
74 execute.view {
75 module = "initiative", view = "_list_element", params = {
76 position = position,
77 initiative = initiative, for_event = for_event, for_member = for_member
78 }
79 }
80 end
81 }
82 end
83 end
84 end
85 }