liquid_feedback_frontend

annotate app/main/initiative/_list.lua @ 725:344e5fdce8c9

Fixed public search, made draft history available again
author bsw
date Thu Jun 28 13:52:42 2012 +0200 (2012-06-28)
parents 18e8de7a2b6a
children a1ff5d08f0f4
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@725 17 local hide_more_initiatives = param.get("hide_more_initiatives", atom.boolean)
bsw/jbe@19 18
bsw@345 19 local more_initiatives_count
bsw@345 20 if limit then
bsw@551 21 if #initiatives > limit then
bsw@551 22 more_initiatives_count = #initiatives - limit
bsw/jbe@19 23 end
bsw@551 24 initiatives = {}
bsw@551 25 for i, initiative in ipairs(issue.initiatives) do
bsw@551 26 if i <= limit then
bsw@551 27 initiatives[#initiatives+1] = initiative
bsw@551 28 end
bsw@551 29 end
bsw/jbe@19 30 end
bsw/jbe@19 31
bsw@345 32 local name = "initiative_list"
bsw@345 33 if issue then
bsw@345 34 name = "issue_" .. tostring(issue.id) .. "_initiative_list"
bsw@345 35 end
bsw@345 36
bsw@345 37 ui.add_partial_param_names{ name }
bsw/jbe@19 38
bsw@551 39 if highlight_initiative then
bsw@551 40 local highlight_initiative_found
bsw@551 41 for i, initiative in ipairs(initiatives) do
bsw@551 42 if initiative.id == highlight_initiative.id then
bsw@551 43 highhighlight_initiative_found = true
bsw@469 44 end
bsw/jbe@19 45 end
bsw@551 46 if not highhighlight_initiative_found then
bsw@551 47 initiatives[#initiatives+1] = highlight_initiative
bsw@551 48 if more_initiatives_count then
bsw@551 49 more_initiatives_count = more_initiatives_count - 1
bsw@551 50 end
bsw@551 51 end
bsw@551 52 end
bsw@551 53 for i, initiative in ipairs(initiatives) do
bsw@551 54 execute.view{
bsw@551 55 module = "initiative",
bsw@551 56 view = "_list_element",
bsw@551 57 params = {
bsw@551 58 initiative = initiative,
bsw@551 59 selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
bsw@551 60 }
bsw@551 61 }
bsw@551 62 end
bsw/jbe@19 63
bsw@725 64 if not hide_more_initiatives and more_initiatives_count and more_initiatives_count > 0 then
bsw@345 65 local text
bsw@345 66 if more_initiatives_count == 1 then
bsw@345 67 text = _("and one more initiative")
bsw@345 68 else
bsw@345 69 text = _("and #{count} more initiatives", { count = more_initiatives_count })
bsw@345 70 end
bsw@345 71 ui.link{
bsw@345 72 attr = { class = "more_initiatives_link" },
bsw@345 73 content = text,
bsw@345 74 module = "issue",
bsw@345 75 view = "show",
bsw@345 76 id = issue.id,
bsw@345 77 }
bsw/jbe@19 78 end

Impressum / About Us