liquid_feedback_frontend

diff app/main/initiative/_list.lua @ 469:3e2e233330d9

Added some whitespace to updated initiatives list and removed filter from initiatives
author bsw
date Wed Mar 14 11:26:22 2012 +0100 (2012-03-14)
parents 7d6a3c411f99
children d697e8486185
line diff
     1.1 --- a/app/main/initiative/_list.lua	Wed Mar 14 11:20:14 2012 +0100
     1.2 +++ b/app/main/initiative/_list.lua	Wed Mar 14 11:26:22 2012 +0100
     1.3 @@ -23,10 +23,11 @@
     1.4      :add_field("_direct_supporter_snapshot.member_id NOTNULL", "is_supporter_via_delegation")
     1.5  end
     1.6  
     1.7 +initiatives_selector:add_order_by("id")
     1.8 +
     1.9  local initiatives_count = initiatives_selector:count()
    1.10  
    1.11  local limit = param.get("limit", atom.number)
    1.12 -local no_sort = param.get("no_sort", atom.boolean)
    1.13  
    1.14  local more_initiatives_count
    1.15  if limit then
    1.16 @@ -45,91 +46,36 @@
    1.17  
    1.18  ui.add_partial_param_names{ name }
    1.19  
    1.20 -local order_filter = {
    1.21 -  name = name,
    1.22 -  label = _"Order by"
    1.23 -}
    1.24 -
    1.25 -if issue and issue.ranks_available then
    1.26 -  order_filter[#order_filter+1] = {
    1.27 -    name = "rank",
    1.28 -    label = _"Rank",
    1.29 -    selector_modifier = function(selector) selector:add_order_by("initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id") end
    1.30 -  }
    1.31 -end
    1.32 -
    1.33 -order_filter[#order_filter+1] = {
    1.34 -  name = "potential_support",
    1.35 -  label = _"Potential support",
    1.36 -  selector_modifier = function(selector) selector:add_order_by("CASE WHEN issue.population = 0 THEN 0 ELSE initiative.supporter_count::float / issue.population::float END DESC, initiative.id") end
    1.37 -}
    1.38 -
    1.39 -order_filter[#order_filter+1] = {
    1.40 -  name = "support",
    1.41 -  label = _"Support",
    1.42 -  selector_modifier = function(selector) selector:add_order_by("initiative.satisfied_supporter_count::float / issue.population::float DESC, initiative.id") end
    1.43 -}
    1.44 -
    1.45 -order_filter[#order_filter+1] = {
    1.46 -  name = "newest",
    1.47 -  label = _"Newest",
    1.48 -  selector_modifier = function(selector) selector:add_order_by("initiative.created DESC, initiative.id") end
    1.49 -}
    1.50 -
    1.51 -order_filter[#order_filter+1] = {
    1.52 -  name = "oldest",
    1.53 -  label = _"Oldest",
    1.54 -  selector_modifier = function(selector) selector:add_order_by("initiative.created, initiative.id") end
    1.55 -}
    1.56 -
    1.57 -ui_filters = ui.filters
    1.58 -
    1.59 -if no_sort then
    1.60 -  ui_filters = function(args) args.content() end
    1.61 -  if issue.ranks_available then
    1.62 -    initiatives_selector:add_order_by("initiative.rank, initiative.admitted DESC, vote_ratio(initiative.positive_votes, initiative.negative_votes) DESC, initiative.id")
    1.63 -  else
    1.64 -    initiatives_selector:add_order_by("CASE WHEN issue.population = 0 OR initiative.supporter_count = 0 OR initiative.supporter_count ISNULL THEN 0 ELSE initiative.supporter_count::float / issue.population::float END DESC, initiative.id")
    1.65 -  end
    1.66 -end
    1.67 -
    1.68 -ui_filters{
    1.69 -  label = _"Change order",
    1.70 -  order_filter,
    1.71 +ui.paginate{
    1.72 +  name = issue and "issue_" .. tostring(issue.id) .. "_page" or nil,
    1.73    selector = initiatives_selector,
    1.74 +  per_page = param.get("per_page", atom.number) or limit,
    1.75    content = function()
    1.76 -    ui.paginate{
    1.77 -      name = issue and "issue_" .. tostring(issue.id) .. "_page" or nil,
    1.78 -      selector = initiatives_selector,
    1.79 -      per_page = param.get("per_page", atom.number) or limit,
    1.80 -      content = function()
    1.81 -        local initiatives = initiatives_selector:exec()
    1.82 -        if highlight_initiative then
    1.83 -          local highlight_initiative_found
    1.84 -          for i, initiative in ipairs(initiatives) do
    1.85 -            if initiative.id == highlight_initiative.id then
    1.86 -              highhighlight_initiative_found = true
    1.87 -            end
    1.88 -          end
    1.89 -          if not highhighlight_initiative_found then
    1.90 -            initiatives[#initiatives+1] = highlight_initiative
    1.91 -            if more_initiatives_count then
    1.92 -              more_initiatives_count = more_initiatives_count - 1
    1.93 -            end
    1.94 -          end
    1.95 -        end
    1.96 -        for i, initiative in ipairs(initiatives) do
    1.97 -          execute.view{
    1.98 -            module = "initiative",
    1.99 -            view = "_list_element",
   1.100 -            params = {
   1.101 -              initiative = initiative,
   1.102 -              selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
   1.103 -            }
   1.104 -          }
   1.105 +    local initiatives = initiatives_selector:exec()
   1.106 +    if highlight_initiative then
   1.107 +      local highlight_initiative_found
   1.108 +      for i, initiative in ipairs(initiatives) do
   1.109 +        if initiative.id == highlight_initiative.id then
   1.110 +          highhighlight_initiative_found = true
   1.111          end
   1.112        end
   1.113 -    }
   1.114 +      if not highhighlight_initiative_found then
   1.115 +        initiatives[#initiatives+1] = highlight_initiative
   1.116 +        if more_initiatives_count then
   1.117 +          more_initiatives_count = more_initiatives_count - 1
   1.118 +        end
   1.119 +      end
   1.120 +    end
   1.121 +    for i, initiative in ipairs(initiatives) do
   1.122 +      execute.view{
   1.123 +        module = "initiative",
   1.124 +        view = "_list_element",
   1.125 +        params = {
   1.126 +          initiative = initiative,
   1.127 +          selected = highlight_initiative and highlight_initiative.id == initiative.id or nil,
   1.128 +        }
   1.129 +      }
   1.130 +    end
   1.131    end
   1.132  }
   1.133  

Impressum / About Us