liquid_feedback_frontend
view app/main/timeline/_list.lua @ 42:1ccbefa729eb
Added tag beta13 for changeset 53a45356c107
| author | jbe | 
|---|---|
| date | Sun Mar 07 15:42:40 2010 +0100 (2010-03-07) | 
| parents | 00d1004545f1 | 
| children | 166fd10c7e81 | 
 line source
     1 local timeline_selector = param.get("timeline_selector", "table")
     2 local event_names = param.get("event_names", "table")
     3 local initiatives_per_page = param.get("initiatives_per_page", atom.number) or 3
     5 ui.paginate{
     6   per_page = param.get("per_page", atom.number) or 25,
     7   selector = timeline_selector,
     8   content = function()
     9     local timelines = timeline_selector:exec()
    10     timelines:load("issue")
    11     timelines:load("initiative")
    12     timelines:load("member")
    13     ui.list{
    14       attr = { class = "nohover" },
    15       records = timelines,
    16       columns = {
    17         {
    18           field_attr = { style = "width: 10em;" },
    19           content = function(timeline)
    20             ui.field.text{
    21               attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
    22               value = format.time(timeline.occurrence)
    23             }
    25             ui.field.text{
    26               attr = { style = "font-size: 75%; font-weight: bold;"},
    27               value = event_names[timeline.event] or timeline.event
    28             }
    29             if timeline.event == "draft_created" and timeline.count > 1 then
    30               ui.field.text{
    31                 attr = { style = "font-size: 75%;"},
    32                 value = _("(#{more_count} duplicates removed)", { more_count = timeline.count - 1 })
    33               }
    34             end
    35           end
    36         },
    37         {
    38           content = function(timeline)
    39             local issue
    40             local initiative
    41             if timeline.issue then
    42               issue = timeline.issue
    43             elseif timeline.initiative then
    44               initiative = timeline.initiative
    45               issue = initiative.issue
    46             elseif timeline.draft then
    47               initiative = timeline.draft.initiative
    48               issue = initiative.issue
    49             elseif timeline.suggestion then
    50               initiative = timeline.suggestion.initiative
    51               issue = initiative.issue
    52             end
    53             if issue then
    54               if timeline.is_interested then
    55                 local label = _"You are interested in this issue",
    56                 ui.image{
    57                   attr = { alt = label, title = label, style = "float: left; margin-right: 0.5em;" },
    58                   static = "icons/16/eye.png"
    59                 }
    60               end
    61               slot.put(" ")
    62               ui.tag{
    63                 tag = "span",
    64                 attr = { style = "font-size: 75%; font-weight: bold; background-color: #ccc; display: block; margin-bottom: 1ex;"},
    65                 content = issue.area.name .. ", " .. _("Issue ##{id}", { id = issue.id })
    66               }
    67             else
    68               ui.tag{
    69                 tag = "span",
    70                 attr = { style = "font-size: 75%; background-color: #ccc; display: block; margin-bottom: 1ex;"},
    71                 content = function() slot.put(" ") end
    72               }
    73             end
    75             if timeline.member then
    76               execute.view{
    77                 module = "member_image",
    78                 view = "_show",
    79                 params = {
    80                   member = timeline.member,
    81                   image_type = "avatar",
    82                   show_dummy = true
    83                 }
    84               }
    85               ui.link{
    86                 content = timeline.member.name,
    87                 module = "member",
    88                 view = "show",
    89                 id = timeline.member.id
    90               }
    91             end
    92             if timeline.issue then
    93               local initiatives_selector = timeline.issue
    94                 :get_reference_selector("initiatives")
    95               execute.view{
    96                 module = "initiative",
    97                 view = "_list",
    98                 params = {
    99                   issue = timeline.issue,
   100                   initiatives_selector = initiatives_selector,
   101                   per_page = initiatives_per_page,
   102                   no_sort = true,
   103                   limit = initiatives_per_page
   104                 }
   105               }
   106             elseif initiative then
   107               execute.view{
   108                 module = "initiative",
   109                 view = "_list",
   110                 params = {
   111                   issue = initiative.issue,
   112                   initiatives_selector = Initiative:new_selector():add_where{ "initiative.id = ?", initiative.id },
   113                   per_page = initiatives_per_page,
   114                   no_sort = true
   115                 }
   116               }
   117             end
   118             if timeline.suggestion then
   119               ui.link{
   120                 module = "suggestion",
   121                 view = "show",
   122                 id = timeline.suggestion.id,
   123                 content = timeline.suggestion.name
   124               }
   125             end
   126           end
   127         },
   128       }
   129     }
   130   end
   131 }
