liquid_feedback_frontend

view app/main/delegation/_show_box.lua @ 2:5c601807d397

Version alpha3

Dark green part of issue supporter bargraph represents all satisfied supporters, regardless of having seen the latest draft

Wiki formatting for drafts

Showing differences between two drafts of the same initiative

Display of outgoing delegation chains

Many other improvements
author bsw
date Mon Nov 23 12:00:00 2009 +0100 (2009-11-23)
parents 3bfb2fcf7ab9
children 80c215dbf076
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()
53 ui.container{
54 attr = {
55 class = "close",
56 style = "cursor: pointer;",
57 onclick = "document.getElementById('delegation_content').style.display = 'none';"
58 },
59 content = _"X"
60 }
62 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 }
64 for i, record in ipairs(delegation_chain) do
65 local style
66 execute.view{
67 module = "member",
68 view = "_show_thumb",
69 params = { member = record }
70 }
71 slot.put("<br style='clear: left'/>")
72 if record.scope_out then
73 ui.container{
74 attr = { class = "delegation_info" },
75 content = function()
76 ui.image{
77 attr = { class = "delegation_arrow" },
78 static = "delegation_arrow_vertical.jpg"
79 }
80 ui.container{
81 attr = { class = "delegation_scope" },
82 content = function()
83 if record.scope_out == "global" then
84 slot.put(_"Global delegation")
85 elseif record.scope_out == "area" then
86 slot.put(_"Area delegation")
87 elseif record.scope_out == "issue" then
88 slot.put(_"Issue delegation")
89 end
90 end
91 }
92 if record.id == app.session.member.id then
93 ui.link{
94 attr = { class = "revoke" },
95 content = function()
96 ui.image{ static = "icons/16/delete.png" }
97 slot.put(_"Revoke")
98 end,
99 module = "delegation",
100 action = "update",
101 params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true },
102 routing = {
103 default = {
104 mode = "redirect",
105 module = request.get_module(),
106 view = request.get_view(),
107 id = param.get_id_cgi(),
108 params = param.get_all_cgi()
109 }
110 }
111 }
112 end
113 end
114 }
115 end
116 end
117 end
118 }
119 end
121 end)

Impressum / About Us