bsw/jbe@5: 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: bsw/jbe@5: ui.script{ static = "js/browser_warning.js" } bsw/jbe@5: ui.script{ script = "checkBrowser(" .. encode.json(_"Your web browser is not fully supported yet." .. " " .. warning_text:gsub("\n", "\n\n")) .. ");" } bsw/jbe@5: bsw/jbe@5: ui.tag{ bsw/jbe@5: tag = "noscript", bsw/jbe@5: content = function() bsw/jbe@5: slot.put(_"JavaScript is disabled or not available." .. " " .. encode.html_newlines(warning_text)) bsw/jbe@5: end bsw/jbe@5: } bsw/jbe@5: bsw/jbe@5: bsw/jbe@5: local issue = Issue:by_id(param.get("issue_id"), atom.integer) bsw/jbe@5: bsw/jbe@5: local initiatives = issue.initiatives bsw/jbe@5: bsw/jbe@5: local min_grade = -1; bsw/jbe@5: local max_grade = 1; bsw/jbe@5: bsw/jbe@5: for i, initiative in ipairs(initiatives) do bsw/jbe@5: -- TODO performance bsw/jbe@5: initiative.vote = Vote:by_pk(initiative.id, app.session.member.id) bsw/jbe@5: if initiative.vote then bsw/jbe@5: if initiative.vote.grade > max_grade then bsw/jbe@5: max_grade = initiative.vote.grade bsw/jbe@5: end bsw/jbe@5: if initiative.vote.grade < min_grade then bsw/jbe@5: min_grade = initiative.vote.grade bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: bsw/jbe@5: local sections = {} bsw/jbe@5: for i = min_grade, max_grade do bsw/jbe@5: sections[i] = {} bsw/jbe@5: for j, initiative in ipairs(initiatives) do bsw/jbe@5: if (initiative.vote and initiative.vote.grade == i) or (not initiative.vote and i == 0) then bsw/jbe@5: sections[i][#(sections[i])+1] = initiative bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: bsw/jbe@5: slot.put_into("title", _"Voting") bsw/jbe@5: bsw/jbe@5: slot.select("actions", function() bsw/jbe@5: ui.link{ bsw/jbe@5: content = function() bsw/jbe@5: ui.image{ static = "icons/16/cancel.png" } bsw/jbe@5: slot.put(_"Cancel") bsw/jbe@5: end, bsw/jbe@5: module = "issue", bsw/jbe@5: view = "show", bsw/jbe@5: id = issue.id bsw/jbe@5: } bsw/jbe@5: end) bsw/jbe@5: bsw/jbe@5: util.help("vote.list", _"Voting") bsw/jbe@5: bsw/jbe@5: bsw/jbe@5: slot.put('') bsw/jbe@5: slot.put('') bsw/jbe@5: bsw/jbe@5: ui.form{ bsw/jbe@5: attr = { id = "voting_form" }, bsw/jbe@5: module = "vote", bsw/jbe@5: action = "update", bsw/jbe@5: params = { issue_id = issue.id }, bsw/jbe@5: routing = { bsw/jbe@5: default = { bsw/jbe@5: mode = "redirect", bsw/jbe@5: module = "issue", bsw/jbe@5: view = "show", bsw/jbe@5: id = issue.id bsw/jbe@5: } bsw/jbe@5: }, bsw/jbe@5: content = function() bsw/jbe@5: slot.put('') bsw/jbe@5: -- TODO abstrahieren bsw/jbe@5: ui.tag{ bsw/jbe@5: tag = "input", bsw/jbe@5: attr = { bsw/jbe@5: type = "button", bsw/jbe@5: class = "voting_done", bsw/jbe@5: value = _"Finish voting" bsw/jbe@5: } bsw/jbe@5: } bsw/jbe@5: ui.container{ bsw/jbe@5: attr = { id = "voting" }, bsw/jbe@5: content = function() bsw/jbe@5: for grade = max_grade, min_grade, -1 do bsw/jbe@5: local section = sections[grade] bsw/jbe@5: local class bsw/jbe@5: if grade > 0 then bsw/jbe@5: class = "approval" bsw/jbe@5: elseif grade < 0 then bsw/jbe@5: class = "disapproval" bsw/jbe@5: else bsw/jbe@5: class = "abstention" bsw/jbe@5: end bsw/jbe@5: ui.container{ bsw/jbe@5: attr = { class = class }, bsw/jbe@5: content = function() bsw/jbe@5: slot.put('
') bsw/jbe@5: for i, initiative in ipairs(section) do bsw/jbe@5: ui.container{ bsw/jbe@5: attr = { bsw/jbe@5: class = "movable", bsw/jbe@5: id = "entry_" .. tostring(initiative.id) bsw/jbe@5: }, bsw/jbe@5: content = function() bsw/jbe@5: ui.link{ bsw/jbe@5: attr = { class = "clickable" }, bsw/jbe@5: content = initiative.name, bsw/jbe@5: module = "initiative", bsw/jbe@5: view = "show", bsw/jbe@5: id = initiative.id bsw/jbe@5: } bsw/jbe@5: end bsw/jbe@5: } bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: } bsw/jbe@5: end bsw/jbe@5: end bsw/jbe@5: } bsw/jbe@5: ui.tag{ bsw/jbe@5: tag = "input", bsw/jbe@5: attr = { bsw/jbe@5: type = "button", bsw/jbe@5: class = "voting_done", bsw/jbe@5: value = _"Finish voting" bsw/jbe@5: } bsw/jbe@5: } bsw/jbe@5: end bsw/jbe@5: } bsw/jbe@5: bsw/jbe@5: