liquid_feedback_frontend
view 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
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 source
1 local initiative = param.get("initiative", "table")
4 local battled_initiatives = Initiative:new_selector()
5 :add_field("winning_battle.count", "winning_count")
6 :add_field("losing_battle.count", "losing_count")
7 :join("battle", "winning_battle", { "winning_battle.winning_initiative_id = ? AND winning_battle.losing_initiative_id = initiative.id", initiative.id })
8 :join("battle", "losing_battle", { "losing_battle.losing_initiative_id = ? AND losing_battle.winning_initiative_id = initiative.id", initiative.id })
9 :add_order_by("rank")
10 :exec()
12 local number_of_initiatives = Initiative:new_selector()
13 :add_where{ "issue_id = ?", initiative.issue_id }
14 :add_where("admitted")
15 :count()
17 if initiative.revoked then
18 slot.put(_"Not voted (revoked from initiator)")
19 elseif initiative.admitted == false then
20 slot.put(_"Not voted (not admitted)")
21 else
22 if number_of_initiatives > 1 then
23 ui.container{
24 attr = { class = "heading first" },
25 content = _"This initiative compared to alternative initiatives"
26 }
28 ui.list{
29 records = battled_initiatives,
30 columns = {
31 {
32 content = function()
33 slot.put(_"This initiative")
34 end
35 },
36 {
37 content = function(record)
38 local population = initiative.issue.voter_count
39 local value = record.winning_count
40 ui.bargraph{
41 class = "bargraph bargraph50",
42 max_value = population,
43 width = 50,
44 bars = {
45 { color = "#aaa", value = population - value },
46 { color = "#444", value = value },
47 }
48 }
49 end
50 },
51 {
52 content = function(record)
53 slot.put(record.winning_count)
54 end
55 },
56 {
57 content = function(record)
58 if record.winning_count == record.losing_count then
59 ui.image{ static = "icons/16/bullet_blue.png" }
60 elseif record.winning_count > record.losing_count then
61 ui.image{ static = "icons/16/resultset_previous.png" }
62 else
63 ui.image{ static = "icons/16/resultset_next.png" }
64 end
65 end
66 },
67 {
68 field_attr = { style = "text-align: right;" },
69 content = function(record)
70 slot.put(record.losing_count)
71 end
72 },
73 {
74 content = function(record)
75 local population = initiative.issue.voter_count
76 local value = record.losing_count
77 ui.bargraph{
78 class = "bargraph bargraph50",
79 max_value = population,
80 width = 50,
81 bars = {
82 { color = "#444", value = value },
83 { color = "#aaa", value = population - value },
84 }
85 }
86 end
87 },
88 {
89 name = "name"
90 }
91 }
92 }
93 end
95 ui.container{
96 attr = { class = "heading" },
97 content = _"Member voting"
98 }
100 execute.view{
101 module = "member",
102 view = "_list",
103 params = {
104 initiative = initiative,
105 members_selector = initiative.issue:get_reference_selector("direct_voters")
106 :left_join("vote", nil, { "vote.initiative_id = ? AND vote.member_id = member.id", initiative.id })
107 :add_field("direct_voter.weight as voter_weight")
108 :add_field("coalesce(vote.grade, 0) as grade")
109 }
110 }
112 end