liquid_feedback_frontend

diff app/main/initiative/_show_voting.lua @ 19:00d1004545f1

Dynamic interface using XMLHttpRequests, and many other changes

Bugfixes:
- Only allow voting on admitted initiatives
- Repaired issue search
- Don't display delegations for closed issues on member page
- Don't show revoke link in initiative, when issue is already half_frozen
- Localization for voting JavaScript
- Display author of suggestions

Disclosure of voting data after voting is finished:
- Possibility to inspect every ballot including preferences
- Show number of voters preferring one initiative to another initiative

Interface behaviour changes:
- Reversed default order of drafts
- Default order of suggestions changed
- Show new drafts of initiatives only once per day in timeline

Accessibility:
- Barrier-free voting implemented
- POST links are now accessible without JavaScript
- Changed gray for unsatisfied supporters in bar graph to a lighter gray

Other interface improvements:
- Optical enhancements
- Dynamic interface using XMLHttpRequests
- Show usage terms in about section
- Show own membership in area listing
- Show uninformed supporters greyed out and marked with yellow question mark
- Warning box in non-admitted initiatives
- When voted, don't display voting notice and change label of voting link
- Show object counts in more tabulator heads
- Enlarged member statement input field

Miscellaneous:
- Code cleanup
- Added README file containing installation instructions
- Use new WebMCP function ui.filters{...} instead of own ui.filter and ui.order functions
author bsw/jbe
date Sat Feb 20 22:10:31 2010 +0100 (2010-02-20)
parents
children 81586ea68d57
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/initiative/_show_voting.lua	Sat Feb 20 22:10:31 2010 +0100
     1.3 @@ -0,0 +1,112 @@
     1.4 +local initiative = param.get("initiative", "table")
     1.5 +
     1.6 +
     1.7 +local battled_initiatives = Initiative:new_selector()
     1.8 +  :add_field("winning_battle.count", "winning_count")
     1.9 +  :add_field("losing_battle.count", "losing_count")
    1.10 +  :join("battle", "winning_battle", { "winning_battle.winning_initiative_id = ? AND winning_battle.losing_initiative_id = initiative.id", initiative.id })
    1.11 +  :join("battle", "losing_battle", { "losing_battle.losing_initiative_id = ? AND losing_battle.winning_initiative_id = initiative.id", initiative.id })
    1.12 +  :add_order_by("rank")
    1.13 +  :exec()
    1.14 +
    1.15 +local number_of_initiatives = Initiative:new_selector()
    1.16 +  :add_where{ "issue_id = ?", initiative.issue_id }
    1.17 +  :add_where("admitted")
    1.18 +  :count()
    1.19 +
    1.20 +if initiative.revoked then
    1.21 +  slot.put(_"Not voted (revoked from initiator)")
    1.22 +elseif initiative.admitted == false then
    1.23 +  slot.put(_"Not voted (not admitted)")
    1.24 +else
    1.25 +  if number_of_initiatives > 1 then
    1.26 +    ui.container{
    1.27 +      attr = { class = "heading first" },
    1.28 +      content = _"This initiative compared to alternative initiatives"
    1.29 +    }
    1.30 +
    1.31 +    ui.list{
    1.32 +      records = battled_initiatives,
    1.33 +      columns = {
    1.34 +        {
    1.35 +          content = function()
    1.36 +            slot.put(_"This initiative")
    1.37 +          end
    1.38 +        },
    1.39 +        {
    1.40 +          content = function(record)
    1.41 +            local population = initiative.issue.voter_count
    1.42 +            local value = record.winning_count
    1.43 +            ui.bargraph{
    1.44 +              class = "bargraph bargraph50",
    1.45 +              max_value = population,
    1.46 +              width = 50,
    1.47 +              bars = {
    1.48 +                { color = "#aaa", value = population - value },
    1.49 +                { color = "#444", value = value },
    1.50 +              }
    1.51 +            }
    1.52 +          end
    1.53 +        },
    1.54 +        {
    1.55 +          content = function(record)
    1.56 +            slot.put(record.winning_count)
    1.57 +          end
    1.58 +        },
    1.59 +        {
    1.60 +          content = function(record)
    1.61 +            if record.winning_count == record.losing_count then
    1.62 +              ui.image{ static = "icons/16/bullet_blue.png" }
    1.63 +            elseif record.winning_count > record.losing_count then
    1.64 +              ui.image{ static = "icons/16/resultset_previous.png" }
    1.65 +            else
    1.66 +              ui.image{ static = "icons/16/resultset_next.png" }
    1.67 +            end
    1.68 +          end
    1.69 +        },
    1.70 +        {
    1.71 +          field_attr = { style = "text-align: right;" },
    1.72 +          content = function(record)
    1.73 +            slot.put(record.losing_count)
    1.74 +          end
    1.75 +        },
    1.76 +        {
    1.77 +          content = function(record)
    1.78 +            local population = initiative.issue.voter_count
    1.79 +            local value = record.losing_count
    1.80 +            ui.bargraph{
    1.81 +              class = "bargraph bargraph50",
    1.82 +              max_value = population,
    1.83 +              width = 50,
    1.84 +              bars = {
    1.85 +                { color = "#444", value = value },
    1.86 +                { color = "#aaa", value = population - value },
    1.87 +              }
    1.88 +            }
    1.89 +          end
    1.90 +        },
    1.91 +        {
    1.92 +          name = "name"
    1.93 +        }
    1.94 +      }
    1.95 +    }
    1.96 +  end
    1.97 +
    1.98 +  ui.container{
    1.99 +    attr = { class = "heading" },
   1.100 +    content = _"Member voting"
   1.101 +  }
   1.102 +
   1.103 +  execute.view{
   1.104 +    module = "member",
   1.105 +    view = "_list",
   1.106 +    params = {
   1.107 +      initiative = initiative,
   1.108 +      members_selector =  initiative.issue:get_reference_selector("direct_voters")
   1.109 +        :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id })
   1.110 +        :add_field("direct_voter.weight as voter_weight")
   1.111 +        :add_field("coalesce(vote.grade, 0) as grade")
   1.112 +    }
   1.113 +  }
   1.114 +
   1.115 +end

Impressum / About Us