liquid_feedback_frontend
view app/main/initiative/_list.lua @ 691:e9cf53cd5954
Made "vote now" string translateable
| author | bsw | 
|---|---|
| date | Tue Jun 26 18:22:25 2012 +0200 (2012-06-26) | 
| parents | 18e8de7a2b6a | 
| children | 344e5fdce8c9 | 
 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)
    18 local more_initiatives_count
    19 if limit then
    20   if #initiatives > limit then
    21     more_initiatives_count = #initiatives - limit
    22   end
    23   initiatives = {}
    24   for i, initiative in ipairs(issue.initiatives) do
    25     if i <= limit then
    26       initiatives[#initiatives+1] = initiative
    27     end
    28   end
    29 end
    31 local name = "initiative_list"
    32 if issue then
    33   name = "issue_" .. tostring(issue.id) ..  "_initiative_list"
    34 end
    36 ui.add_partial_param_names{ name }
    38 if highlight_initiative then
    39   local highlight_initiative_found
    40   for i, initiative in ipairs(initiatives) do
    41     if initiative.id == highlight_initiative.id then
    42       highhighlight_initiative_found = true
    43     end
    44   end
    45   if not highhighlight_initiative_found then
    46     initiatives[#initiatives+1] = highlight_initiative
    47     if more_initiatives_count then
    48       more_initiatives_count = more_initiatives_count - 1
    49     end
    50   end
    51 end
    52 for i, initiative in ipairs(initiatives) do
    53   execute.view{
    54     module = "initiative",
    55     view = "_list_element",
    56     params = {
    57       initiative = initiative,
    58       selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
    59     }
    60   }
    61 end
    63 if more_initiatives_count and more_initiatives_count > 0 then
    64   local text
    65   if more_initiatives_count == 1 then
    66     text = _("and one more initiative")
    67   else
    68     text = _("and #{count} more initiatives", { count = more_initiatives_count })
    69   end
    70   ui.link{
    71     attr = { class = "more_initiatives_link" },
    72     content = text,
    73     module = "issue",
    74     view = "show",
    75     id = issue.id,
    76   }
    77 end
