liquid_feedback_frontend

view app/main/delegation/new.lua @ 180:02aacb3dffe0

Added support for null delegation in upcoming core release
author bsw
date Sun Oct 31 23:38:43 2010 +0100 (2010-10-31)
parents bf885faf3452
children 02197b85ca3b
line source
1 local area = Area:by_id(param.get("area_id", atom.integer))
2 if area then
3 slot.put_into("title", encode.html(_"Set delegation for Area '#{name}'":gsub("#{name}", area.name)))
4 util.help("delegation.new.area")
5 end
7 local issue = Issue:by_id(param.get("issue_id", atom.integer))
8 if issue then
9 slot.put_into("title", encode.html(_"Set delegation for Issue ##{number} in Area '#{area_name}'":gsub("#{number}", issue.id):gsub("#{area_name}", issue.area.name)))
10 util.help("delegation.new.issue")
11 end
13 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
15 if not area and not issue then
16 slot.put_into("title", encode.html(_"Set global delegation"))
17 util.help("delegation.new.global")
18 end
20 slot.select("actions", function()
21 if issue then
22 ui.link{
23 module = "issue",
24 view = "show",
25 id = issue.id,
26 content = function()
27 ui.image{ static = "icons/16/cancel.png" }
28 slot.put(_"Cancel")
29 end,
30 }
31 elseif area then
32 ui.link{
33 module = "area",
34 view = "show",
35 id = area.id,
36 content = function()
37 ui.image{ static = "icons/16/cancel.png" }
38 slot.put(_"Cancel")
39 end,
40 }
41 else
42 ui.link{
43 module = "index",
44 view = "index",
45 content = function()
46 ui.image{ static = "icons/16/cancel.png" }
47 slot.put(_"Cancel")
48 end,
49 }
50 end
51 end)
55 local contact_members = Member:new_selector()
56 :add_where{ "contact.member_id = ?", app.session.member.id }
57 :join("contact", nil, "member.id = contact.other_member_id")
58 :add_order_by("member.name")
59 :exec()
62 ui.form{
63 attr = { class = "vertical" },
64 module = "delegation",
65 action = "update",
66 params = {
67 area_id = area and area.id or nil,
68 issue_id = issue and issue.id or nil,
69 },
70 routing = {
71 default = {
72 mode = "redirect",
73 module = area and "area" or issue and "issue" or "index",
74 view = (area or issue) and "show" or "index",
75 id = area and area.id or issue and issue.id or nil,
76 }
77 },
78 content = function()
79 local records
81 if issue then
82 records = {
83 {
84 id = -1,
85 name = _"Inherit delegation from area"
86 },
87 {
88 id = 0,
89 name = _"No delegation (override area delegation)"
90 },
92 }
93 elseif area then
94 records = {
95 {
96 id = -1,
97 name = _"Inherit global delegation"
98 },
99 {
100 id = 0,
101 name = _"No delegation (override global delegation)"
102 }
103 }
105 else
106 records = {
107 {
108 id = -1,
109 name = _"No delegation"
110 }
111 }
113 end
115 for i, record in ipairs(contact_members) do
116 records[#records+1] = record
117 end
118 disabled_records = {}
119 -- add initiative authors
120 if initiative then
121 records[#records+1] = {id="_", name=_"--- Initiators ---"}
122 disabled_records["_"] = true
123 for i,record in ipairs(initiative.initiators) do
124 trace.debug(record)
125 trace.debug(record.member.name)
126 records[#records+1] = record.member
127 end
128 end
130 ui.field.select{
131 label = _"Trustee",
132 name = "trustee_id",
133 foreign_records = records,
134 foreign_id = "id",
135 foreign_name = "name",
136 disabled_records = disabled_records
137 }
139 ui.submit{ text = _"Save" }
140 end
141 }

Impressum / About Us