liquid_feedback_frontend

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

Impressum / About Us