liquid_feedback_frontend
annotate app/main/delegation/_show_box.lua @ 3:768faea1096d
Version alpha4
Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.
Initiatives may provide a link to an external discussion platform
Direct link on every initiative page to create an alternative initiative
Bugfix: No error when clicking "neutral", when "neutral" is currently selected
Members interested in an issue or supporting an initiative have a weight information attached. Browsing the members causing that weight is possible.
Initiatives may provide a link to an external discussion platform
Direct link on every initiative page to create an alternative initiative
Bugfix: No error when clicking "neutral", when "neutral" is currently selected
| author | bsw | 
|---|---|
| date | Mon Nov 30 12:00:00 2009 +0100 (2009-11-30) | 
| parents | 5c601807d397 | 
| children | 80c215dbf076 | 
| 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@2 | 53 ui.container{ | 
| bsw@2 | 54 attr = { | 
| bsw@2 | 55 class = "close", | 
| bsw@2 | 56 style = "cursor: pointer;", | 
| bsw@2 | 57 onclick = "document.getElementById('delegation_content').style.display = 'none';" | 
| bsw@2 | 58 }, | 
| bsw@2 | 59 content = _"X" | 
| bsw@2 | 60 } | 
| bsw/jbe@0 | 61 | 
| bsw/jbe@0 | 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 } | 
| bsw/jbe@0 | 63 | 
| bsw/jbe@0 | 64 for i, record in ipairs(delegation_chain) do | 
| bsw/jbe@0 | 65 local style | 
| bsw@2 | 66 execute.view{ | 
| bsw@2 | 67 module = "member", | 
| bsw@2 | 68 view = "_show_thumb", | 
| bsw@2 | 69 params = { member = record } | 
| bsw@2 | 70 } | 
| bsw@2 | 71 slot.put("<br style='clear: left'/>") | 
| bsw@2 | 72 if record.scope_out then | 
| bsw@2 | 73 ui.container{ | 
| bsw@2 | 74 attr = { class = "delegation_info" }, | 
| bsw@2 | 75 content = function() | 
| bsw@2 | 76 ui.image{ | 
| bsw@2 | 77 attr = { class = "delegation_arrow" }, | 
| bsw@2 | 78 static = "delegation_arrow_vertical.jpg" | 
| bsw@2 | 79 } | 
| bsw@2 | 80 ui.container{ | 
| bsw@2 | 81 attr = { class = "delegation_scope" }, | 
| bsw@2 | 82 content = function() | 
| bsw@2 | 83 if record.scope_out == "global" then | 
| bsw@2 | 84 slot.put(_"Global delegation") | 
| bsw@2 | 85 elseif record.scope_out == "area" then | 
| bsw@2 | 86 slot.put(_"Area delegation") | 
| bsw@2 | 87 elseif record.scope_out == "issue" then | 
| bsw@2 | 88 slot.put(_"Issue delegation") | 
| bsw@2 | 89 end | 
| bsw@2 | 90 end | 
| bsw@2 | 91 } | 
| bsw@2 | 92 if record.id == app.session.member.id then | 
| bsw@2 | 93 ui.link{ | 
| bsw@2 | 94 attr = { class = "revoke" }, | 
| bsw@2 | 95 content = function() | 
| bsw@2 | 96 ui.image{ static = "icons/16/delete.png" } | 
| bsw@2 | 97 slot.put(_"Revoke") | 
| bsw@2 | 98 end, | 
| bsw@2 | 99 module = "delegation", | 
| bsw@2 | 100 action = "update", | 
| bsw@2 | 101 params = { issue_id = delegation.issue_id, area_id = delegation.area_id, delete = true }, | 
| bsw@2 | 102 routing = { | 
| bsw@2 | 103 default = { | 
| bsw@2 | 104 mode = "redirect", | 
| bsw@2 | 105 module = request.get_module(), | 
| bsw@2 | 106 view = request.get_view(), | 
| bsw@2 | 107 id = param.get_id_cgi(), | 
| bsw@2 | 108 params = param.get_all_cgi() | 
| bsw@2 | 109 } | 
| bsw@2 | 110 } | 
| bsw@2 | 111 } | 
| bsw@2 | 112 end | 
| bsw@2 | 113 end | 
| bsw/jbe@0 | 114 } | 
| bsw/jbe@0 | 115 end | 
| bsw/jbe@0 | 116 end | 
| bsw/jbe@0 | 117 end | 
| bsw/jbe@0 | 118 } | 
| bsw/jbe@0 | 119 end | 
| bsw/jbe@0 | 120 | 
| bsw/jbe@0 | 121 end) |