bsw/jbe@0: local issue = param.get("issue", "table") bsw@558: local initiatives_selector = param.get("initiatives_selector", "table") bsw/jbe@0: bsw@558: local initiatives bsw@558: if issue then bsw@558: initiatives = issue.initiatives bsw@558: else bsw@558: initiatives = initiatives_selector:exec() bsw@558: initiatives:load_everything_for_member_id(app.session.member_id) bsw@558: end bsw@51: bsw@274: local highlight_initiative = param.get("highlight_initiative", "table") bsw@274: bsw@285: local for_member = param.get("for_member", "table") or app.session.member bsw@285: bsw/jbe@19: local limit = param.get("limit", atom.number) bsw@725: local hide_more_initiatives = param.get("hide_more_initiatives", atom.boolean) bsw/jbe@19: bsw@345: local more_initiatives_count bsw@345: if limit then bsw@551: if #initiatives > limit then bsw@551: more_initiatives_count = #initiatives - limit bsw/jbe@19: end bsw@551: initiatives = {} bsw@551: for i, initiative in ipairs(issue.initiatives) do bsw@551: if i <= limit then bsw@551: initiatives[#initiatives+1] = initiative bsw@551: end bsw@551: end bsw/jbe@19: end bsw/jbe@19: bsw@345: local name = "initiative_list" bsw@345: if issue then bsw@345: name = "issue_" .. tostring(issue.id) .. "_initiative_list" bsw@345: end bsw@345: bsw@345: ui.add_partial_param_names{ name } bsw/jbe@19: bsw@551: if highlight_initiative then bsw@551: local highlight_initiative_found bsw@551: for i, initiative in ipairs(initiatives) do bsw@551: if initiative.id == highlight_initiative.id then bsw@551: highhighlight_initiative_found = true bsw@469: end bsw/jbe@19: end bsw@551: if not highhighlight_initiative_found then bsw@551: initiatives[#initiatives+1] = highlight_initiative bsw@551: if more_initiatives_count then bsw@551: more_initiatives_count = more_initiatives_count - 1 bsw@551: end bsw@551: end bsw@551: end bsw@551: for i, initiative in ipairs(initiatives) do bsw@551: execute.view{ bsw@551: module = "initiative", bsw@551: view = "_list_element", bsw@551: params = { bsw@551: initiative = initiative, bsw@551: selected = highlight_initiative and highlight_initiative.id == initiative.id or nil, bsw@551: } bsw@551: } bsw@551: end bsw/jbe@19: bsw@725: if not hide_more_initiatives and more_initiatives_count and more_initiatives_count > 0 then bsw@345: local text bsw@345: if more_initiatives_count == 1 then bsw@345: text = _("and one more initiative") bsw@345: else bsw@345: text = _("and #{count} more initiatives", { count = more_initiatives_count }) bsw@345: end bsw@345: ui.link{ bsw@345: attr = { class = "more_initiatives_link" }, bsw@345: content = text, bsw@345: module = "issue", bsw@345: view = "show", bsw@345: id = issue.id, bsw@345: } bsw/jbe@19: end