liquid_feedback_frontend

view app/main/initiative/_list.lua @ 959:1d9e48ecd254

Ordering of suggestions by harmonic weight
author bsw
date Sat Feb 02 22:16:10 2013 +0100 (2013-02-02)
parents a1ff5d08f0f4
children 701a5cf6b067
line source
1 local issue = param.get("issue", "table")
2 local initiatives_selector = param.get("initiatives_selector", "table")
4 local initiatives
5 if issue then
6 initiatives = issue.initiatives
7 else
8 initiatives = initiatives_selector:exec()
9 initiatives:load_everything_for_member_id(app.session.member_id)
10 end
12 local highlight_initiative = param.get("highlight_initiative", "table")
14 local for_member = param.get("for_member", "table") or app.session.member
16 local limit = param.get("limit", atom.number)
17 local hide_more_initiatives = param.get("hide_more_initiatives", atom.boolean)
19 local more_initiatives_count
20 if limit then
21 if #initiatives > limit then
22 more_initiatives_count = #initiatives - limit
23 end
24 initiatives = {}
25 for i, initiative in ipairs(issue.initiatives) do
26 if i <= limit then
27 initiatives[#initiatives+1] = initiative
28 end
29 end
30 end
32 local name = "initiative_list"
33 if issue then
34 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
35 end
37 ui.add_partial_param_names{ name }
39 if highlight_initiative then
40 local highlight_initiative_found
41 for i, initiative in ipairs(initiatives) do
42 if initiative.id == highlight_initiative.id then
43 highhighlight_initiative_found = true
44 end
45 end
46 if not highhighlight_initiative_found then
47 initiatives[#initiatives+1] = highlight_initiative
48 if more_initiatives_count then
49 more_initiatives_count = more_initiatives_count - 1
50 end
51 end
52 end
53 for i, initiative in ipairs(initiatives) do
54 execute.view{
55 module = "initiative",
56 view = "_list_element",
57 params = {
58 initiative = initiative,
59 selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
60 for_member = for_member
61 }
62 }
63 end
65 if not hide_more_initiatives and more_initiatives_count and more_initiatives_count > 0 then
66 local text
67 if more_initiatives_count == 1 then
68 text = _("and one more initiative")
69 else
70 text = _("and #{count} more initiatives", { count = more_initiatives_count })
71 end
72 ui.link{
73 attr = { class = "more_initiatives_link" },
74 content = text,
75 module = "issue",
76 view = "show",
77 id = issue.id,
78 }
79 end

Impressum / About Us