liquid_feedback_frontend
diff 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
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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/vote/list.lua Fri Dec 25 12:00:00 2009 +0100 1.3 @@ -0,0 +1,138 @@ 1.4 +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." 1.5 + 1.6 +ui.script{ static = "js/browser_warning.js" } 1.7 +ui.script{ script = "checkBrowser(" .. encode.json(_"Your web browser is not fully supported yet." .. " " .. warning_text:gsub("\n", "\n\n")) .. ");" } 1.8 + 1.9 +ui.tag{ 1.10 + tag = "noscript", 1.11 + content = function() 1.12 + slot.put(_"JavaScript is disabled or not available." .. " " .. encode.html_newlines(warning_text)) 1.13 + end 1.14 +} 1.15 + 1.16 + 1.17 +local issue = Issue:by_id(param.get("issue_id"), atom.integer) 1.18 + 1.19 +local initiatives = issue.initiatives 1.20 + 1.21 +local min_grade = -1; 1.22 +local max_grade = 1; 1.23 + 1.24 +for i, initiative in ipairs(initiatives) do 1.25 + -- TODO performance 1.26 + initiative.vote = Vote:by_pk(initiative.id, app.session.member.id) 1.27 + if initiative.vote then 1.28 + if initiative.vote.grade > max_grade then 1.29 + max_grade = initiative.vote.grade 1.30 + end 1.31 + if initiative.vote.grade < min_grade then 1.32 + min_grade = initiative.vote.grade 1.33 + end 1.34 + end 1.35 +end 1.36 + 1.37 +local sections = {} 1.38 +for i = min_grade, max_grade do 1.39 + sections[i] = {} 1.40 + for j, initiative in ipairs(initiatives) do 1.41 + if (initiative.vote and initiative.vote.grade == i) or (not initiative.vote and i == 0) then 1.42 + sections[i][#(sections[i])+1] = initiative 1.43 + end 1.44 + end 1.45 +end 1.46 + 1.47 +slot.put_into("title", _"Voting") 1.48 + 1.49 +slot.select("actions", function() 1.50 + ui.link{ 1.51 + content = function() 1.52 + ui.image{ static = "icons/16/cancel.png" } 1.53 + slot.put(_"Cancel") 1.54 + end, 1.55 + module = "issue", 1.56 + view = "show", 1.57 + id = issue.id 1.58 + } 1.59 +end) 1.60 + 1.61 +util.help("vote.list", _"Voting") 1.62 + 1.63 + 1.64 +slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/dragdrop.js"></script>') 1.65 +slot.put('<script src="' .. request.get_relative_baseurl() .. 'static/js/voting.js"></script>') 1.66 + 1.67 +ui.form{ 1.68 + attr = { id = "voting_form" }, 1.69 + module = "vote", 1.70 + action = "update", 1.71 + params = { issue_id = issue.id }, 1.72 + routing = { 1.73 + default = { 1.74 + mode = "redirect", 1.75 + module = "issue", 1.76 + view = "show", 1.77 + id = issue.id 1.78 + } 1.79 + }, 1.80 + content = function() 1.81 + slot.put('<input type="hidden" name="scoring" value=""/>') 1.82 + -- TODO abstrahieren 1.83 + ui.tag{ 1.84 + tag = "input", 1.85 + attr = { 1.86 + type = "button", 1.87 + class = "voting_done", 1.88 + value = _"Finish voting" 1.89 + } 1.90 + } 1.91 + ui.container{ 1.92 + attr = { id = "voting" }, 1.93 + content = function() 1.94 + for grade = max_grade, min_grade, -1 do 1.95 + local section = sections[grade] 1.96 + local class 1.97 + if grade > 0 then 1.98 + class = "approval" 1.99 + elseif grade < 0 then 1.100 + class = "disapproval" 1.101 + else 1.102 + class = "abstention" 1.103 + end 1.104 + ui.container{ 1.105 + attr = { class = class }, 1.106 + content = function() 1.107 + slot.put('<div class="cathead"></div>') 1.108 + for i, initiative in ipairs(section) do 1.109 + ui.container{ 1.110 + attr = { 1.111 + class = "movable", 1.112 + id = "entry_" .. tostring(initiative.id) 1.113 + }, 1.114 + content = function() 1.115 + ui.link{ 1.116 + attr = { class = "clickable" }, 1.117 + content = initiative.name, 1.118 + module = "initiative", 1.119 + view = "show", 1.120 + id = initiative.id 1.121 + } 1.122 + end 1.123 + } 1.124 + end 1.125 + end 1.126 + } 1.127 + end 1.128 + end 1.129 + } 1.130 + ui.tag{ 1.131 + tag = "input", 1.132 + attr = { 1.133 + type = "button", 1.134 + class = "voting_done", 1.135 + value = _"Finish voting" 1.136 + } 1.137 + } 1.138 + end 1.139 +} 1.140 + 1.141 +