liquid_feedback_frontend

annotate app/main/delegation/_show_box.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 5c601807d397
rev   line source
bsw/jbe@0 1 slot.select("delegation", function()
bsw/jbe@0 2
bsw/jbe@0 3 local delegation
bsw/jbe@0 4 local area_id
bsw/jbe@0 5 local issue_id
bsw/jbe@0 6
bsw/jbe@0 7 local scope = "global"
bsw/jbe@0 8
bsw/jbe@0 9 if param.get("initiative_id", atom.integer) then
bsw/jbe@0 10 issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id
bsw/jbe@0 11 scope = "issue"
bsw/jbe@0 12 end
bsw/jbe@0 13
bsw/jbe@0 14 if param.get("issue_id", atom.integer) then
bsw/jbe@0 15 issue_id = param.get("issue_id", atom.integer)
bsw/jbe@0 16 scope = "issue"
bsw/jbe@0 17 end
bsw/jbe@0 18
bsw/jbe@0 19 if param.get("area_id", atom.integer) then
bsw/jbe@0 20 area_id = param.get("area_id", atom.integer)
bsw/jbe@0 21 scope = "area"
bsw/jbe@0 22 end
bsw/jbe@0 23
bsw/jbe@0 24
bsw/jbe@0 25
bsw/jbe@0 26 local delegation
bsw/jbe@0 27
bsw/jbe@0 28 if issue_id then
bsw/jbe@0 29 delegation = Delegation:by_pk(app.session.member.id, nil, issue_id)
bsw/jbe@0 30 if not delegation then
bsw/jbe@0 31 local issue = Issue:by_id(issue_id)
bsw/jbe@0 32 delegation = Delegation:by_pk(app.session.member.id, issue.area_id)
bsw/jbe@0 33 end
bsw/jbe@0 34 elseif area_id then
bsw/jbe@0 35 delegation = Delegation:by_pk(app.session.member.id, area_id)
bsw/jbe@0 36 end
bsw/jbe@0 37
bsw/jbe@0 38 if not delegation then
bsw/jbe@0 39 delegation = Delegation:by_pk(app.session.member.id)
bsw/jbe@0 40 end
bsw/jbe@0 41 if delegation then
bsw/jbe@0 42 ui.container{
bsw/jbe@0 43 attr = {
bsw/jbe@0 44 class = "head",
bsw/jbe@0 45 style = "cursor: pointer;",
bsw/jbe@0 46 onclick = "document.getElementById('delegation_content').style.display = 'block';"
bsw/jbe@0 47 },
bsw/jbe@0 48 content = _"Your vote is delegated. [more]"
bsw/jbe@0 49 }
bsw/jbe@0 50 ui.container{
bsw/jbe@0 51 attr = { class = "content", id = "delegation_content" },
bsw/jbe@0 52 content = function()
bsw/jbe@0 53
bsw/jbe@0 54 local delegation_chain = db:query{ "SELECT * FROM delegation_chain(?, ?, ?) JOIN member ON member.id = member_id ORDER BY index", app.session.member.id, area_id, issue_id }
bsw/jbe@0 55
bsw/jbe@0 56 for i, record in ipairs(delegation_chain) do
bsw/jbe@0 57 local style
bsw/jbe@0 58 if record.participation then
bsw/jbe@0 59 style = "font-weight: bold;"
bsw/jbe@0 60 end
bsw/jbe@0 61 if record.overridden then
bsw/jbe@0 62 style = "color: #777;"
bsw/jbe@0 63 end
bsw/jbe@0 64 if not record.active then
bsw/jbe@0 65 style = "text-decoration: line-through;"
bsw/jbe@0 66 end
bsw/jbe@0 67 if record.scope_in then
bsw/jbe@0 68 ui.field.text{
bsw/jbe@0 69 value = " v " .. record.scope_in .. " v "
bsw/jbe@0 70 }
bsw/jbe@0 71 end
bsw/jbe@0 72 local name = record.name
bsw/jbe@0 73 if record.member_id == app.session.member.id then
bsw/jbe@0 74 name = _"Me"
bsw/jbe@0 75 end
bsw/jbe@0 76 ui.field.text{
bsw/jbe@0 77 attr = { style = style },
bsw/jbe@0 78 value = name
bsw/jbe@0 79 }
bsw/jbe@0 80 end
bsw/jbe@0 81
bsw/jbe@0 82 ui.link{
bsw/jbe@0 83 attr = { class = "revoke" },
bsw/jbe@0 84 content = function()
bsw/jbe@0 85 ui.image{ static = "icons/16/delete.png" }
bsw/jbe@0 86 slot.put(_"Revoke")
bsw/jbe@0 87 end,
bsw/jbe@0 88 module = "delegation",
bsw/jbe@0 89 action = "update",
bsw/jbe@0 90 params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
bsw/jbe@0 91 routing = {
bsw/jbe@0 92 default = {
bsw/jbe@0 93 mode = "redirect",
bsw/jbe@0 94 module = request.get_module(),
bsw/jbe@0 95 view = request.get_view(),
bsw/jbe@0 96 id = param.get_id_cgi(),
bsw/jbe@0 97 params = param.get_all_cgi()
bsw/jbe@0 98 }
bsw/jbe@0 99 }
bsw/jbe@0 100 }
bsw/jbe@0 101
bsw/jbe@0 102 ui.container{
bsw/jbe@0 103 attr = {
bsw/jbe@0 104 class = "head",
bsw/jbe@0 105 style = "cursor: pointer;",
bsw/jbe@0 106 onclick = "document.getElementById('delegation_content').style.display = 'none';"
bsw/jbe@0 107 },
bsw/jbe@0 108 content = _"Click here to close."
bsw/jbe@0 109 }
bsw/jbe@0 110 end
bsw/jbe@0 111 }
bsw/jbe@0 112 end
bsw/jbe@0 113
bsw/jbe@0 114 end)

Impressum / About Us