liquid_feedback_frontend
view app/main/initiative/_list.lua @ 785:d2ecfc4ae757
Changed locale/help/index.index.de.txt
| author | jbe | 
|---|---|
| date | Fri Jun 29 00:20:58 2012 +0200 (2012-06-29) | 
| parents | 344e5fdce8c9 | 
| children | a1ff5d08f0f4 | 
 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)
    17 local hide_more_initiatives = param.get("hide_more_initiatives", atom.boolean)
    19 local more_initiatives_count
    20 if limit then
    21   if #initiatives > limit then
    22     more_initiatives_count = #initiatives - limit
    23   end
    24   initiatives = {}
    25   for i, initiative in ipairs(issue.initiatives) do
    26     if i <= limit then
    27       initiatives[#initiatives+1] = initiative
    28     end
    29   end
    30 end
    32 local name = "initiative_list"
    33 if issue then
    34   name = "issue_" .. tostring(issue.id) ..  "_initiative_list"
    35 end
    37 ui.add_partial_param_names{ name }
    39 if highlight_initiative then
    40   local highlight_initiative_found
    41   for i, initiative in ipairs(initiatives) do
    42     if initiative.id == highlight_initiative.id then
    43       highhighlight_initiative_found = true
    44     end
    45   end
    46   if not highhighlight_initiative_found then
    47     initiatives[#initiatives+1] = highlight_initiative
    48     if more_initiatives_count then
    49       more_initiatives_count = more_initiatives_count - 1
    50     end
    51   end
    52 end
    53 for i, initiative in ipairs(initiatives) do
    54   execute.view{
    55     module = "initiative",
    56     view = "_list_element",
    57     params = {
    58       initiative = initiative,
    59       selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
    60     }
    61   }
    62 end
    64 if not hide_more_initiatives and more_initiatives_count and more_initiatives_count > 0 then
    65   local text
    66   if more_initiatives_count == 1 then
    67     text = _("and one more initiative")
    68   else
    69     text = _("and #{count} more initiatives", { count = more_initiatives_count })
    70   end
    71   ui.link{
    72     attr = { class = "more_initiatives_link" },
    73     content = text,
    74     module = "issue",
    75     view = "show",
    76     id = issue.id,
    77   }
    78 end
