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