liquid_feedback_frontend
view app/main/suggestion/_list.lua @ 971:a8c6e80cdf5d
Fixed showing of wrong issue cancelled information
| author | bsw | 
|---|---|
| date | Sat Mar 09 19:13:55 2013 +0100 (2013-03-09) | 
| parents | 65c95cb65b4e | 
| children | e4ceb185092e | 
 line source
     2 local initiative = param.get("initiative", "table")
     3 local suggestions_selector = param.get("suggestions_selector", "table")
     5 suggestions_selector:add_order_by("plus2_unfulfilled_count + plus1_unfulfilled_count DESC, id")
     7 local ui_filters = ui.filters
     8 if true or not show_filter then
     9   ui_filters = function(args) args.content() end
    10 end
    13 ui.container{ attr = { class = "initiative_head" },
    14   content = function()
    15     ui.container{ attr = { class = "title" }, content = _"Suggestions" }
    16     ui.container{ attr = { class = "content" }, content = function()
    17       ui.paginate{
    18         selector = suggestions_selector,
    19         content = function()
    20           local suggestions = suggestions_selector:exec()
    21           if #suggestions < 1 then
    22             if not initiative.issue.fully_frozen and not initiative.issue.closed then
    23               ui.tag{ content = _"No suggestions yet" }
    24             else
    25               ui.tag{ content = _"No suggestions" }
    26             end
    27           else
    28             ui.list{
    29               attr = { style = "table-layout: fixed;" },
    30               records = suggestions,
    31               columns = {
    32                 {
    33                   label_attr = { style = "width: 101px;" },
    34                   content = function(record)
    35                     if record.minus2_unfulfilled_count then
    36                       local max_value = record.initiative.supporter_count
    37                       ui.bargraph{
    38                         max_value = max_value,
    39                         width = 100,
    40                         bars = {
    41                           { color = "#0a0", value = record.plus2_unfulfilled_count + record.plus2_fulfilled_count },
    42                           { color = "#8f8", value = record.plus1_unfulfilled_count + record.plus1_fulfilled_count },
    43                           { color = "#eee", value = max_value - record.minus2_unfulfilled_count - record.minus1_unfulfilled_count - record.minus2_fulfilled_count - record.minus1_fulfilled_count - record.plus1_unfulfilled_count - record.plus2_unfulfilled_count - record.plus1_fulfilled_count - record.plus2_fulfilled_count},
    44                           { color = "#f88", value = record.minus1_unfulfilled_count + record.minus1_fulfilled_count },
    45                           { color = "#a00", value = record.minus2_unfulfilled_count + record.minus2_fulfilled_count },
    46                         }
    47                       }
    48                     end
    49                   end
    50                 },
    51                 {
    52                   content = function(record)
    53                     ui.link{
    54                       text = record.name,
    55                       module = "suggestion",
    56                       view = "show",
    57                       id = record.id
    58                     }
    59                     local degree
    60                     local opinion
    61                     if app.session.member_id then
    62                       opinion = Opinion:by_pk(app.session.member.id, record.id)
    63                     end
    64                     if opinion then
    65                       local degrees = {
    66                         ["-2"] = _"must not",
    67                         ["-1"] = _"should not",
    68                         ["0"] = _"neutral",
    69                         ["1"] = _"should",
    70                         ["2"] = _"must"
    71                       }
    72                       slot.put(" · ")
    73                       ui.tag{ content = degrees[tostring(opinion.degree)] }
    74                       slot.put(" · ")
    75                       if opinion.fulfilled then
    76                         ui.tag{ content = _"implemented" }
    77                       else
    78                         ui.tag{ content = _"not implemented" }
    79                       end
    80                     end
    81                   end
    82                 },
    83               }
    84             }
    85           end
    86         end
    87       }
    88     end }
    89     if app.session.member_id
    90       and not initiative.issue.half_frozen
    91       and not initiative.issue.closed
    92       and not initiative.revoked
    93       and app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id)
    94     then
    95       ui.container{ attr = { class = "content" }, content = function()
    96         ui.link{
    97           module = "suggestion", view = "new", params = { initiative_id = initiative.id },
    98           text = _"New suggestion"
    99         }
   100       end }
   101     end
   102   end
   103 }
