liquid_feedback_frontend
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/app/main/delegation/_show_box.lua Wed Nov 18 12:00:00 2009 +0100 1.3 @@ -0,0 +1,114 @@ 1.4 +slot.select("delegation", function() 1.5 + 1.6 + local delegation 1.7 + local area_id 1.8 + local issue_id 1.9 + 1.10 + local scope = "global" 1.11 + 1.12 + if param.get("initiative_id", atom.integer) then 1.13 + issue_id = Initiative:by_id(param.get("initiative_id", atom.integer)).issue_id 1.14 + scope = "issue" 1.15 + end 1.16 + 1.17 + if param.get("issue_id", atom.integer) then 1.18 + issue_id = param.get("issue_id", atom.integer) 1.19 + scope = "issue" 1.20 + end 1.21 + 1.22 + if param.get("area_id", atom.integer) then 1.23 + area_id = param.get("area_id", atom.integer) 1.24 + scope = "area" 1.25 + end 1.26 + 1.27 + 1.28 + 1.29 + local delegation 1.30 + 1.31 + if issue_id then 1.32 + delegation = Delegation:by_pk(app.session.member.id, nil, issue_id) 1.33 + if not delegation then 1.34 + local issue = Issue:by_id(issue_id) 1.35 + delegation = Delegation:by_pk(app.session.member.id, issue.area_id) 1.36 + end 1.37 + elseif area_id then 1.38 + delegation = Delegation:by_pk(app.session.member.id, area_id) 1.39 + end 1.40 + 1.41 + if not delegation then 1.42 + delegation = Delegation:by_pk(app.session.member.id) 1.43 + end 1.44 + if delegation then 1.45 + ui.container{ 1.46 + attr = { 1.47 + class = "head", 1.48 + style = "cursor: pointer;", 1.49 + onclick = "document.getElementById('delegation_content').style.display = 'block';" 1.50 + }, 1.51 + content = _"Your vote is delegated. [more]" 1.52 + } 1.53 + ui.container{ 1.54 + attr = { class = "content", id = "delegation_content" }, 1.55 + content = function() 1.56 + 1.57 + 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 } 1.58 + 1.59 + for i, record in ipairs(delegation_chain) do 1.60 + local style 1.61 + if record.participation then 1.62 + style = "font-weight: bold;" 1.63 + end 1.64 + if record.overridden then 1.65 + style = "color: #777;" 1.66 + end 1.67 + if not record.active then 1.68 + style = "text-decoration: line-through;" 1.69 + end 1.70 + if record.scope_in then 1.71 + ui.field.text{ 1.72 + value = " v " .. record.scope_in .. " v " 1.73 + } 1.74 + end 1.75 + local name = record.name 1.76 + if record.member_id == app.session.member.id then 1.77 + name = _"Me" 1.78 + end 1.79 + ui.field.text{ 1.80 + attr = { style = style }, 1.81 + value = name 1.82 + } 1.83 + end 1.84 + 1.85 + ui.link{ 1.86 + attr = { class = "revoke" }, 1.87 + content = function() 1.88 + ui.image{ static = "icons/16/delete.png" } 1.89 + slot.put(_"Revoke") 1.90 + end, 1.91 + module = "delegation", 1.92 + action = "update", 1.93 + params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true }, 1.94 + routing = { 1.95 + default = { 1.96 + mode = "redirect", 1.97 + module = request.get_module(), 1.98 + view = request.get_view(), 1.99 + id = param.get_id_cgi(), 1.100 + params = param.get_all_cgi() 1.101 + } 1.102 + } 1.103 + } 1.104 + 1.105 + ui.container{ 1.106 + attr = { 1.107 + class = "head", 1.108 + style = "cursor: pointer;", 1.109 + onclick = "document.getElementById('delegation_content').style.display = 'none';" 1.110 + }, 1.111 + content = _"Click here to close." 1.112 + } 1.113 + end 1.114 + } 1.115 + end 1.116 + 1.117 +end)