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