liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 552:3344717939f0

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

Impressum / About Us