liquid_feedback_frontend

view app/main/initiative/_list.lua @ 555:3d9cf824f9df

Added tag v2.beta7 for changeset 03a280f59e9b
author bsw
date Tue Jun 19 18:41:29 2012 +0200 (2012-06-19)
parents c1dc3b14a4f3
children 18e8de7a2b6a
line source
1 local issue = param.get("issue", "table")
3 local initiatives = issue.initiatives
5 local highlight_initiative = param.get("highlight_initiative", "table")
7 local for_member = param.get("for_member", "table") or app.session.member
9 local limit = param.get("limit", atom.number)
11 local more_initiatives_count
12 if limit then
13 if #initiatives > limit then
14 more_initiatives_count = #initiatives - limit
15 end
16 initiatives = {}
17 for i, initiative in ipairs(issue.initiatives) do
18 if i <= limit then
19 initiatives[#initiatives+1] = initiative
20 end
21 end
22 end
24 local issue = param.get("issue", "table")
26 local name = "initiative_list"
27 if issue then
28 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
29 end
31 ui.add_partial_param_names{ name }
33 if highlight_initiative then
34 local highlight_initiative_found
35 for i, initiative in ipairs(initiatives) do
36 if initiative.id == highlight_initiative.id then
37 highhighlight_initiative_found = true
38 end
39 end
40 if not highhighlight_initiative_found then
41 initiatives[#initiatives+1] = highlight_initiative
42 if more_initiatives_count then
43 more_initiatives_count = more_initiatives_count - 1
44 end
45 end
46 end
47 for i, initiative in ipairs(initiatives) do
48 execute.view{
49 module = "initiative",
50 view = "_list_element",
51 params = {
52 initiative = initiative,
53 selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
54 }
55 }
56 end
58 if more_initiatives_count and more_initiatives_count > 0 then
59 local text
60 if more_initiatives_count == 1 then
61 text = _("and one more initiative")
62 else
63 text = _("and #{count} more initiatives", { count = more_initiatives_count })
64 end
65 ui.link{
66 attr = { class = "more_initiatives_link" },
67 content = text,
68 module = "issue",
69 view = "show",
70 id = issue.id,
71 }
72 end

Impressum / About Us