liquid_feedback_frontend

view app/main/vote/list.lua @ 5:afd9f769c7ae

Version beta1

Final voting with Schulze-Method is now possible

Many bug fixes and code cleanup

Registration with invite codes

More sort and filter options

Seperated display of "supporters" and "potential supporters"

Optical changes

Flood limit / initiative contigent is now checked by frontend

Neccessary changes to access core beta11
author bsw/jbe
date Fri Dec 25 12:00:00 2009 +0100 (2009-12-25)
parents
children 8d91bccab0bf
line source
1 local warning_text = _"Some JavaScript based functions (voting in particular) will not work.\nFor this beta, please use a current version of Firefox, Safari, Opera(?), Konqueror or another (more) standard compliant browser.\nAlternative access without JavaScript will be available soon."
3 ui.script{ static = "js/browser_warning.js" }
4 ui.script{ script = "checkBrowser(" .. encode.json(_"Your web browser is not fully supported yet." .. " " .. warning_text:gsub("\n", "\n\n")) .. ");" }
6 ui.tag{
7 tag = "noscript",
8 content = function()
9 slot.put(_"JavaScript is disabled or not available." .. " " .. encode.html_newlines(warning_text))
10 end
11 }
14 local issue = Issue:by_id(param.get("issue_id"), atom.integer)
16 local initiatives = issue.initiatives
18 local min_grade = -1;
19 local max_grade = 1;
21 for i, initiative in ipairs(initiatives) do
22 -- TODO performance
23 initiative.vote = Vote:by_pk(initiative.id, app.session.member.id)
24 if initiative.vote then
25 if initiative.vote.grade > max_grade then
26 max_grade = initiative.vote.grade
27 end
28 if initiative.vote.grade < min_grade then
29 min_grade = initiative.vote.grade
30 end
31 end
32 end
34 local sections = {}
35 for i = min_grade, max_grade do
36 sections[i] = {}
37 for j, initiative in ipairs(initiatives) do
38 if (initiative.vote and initiative.vote.grade == i) or (not initiative.vote and i == 0) then
39 sections[i][#(sections[i])+1] = initiative
40 end
41 end
42 end
44 slot.put_into("title", _"Voting")
46 slot.select("actions", function()
47 ui.link{
48 content = function()
49 ui.image{ static = "icons/16/cancel.png" }
50 slot.put(_"Cancel")
51 end,
52 module = "issue",
53 view = "show",
54 id = issue.id
55 }
56 end)
58 util.help("vote.list", _"Voting")
61 slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/dragdrop.js"></script>')
62 slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/voting.js"></script>')
64 ui.form{
65 attr = { id = "voting_form" },
66 module = "vote",
67 action = "update",
68 params = { issue_id = issue.id },
69 routing = {
70 default = {
71 mode = "redirect",
72 module = "issue",
73 view = "show",
74 id = issue.id
75 }
76 },
77 content = function()
78 slot.put('<input type="hidden" name="scoring" value=""/>')
79 -- TODO abstrahieren
80 ui.tag{
81 tag = "input",
82 attr = {
83 type = "button",
84 class = "voting_done",
85 value = _"Finish voting"
86 }
87 }
88 ui.container{
89 attr = { id = "voting" },
90 content = function()
91 for grade = max_grade, min_grade, -1 do
92 local section = sections[grade]
93 local class
94 if grade > 0 then
95 class = "approval"
96 elseif grade < 0 then
97 class = "disapproval"
98 else
99 class = "abstention"
100 end
101 ui.container{
102 attr = { class = class },
103 content = function()
104 slot.put('<div class="cathead"></div>')
105 for i, initiative in ipairs(section) do
106 ui.container{
107 attr = {
108 class = "movable",
109 id = "entry_" .. tostring(initiative.id)
110 },
111 content = function()
112 ui.link{
113 attr = { class = "clickable" },
114 content = initiative.name,
115 module = "initiative",
116 view = "show",
117 id = initiative.id
118 }
119 end
120 }
121 end
122 end
123 }
124 end
125 end
126 }
127 ui.tag{
128 tag = "input",
129 attr = {
130 type = "button",
131 class = "voting_done",
132 value = _"Finish voting"
133 }
134 }
135 end
136 }

Impressum / About Us