liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 558:18e8de7a2b6a

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

Impressum / About Us