liquid_feedback_frontend

view app/main/initiative/new.lua @ 898:ae9ab3edff89

Added polling support
author bsw
date Mon Aug 20 03:54:20 2012 +0200 (2012-08-20)
parents 54dc90658990
children f3d6d08b0125
line source
1 local issue
2 local area
4 local issue_id = param.get("issue_id", atom.integer)
5 if issue_id then
6 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
7 area = issue.area
9 else
10 local area_id = param.get("area_id", atom.integer)
11 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
12 end
14 if issue_id then
15 ui.title(_"Add alternative initiative to issue")
16 else
17 ui.title(_"Create new issue")
18 end
20 ui.form{
21 module = "initiative",
22 action = "create",
23 params = {
24 area_id = area.id,
25 issue_id = issue and issue.id or nil
26 },
27 attr = { class = "vertical" },
28 content = function()
29 ui.field.text{ label = _"Unit", value = area.unit.name }
30 ui.field.text{ label = _"Area", value = area.name }
31 slot.put("<br />")
32 if issue_id then
33 ui.field.text{ label = _"Issue", value = issue_id }
34 else
35 tmp = { { id = -1, name = _"Please choose a policy" } }
36 for i, allowed_policy in ipairs(area.allowed_policies) do
37 if not allowed_policy.polling or app.session.member:has_polling_right_for_unit_id(area.unit_id) then
38 tmp[#tmp+1] = allowed_policy
39 end
40 end
41 ui.field.select{
42 label = _"Policy",
43 name = "policy_id",
44 foreign_records = tmp,
45 foreign_id = "id",
46 foreign_name = "name",
47 value = param.get("policy_id", atom.integer) or area.default_policy and area.default_policy.id
48 }
49 ui.tag{
50 tag = "div",
51 content = function()
52 ui.tag{
53 tag = "label",
54 attr = { class = "ui_field_label" },
55 content = function() slot.put("&nbsp;") end,
56 }
57 ui.tag{
58 content = function()
59 ui.link{
60 text = _"Information about the available policies",
61 module = "policy",
62 view = "list"
63 }
64 slot.put(" ")
65 ui.link{
66 attr = { target = "_blank" },
67 text = _"(new window)",
68 module = "policy",
69 view = "list"
70 }
71 end
72 }
73 end
74 }
75 end
77 if issue and issue.policy.polling and app.session.member:has_polling_right_for_unit_id(area.unit_id) then
78 ui.field.boolean{ name = "polling", label = _"Poll" }
79 end
81 if param.get("preview") then
82 ui.heading{ level = 1, content = encode.html(param.get("name")) }
83 local discussion_url = param.get("discussion_url")
84 ui.container{
85 attr = { class = "ui_field_label" },
86 content = _"Discussion with initiators"
87 }
88 ui.tag{
89 tag = "span",
90 content = function()
91 if discussion_url:find("^https?://") then
92 if discussion_url and #discussion_url > 0 then
93 ui.link{
94 attr = {
95 class = "actions",
96 target = "_blank",
97 title = discussion_url
98 },
99 content = discussion_url,
100 external = discussion_url
101 }
102 end
103 else
104 slot.put(encode.html(discussion_url))
105 end
106 end
107 }
108 ui.container{
109 attr = { class = "draft_content wiki" },
110 content = function()
111 slot.put(format.wiki_text(param.get("draft"), param.get("formatting_engine")))
112 end
113 }
114 slot.put("<br />")
115 ui.submit{ text = _"Save" }
116 slot.put("<br />")
117 slot.put("<br />")
118 end
119 slot.put("<br />")
121 ui.field.text{
122 label = _"Title of initiative",
123 name = "name",
124 value = param.get("name")
125 }
126 ui.field.text{
127 label = _"Discussion URL",
128 name = "discussion_url",
129 value = param.get("discussion_url")
130 }
131 ui.field.select{
132 label = _"Wiki engine",
133 name = "formatting_engine",
134 foreign_records = {
135 { id = "rocketwiki", name = "RocketWiki" },
136 { id = "compat", name = _"Traditional wiki syntax" }
137 },
138 attr = {id = "formatting_engine"},
139 foreign_id = "id",
140 foreign_name = "name",
141 value = param.get("formatting_engine")
142 }
143 ui.tag{
144 tag = "div",
145 content = function()
146 ui.tag{
147 tag = "label",
148 attr = { class = "ui_field_label" },
149 content = function() slot.put("&nbsp;") end,
150 }
151 ui.tag{
152 content = function()
153 ui.link{
154 text = _"Syntax help",
155 module = "help",
156 view = "show",
157 id = "wikisyntax",
158 attr = {onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
159 }
160 slot.put(" ")
161 ui.link{
162 text = _"(new window)",
163 module = "help",
164 view = "show",
165 id = "wikisyntax",
166 attr = {target = "_blank", onClick="this.href=this.href.replace(/wikisyntax[^.]*/g, 'wikisyntax_'+getElementById('formatting_engine').value)"}
167 }
168 end
169 }
170 end
171 }
172 ui.field.text{
173 label = _"Draft",
174 name = "draft",
175 multiline = true,
176 attr = { style = "height: 50ex;" },
177 value = param.get("draft")
178 }
179 ui.submit{ name = "preview", text = _"Preview" }
180 ui.submit{ text = _"Save" }
181 end

Impressum / About Us