-
Notifications
You must be signed in to change notification settings - Fork 16
/
forms.yml
410 lines (337 loc) · 16.4 KB
/
forms.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
default:
context:
lang: 'en'
visitor: 'ant'
node: 'status'
src: "simple text"
tem: "simple text"
res: "simple text"
add_btn:
src: "<table do='pages' in='site' limit='1'>
<tr do='each'><td do='title'/></tr>
<tr do='add'><td><b><r:add_btn/></b></td></tr>
</table>"
res: "/<tr class='btn_add' id='list1_add'><td><b><a href='javascript:void\(0\)' onclick/"
form_put:
# default should be a put method
src: "<r:form></r:form>"
tem: "/form_for.*:url.*node_path\(@node\.zip\)/"
res: '/<form action="/nodes/\d+".*method="post".*input name="_method" type="hidden" value="put"/'
form_should_not_insert_parent_id:
context:
node: 'zena'
src: "<r:form></r:form>"
tem: "!/parent_id/"
form_post:
# Should make a post on new objects
src: "<r:new klass='Post' title='\"Joe\"'><r:form></r:form></r:new>"
tem: "/if var1 = new_instance\(\"Post\", :title => \"Joe\"\)/"
res: "!/\"put\"/"
new:
# Should accept allowed params (from class and roles) and transform ids to zip (back and forth)
src: "<r:new klass='Letter' title='%q{Joe}' parent_id='project.id' paper='%q{white}' origin='%q{Mars}' bad='%q{value}'><r:form><r:input name='title'/> <r:input name='parent_id'/></r:form></r:new>"
tem: "/:title => \"Joe\", :parent_id => .*@node.project.zip.*, :paper => \"white\", :origin => \"Mars\"/"
res: "/node\[paper\]' value='white'/"
translate_id_to_zip:
src: "<b do='hot_id'/><i do='parent_id'/>"
tem: "<b><%= @node.rel[\"hot\"].try(:other_zip) %></b><i><%= @node.parent_zip %></i>"
select_class_existing_node:
context:
node: 'letter'
src: "<r:form><r:select name='klass' root_class='Note'/></r:form>"
res: "/<select name=.node\[klass\]. id=.list1_klass.><option value=\"Note\">Note<\/option>\n<option value=\"Letter\" selected=\"selected\"> Letter<\/option>\n<option value=\"Post\"> Post<\/option><\/select>/"
select_class_new_node:
src: "<r:pages><r:each/><r:add/><r:form><r:select name='klass' root_class='Note' selected='Post'/></r:form>"
res: "/<select.*name=.node\[klass\].*Note.*Letter.*Post. selected=.selected./"
select_class_kpath:
src: "<r:select param='k' root_class='Note' attr='kpath'/>"
res: "/<select.*name=.k.*NN.*Note.*NNL.*Letter.*NNP.*Post/"
select_class_tprefix:
context:
lang: fr
src: "<r:load dictionary='/Default skin/translations'><r:select tprefix='foo' param='k' root_class='Note'/></r:load>"
tem: '/\["the Foo Note", "Note"\]/'
res: "/the Foo Note.*Letter/"
select_data:
src: "<r:select data-d='foo' param='k' root_class='Note' attr='kpath'/>"
res: "/<select name=.k. data-d='foo'.*NN.*Note.*NNL.*Letter.*NNP.*Post/"
select_nodes:
src: "<r:form><r:select nodes='images in site' name='origin'></select></r:form>"
res: "/name='node\[origin\]'[^>]+><option value=\"\" selected=\"selected\"></option>\n<option value=\"40\">Autumn Tree</option>\n<option value=\"30\">bird</option>/"
select_nodes_show_rubyless:
src: "<r:form><r:select nodes='images in site' name='origin' show='title.limit(3)'></select></r:form>"
res: "/name='node\[origin\]'[^>]+><option value=\"\" selected=\"selected\"></option>\n<option value=\"40\">Aut…</option>\n<option value=\"30\">bir…</option>/"
do_not_set_parent_id_if_form_contains_parent_id:
src: "<r:children><r:each do='title'/><r:add/><r:form><r:select name='parent_id' nodes='projects in site'/><input name='title'/></r:form></r:children>"
res: "!/node\[parent_id\].\s+value/"
select_nodes_selected:
src: "<r:form><r:select name='parent_id' nodes='projects in site'/></r:form>"
res: "/option\s* value=.21.\s* selected=.selected.>Clean Water/"
select_nodes_in_ajax:
src: "<r:pages><r:each do='title'/><r:add/><r:form><r:select nodes='images in site' name='origin'/></r:form></r:pages>"
res: "/name=.node\[origin\].[^>]+><option value=\"\" selected=\"selected\"></option>\n<option value=\"40\">Autumn Tree</option>\n<option value=\"30\">bird</option>/"
select_nodes_show_attr:
src: "<r:form><r:select name='title' nodes='images in site' attr='ext' show='title'/></r:form>"
res: "/name=.node\[title\].[^>]+>.*<option value=\"jpg\">flower</option>\n<option value=\"jpg\">it's a lake</option>/"
select_time_zone:
src: "<r:form><r:select type='time_zone' name='settings[tz]'/></r:form>"
res: "/Asia/Jakarta.*Europe/Zurich.*US/Hawai"
select_values_tshow:
# Refactor select to use collection_select.
src: "<r:select name='origin' values='1,2,3' tshow='en,fr,de'/>"
res: "/option value=.1.>english.*option value=.2.>french/"
select_prop:
# Refactor select to use collection_select.
src: "<r:select name='origin' values='1,2,3' tshow='en,fr,de'/>"
tem: "/@node.prop\['origin'\].to_s/"
select_l_status:
# Refactor select to use collection_select.
src: "<r:select name='l_status' values='1.0, 2.0, 3.0' tshow='en,fr,de'/>"
tem: "/@node.l_status.to_s/"
form_publish:
src: "<r:form publish='true'><r:select name='origin' values='bar,baz'/></r:form>"
res: "/div.*name=.node\[v_status\]. value=.50.\/>.*<\/div>/"
checkbox:
context:
node: 'opening'
src: "<r:checkbox role='calendar' nodes='11'/>"
res: "/hidden.*node\[calendar_ids\]\[\]' value=''.*input type='checkbox' name='node\[calendar_ids\]\[\]' value='11' checked='checked'.*Zena/"
checkbox_literal_auto_trans:
context:
node: 'people'
lang: 'fr'
src: "<r:load dictionary='/Default skin/translations'><r:checkbox name='assigned' values='1,2'/></r:load>"
tem: "/foo/"
res: "/value='1'/> <span>foo</span>/"
radio_literal_auto_trans:
context:
node: 'people'
lang: fr
src: "<r:load dictionary='/Default skin/translations'><r:radio name='assigned' values='1,2'/></r:load>"
res: "/value='1'/> <span>foo</span>/"
checkbox_literal:
context:
node: 'people'
src: "<r:checkbox name='assigned' values='gaspard,sophie'/>"
res: "/value='gaspard' checked='checked'/> <span>gaspard</span>/"
checkbox_literal_show:
context:
node: 'people'
src: "<r:checkbox name='assigned' values='gaspard,sophie' show='slave,master'/>"
res: "/value='gaspard' checked='checked'/> <span>slave</span>/"
checkbox_literal_tshow:
context:
node: 'people'
src: "<r:checkbox name='assigned' values='gaspard,sophie' tshow='fr,en'/>"
res: "/value='gaspard' checked='checked'/> <span>french</span>/"
checkbox_finder:
context:
node: 'opening'
src: "<r:checkbox role='calendar' nodes='projects in site'/>"
res: "/input type=.checkbox. name=.node\[calendar_ids\]\[\]. value=.29. checked=.checked.*wiki.*value=.21.*Clean Water/"
checkbox_checked_value:
src: "<r:input type='checkbox' name='tagged[sky]'/>"
tem: "/@node.tagged\[\"sky\"\].blank\?/"
res: "<input type='hidden' name='node[tagged][sky]' value=''/><input type='checkbox' name='node[tagged][sky]' value='sky' checked='checked'/>"
checkbox_checked_hash_value:
context:
node: test
src: "<r:input type='checkbox' name='settings[one]' value='un'/> <r:input type='checkbox' name='settings[one]' value='deux'/>"
tem: "/@node.prop\[.settings.\]\[.one.\] : nil\) == .un. \? . checked='checked'/"
res: "<input type='hidden' name='node[settings][one]' value=''/><input type='checkbox' name='node[settings][one]' value='un' checked='checked'/> <input type='hidden' name='node[settings][one]' value=''/><input type='checkbox' name='node[settings][one]' value='deux'/>"
checkbox_unchecked_value:
src: "<r:input type='checkbox' name='tagged[foo]'/>"
tem: "/@node.tagged\[\"foo\"\].blank\?/"
res: "<input type='hidden' name='node[tagged][foo]' value=''/><input type='checkbox' name='node[tagged][foo]' value='foo'/>"
checkbox_unchecked_value_blank:
src: "<r:input type='checkbox' name='tagged[foo]' blank='baz'/>"
res: "<input type='hidden' name='node[tagged][foo]' value='baz'/><input type='checkbox' name='node[tagged][foo]' value='foo'/>"
checkbox_value_blank:
src: "<r:input type='checkbox' name='weight' value='100' blank='50'/>"
res: "<input type='hidden' name='node[weight]' value='50'/><input type='checkbox' name='node[weight]' value='100'/>"
input_set_value:
src: "<r:input type='hidden' name='icon_id' value='#{main.id}'/>"
tem: "/@node.zip/"
res: "<input type='hidden' name='node[icon_id]' value='22'/>"
input:
context:
node: 'ant'
src: "<r:Contact?><r:input name='first_name'/></r:Contact?>"
tem: "<% if @node.kpath_match?('NRC') %><input type='text' name='node[first_name]' value='<%= fquote(@node.prop['first_name']) %>'/><% end %>"
res: "<input type='text' name='node[first_name]' value='Solenopsis'/>"
input_raw_name:
src: "<r:input param='first_name'/>"
tem: "<input type='text' name='first_name' value='<%= fquote(params[:first_name]) %>'/>"
input_param_value:
context:
foo:
"bar.baz": 'xyz'
src: "<r:input param='foo[bar.baz]'/>"
tem: "<input type='text' name='foo[bar.baz]' value='<%= fquote(param_value(\"foo[bar.baz]\")) %>'/>"
res: "<input type='text' name='foo[bar.baz]' value='xyz'/>"
input_checkbox_param_value:
context:
foo:
"bar.baz": 'null'
src: "<r:input type='checkbox' value='null' param='foo[bar.baz]'/>"
tem: "<input type='hidden' name='foo[bar.baz]' value=''/><input type='checkbox' name='foo[bar.baz]' value='null'<%= param_value(\"foo[bar.baz]\") == \"null\" ? \" checked='checked'\" : '' %>/>"
res: "<input type='hidden' name='foo[bar.baz]' value=''/><input type='checkbox' name='foo[bar.baz]' value='null' checked='checked'/>"
select_param_value:
context:
foo:
"bar.baz": '1'
src: "<r:select param='foo[bar.baz]' values='1,3' show='one,three'/>"
tem: '/param_value\("foo\[bar.baz\]"\).to_s/'
res: '/<option value="1" selected="selected">one<\/option>/'
input_style:
src: "<r:input style='display:none;' type='submit'/>"
res: "<input type='submit' style='display:none;'/>"
textarea:
context:
node: 'ant'
src: "<r:Contact? do='textarea' name='first_name'/>"
res: "<textarea name='node[first_name]'>Solenopsis</textarea>"
textarea_with_blocks:
context:
node: 'ant'
src: "<r:Contact? do='textarea' name='first_name'>Sir <r:show attr='first_name'/></r:Contact?>"
tem: "/<textarea name='node\[first_name\]'>Sir <%=h @node.prop\['first_name'\] %></textarea>/"
res: "<textarea name='node[first_name]'>Sir Solenopsis</textarea>"
input_new:
context:
node: 'ant'
src: "<r:contacts><r:each/><r:form><r:input name='first_name'/></r:form><r:add/></r:contacts>"
res: "/name='node\[first_name\]' [^>]*id='list1_first_name'/"
show_in_form:
src: "<r:form><b do='title'/></r:form>"
tem: "/<b><%=h @node.prop\['title'\] %></b>/"
res: '/<b>status title</b>/'
not_set_parent_id:
src: "<r:form></r:form>"
tem: "!/node\[parent_id\]/"
set_parent_id_in_new:
src: "<r:new klass='Page' do='form'></r:new>"
tem: "/node\[parent_id\].*@node.zip/"
res: "/<input type='hidden' name='node\[parent_id\]' value='22'/>/"
label_on_input:
context:
lang: fr
src: "<r:input label='t' name='title'/>"
res: "<label>titre</label> <span><input type='text' name='node[title]' value='Etat des travaux'/></span>"
label_on_input_param:
context:
lang: fr
src: "<r:input label='t' param='title'/>"
res: "<label>titre</label> <span><input type='text' name='title' value=''/></span>"
label_on_hash:
src: "<r:input name='settings[foo]' label='t'/>"
tem: "/@node.prop\[.settings.\]\[.foo.\]/"
res: "<label>settings_foo</label> <span><input type='text' name='node[settings][foo]' value=''/></span>"
label_on_textarea:
context:
lang: fr
src: "<r:textarea label='t' name='title'/>"
res: "<label>titre</label> <span><textarea name='node[title]'>Etat des travaux</textarea></span>"
label_on_checkbox:
context:
lang: fr
src: "<r:checkbox label='t' name='title' values='1,2'/>"
res: "/<label>titre</label>.*input type='checkbox'"
default_checkbox:
src: "<r:checkbox name='title' values='1' default='0'/>"
res: "/<input type='hidden' name='node\[title\]' value='0'/>/"
label_on_select:
context:
lang: fr
src: "<r:select label='t' name='title' values='1,2'/>"
res: "/<label>titre</label> <span><select name='node\[title\]'/"
passiv_form:
# Should not transform 'form' or 'input' into 'r:form' or 'r:input'
src: "<form>xxx<input name='x' id='y' type='text'/> yyy<input name='x' id='y' type='text' value='#{id}'/></form>"
tem: "<form>xxx<input name='x' id='y' type='text'/> yyy<input name='x' id='y' type='text' value='<%= @node.zip %>'/></form>"
passiv_input_in_form:
# Should not transform 'form' or 'input' into 'r:form' or 'r:input'
src: "<r:form>xxx<input name='x' id='y' type='text'/> yyy<input name='x' id='y' type='text' value='#{id}'/></r:form>"
tem: "/yyy<input name='x' id='y' type='text' value='<%= @node.zip %>'/>/"
param_on_select:
src: "<r:select param='q[contact.status]' values='0,-5,-10' tshow='active, being registered, inactive'/>"
res: "<select name='q[contact.status]'><option value=\"0\">active</option>\n<option value=\"-5\">being registered</option>\n<option value=\"-10\">inactive</option></select>"
select_eval_value:
context:
f: "a,b,c,en"
q: 'en'
src: "<r:select param='q' eval='params[:f]'/>"
tem: "<select name='q'><%= options_for_select((params[:f] || '').split(',').map(&:strip).map {|e| [trans(e), e]}, param_value(\"q\").to_s) %></select>"
res: "<select name='q'><option value=\"a\">a</option>\n<option value=\"b\">b</option>\n<option value=\"c\">c</option>\n<option value=\"en\" selected=\"selected\">english</option></select>"
select_for_hash:
context:
node: test
src: "<r:select label='t' name='settings[one]' values='foo,un'/>"
tem: "<label>settings_one</label> <span><select name='node[settings][one]'><%= options_for_select([[\"settings_one_foo\", \"foo\"], [\"settings_one_un\", \"un\"]], (@node.prop['settings'] ? @node.prop['settings'][\"one\"] : nil).to_s) %></select></span>"
res: "/<label>settings_one</label> .*option value=\"un\" selected=\"selected\"/"
select_for_hash_tprefix:
context:
node: test
src: "<r:select tprefix='rel' name='settings[one]' values='foo,un'/>"
tem: "<select name='node[settings][one]'><%= options_for_select([[\"rel_foo\", \"foo\"], [\"rel_un\", \"un\"]], (@node.prop['settings'] ? @node.prop['settings'][\"one\"] : nil).to_s) %></select>"
res: "<select name='node[settings][one]'><option value=\"foo\">rel_foo</option>\n<option value=\"un\" selected=\"selected\">rel_un</option></select>"
crop:
context:
node: 'bird_jpg'
src: "<r:Image? do='crop'/>"
res: "/node\[crop\]\[h\]/"
js: '/Zena.Div_editor\("imglist1"/'
hidden_fields_in_form_tag:
src: "<r:form foo='%{bar}'></r:form>"
tem: "/<input type='hidden' name='foo' value='bar'/>/"
hidden_fields_in_form_tag_dynamic:
src: "<r:form node[log]='title'></r:form>"
tem: "/<input type='hidden' name='node\[log\]' value='<%= @node.prop\['title'\] %>/"
should_show_column:
src: "<r:Document do='column(\"size\")' do='name'/>"
res: "size"
should_show_fields_for_columns:
context:
node: 'forest_pdf'
src: "<r:form><r:Document do='column(\"size\")' do='input'/></r:form>"
tem: "/input type='text' name='node\\[<%= var2.name %>\\]/"
res: "/<input type='text' name='node\\[size\\]' value='63569'/>/"
should_show_fields_for_columns:
context:
lang: 'fr'
src: "<r:load dictionary='/Default skin/translations'><r:form><r:select name='assigned' values=',1,2,3'/></r:form></r:load>"
tem: "/foo.*bar/"
res: "/value=\"1\">foo<\/option>\n<option value=\"2\">bar/"
form_rel_status:
context:
node: 'cleanWater'
src: "<r:input name='set_tag_status'/>"
tem: "/other_status/"
res: "<input type='text' name='node[set_tag_status]' value='10.0'/>"
# Before change, tiger uses ant as profile
auth_profile:
context:
node: tiger
src: "<b do='auth[\"profile\"]'/>: <r:select name='auth[profile]' type='profile'/>"
res: "<b>ant</b>: <select name='node[auth][profile]'><option value=\"ant\" selected=\"selected\">ant</option></select>"
auth_login:
context:
node: ant
src: "<r:input name='auth[login]'/>"
res: "<input type='text' name='node[auth][login]' value='ant'/>"
auth_password:
context:
node: ant
src: "<r:input type='password' name='auth[password]'/>"
res: "<input type='password' name='node[auth][password]' value=''/>"
tlabel_with_default_label:
context:
lang: fr
src: "<r:default label='t'><r:input name='title' tlabel='Monday'/></r:default>"
res: '/<label>lundi</label>/'
p_do_input:
src: "<p class='foo' do='input' name='title'/>"
res: "<p class='foo'><input type='text' name='node[title]' value='status title'/></p>"
p_do_input_with_label:
src: "<p class='foo' do='input' name='title' label='t'/>"
res: "<p class='foo'><label>title</label> <span><input type='text' name='node[title]' value='status title'/></span></p>"