Commit f14ca7a65222c3e2788f861a8b0c9b2d78e6e057

Authored by Cédric RICARD
1 parent 4b41c49d

Updating the 'old' generic_form to the new typed declarations.

calexium_lib/web/CXM_generic_form.anubis
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 17
18 18
19 read CXM_making_a_web_site.anubis 19 read CXM_making_a_web_site.anubis
  20 +read tools/basis.anubis
20 21
21 22
22 public type Mandatory: // used to mark fields as mandatory. 23 public type Mandatory: // used to mark fields as mandatory.
@@ -50,25 +51,25 @@ public type FormField: @@ -50,25 +51,25 @@ public type FormField:
50 message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), 51 message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)),
51 52
52 //--- text input field ---------------------------------------------------------------- 53 //--- text input field ----------------------------------------------------------------
53 - input (String web_arg_name, 54 + input (WebArgName web_arg_name,
54 String tag, 55 String tag,
55 Width width, 56 Width width,
56 - String init_value, 57 + InitialValue init_value,
57 Mandatory mandatory), 58 Mandatory mandatory),
58 - input (String web_arg_name, 59 + input (WebArgName web_arg_name,
59 Width width, 60 Width width,
60 - String init_value),  
61 - input_f (String web_arg_name, 61 + InitialValue init_value),
  62 + input_f (WebArgName web_arg_name,
62 List(Text_Option) -> HTML_In_Form tag, 63 List(Text_Option) -> HTML_In_Form tag,
63 Width width, 64 Width width,
64 - String init_value, 65 + InitialValue init_value,
65 Mandatory mandatory), 66 Mandatory mandatory),
66 67
67 //--- password input field ------------------------------------------------------------ 68 //--- password input field ------------------------------------------------------------
68 - password_input (String web_arg_name, 69 + password_input (WebArgName web_arg_name,
69 String tag, 70 String tag,
70 Mandatory mandatory), 71 Mandatory mandatory),
71 - password_input_f (String web_arg_name, 72 + password_input_f (WebArgName web_arg_name,
72 List(Text_Option) -> HTML_In_Form tag, 73 List(Text_Option) -> HTML_In_Form tag,
73 Mandatory mandatory), 74 Mandatory mandatory),
74 75
@@ -79,61 +80,61 @@ public type FormField: @@ -79,61 +80,61 @@ public type FormField:
79 explain_f (List(Text_Option) -> HTML_In_Form), 80 explain_f (List(Text_Option) -> HTML_In_Form),
80 81
81 //--- selector field ------------------------------------------------------------------ 82 //--- selector field ------------------------------------------------------------------
82 - selector (String web_arg_name, 83 + selector (WebArgName web_arg_name,
83 String tag, 84 String tag,
84 List(String) items, 85 List(String) items,
85 - Maybe(String) selected, 86 + Maybe(InitialValue) selected,
86 Mandatory mandatory), 87 Mandatory mandatory),
87 - selector_f (String web_arg_name, 88 + selector_f (WebArgName web_arg_name,
88 List(Text_Option) -> HTML_In_Form, 89 List(Text_Option) -> HTML_In_Form,
89 List(String) items, 90 List(String) items,
90 - Maybe(String) selected, 91 + Maybe(InitialValue) selected,
91 Mandatory mandatory), 92 Mandatory mandatory),
92 - selector_c (String web_arg_name, 93 + selector_c (WebArgName web_arg_name,
93 String tag, 94 String tag,
94 - List((String,String)) items,  
95 - Maybe(String) selected, 95 + List((WebArgValue,String)) items,
  96 + Maybe(InitialValue) selected,
96 Mandatory mandatory), 97 Mandatory mandatory),
97 98
98 99
99 100
100 //--- checkbox field ------------------------------------------------------------------ 101 //--- checkbox field ------------------------------------------------------------------
101 - checkbox (String web_arg_name, 102 + checkbox (WebArgName web_arg_name,
102 String tag, 103 String tag,
103 Bool checked, 104 Bool checked,
104 Mandatory mandatory), 105 Mandatory mandatory),
105 // the same one, but with the tag on the right of the checkbox 106 // the same one, but with the tag on the right of the checkbox
106 - checkboxr (String web_arg_name, 107 + checkboxr (WebArgName web_arg_name,
107 String tag, 108 String tag,
108 Bool checked, 109 Bool checked,
109 Mandatory mandatory), 110 Mandatory mandatory),
110 - checkbox_f (String web_arg_name, 111 + checkbox_f (WebArgName web_arg_name,
111 List(Text_Option) -> HTML_In_Form, 112 List(Text_Option) -> HTML_In_Form,
112 Bool checked, 113 Bool checked,
113 Mandatory mandatory), 114 Mandatory mandatory),
114 115
115 //--- radio-button field -------------------------------------------------------------- 116 //--- radio-button field --------------------------------------------------------------
116 - radio_button (String web_arg_name,  
117 - String web_arg_value, 117 + radio_button (WebArgName web_arg_name,
  118 + WebArgValue web_arg_value,
118 String tag, 119 String tag,
119 Bool checked, 120 Bool checked,
120 Mandatory mandatory), 121 Mandatory mandatory),
121 // the same one, but with the tag on the right of the radio_button 122 // the same one, but with the tag on the right of the radio_button
122 - radio_buttonr (String web_arg_name,  
123 - String web_arg_value, 123 + radio_buttonr (WebArgName web_arg_name,
  124 + WebArgValue web_arg_value,
124 String tag, 125 String tag,
125 Bool checked, 126 Bool checked,
126 Mandatory mandatory), 127 Mandatory mandatory),
127 128
128 //--- text area field ----------------------------------------------------------------- 129 //--- text area field -----------------------------------------------------------------
129 - text_area (String web_arg_name,  
130 - String initial_text),  
131 - text_area (String web_arg_name, 130 + text_area (WebArgName web_arg_name,
  131 + InitialValue initial_text),
  132 + text_area (WebArgName web_arg_name,
132 String tag, 133 String tag,
133 - String initial_text),  
134 - text_area (String web_arg_name, 134 + InitialValue initial_text),
  135 + text_area (WebArgName web_arg_name,
135 String tag, 136 String tag,
136 - String initial_text, 137 + InitialValue initial_text,
137 Int32 width, 138 Int32 width,
138 Int32 height), 139 Int32 height),
139 140
@@ -161,24 +162,24 @@ public type FormField: @@ -161,24 +162,24 @@ public type FormField:
161 public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). 162 public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f).
162 public define FormField 163 public define FormField
163 message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f). 164 message(Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form) f) = message_f(f).
164 -public define FormField input(String web_arg_name, 165 +public define FormField input(WebArgName web_arg_name,
165 List(Text_Option) -> HTML_In_Form tag, 166 List(Text_Option) -> HTML_In_Form tag,
166 Width width, 167 Width width,
167 - String init_value, 168 + InitialValue init_value,
168 Mandatory mandatory) 169 Mandatory mandatory)
169 = input_f(web_arg_name,tag,width,init_value,mandatory). 170 = input_f(web_arg_name,tag,width,init_value,mandatory).
170 -public define FormField password_input(String web_arg_name, 171 +public define FormField password_input(WebArgName web_arg_name,
171 List(Text_Option) -> HTML_In_Form tag, 172 List(Text_Option) -> HTML_In_Form tag,
172 Mandatory mandatory) 173 Mandatory mandatory)
173 = password_input_f(web_arg_name,tag,mandatory). 174 = password_input_f(web_arg_name,tag,mandatory).
174 public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f). 175 public define FormField explain(List(Text_Option) -> HTML_In_Form f) = explain_f(f).
175 -public define FormField selector(String web_arg_name, 176 +public define FormField selector(WebArgName web_arg_name,
176 List(Text_Option) -> HTML_In_Form f, 177 List(Text_Option) -> HTML_In_Form f,
177 List(String) items, 178 List(String) items,
178 - Maybe(String) selected, 179 + Maybe(InitialValue) selected,
179 Mandatory mandatory) 180 Mandatory mandatory)
180 = selector_f(web_arg_name,f,items,selected,mandatory). 181 = selector_f(web_arg_name,f,items,selected,mandatory).
181 -public define FormField checkbox(String web_arg_name, 182 +public define FormField checkbox(WebArgName web_arg_name,
182 List(Text_Option) -> HTML_In_Form f, 183 List(Text_Option) -> HTML_In_Form f,
183 Bool checked, 184 Bool checked,
184 Mandatory mandatory) 185 Mandatory mandatory)
@@ -200,7 +201,7 @@ public define HTML_Off_Form @@ -200,7 +201,7 @@ public define HTML_Off_Form
200 --- That's all for the public part ! -------------------------------------------------- 201 --- That's all for the public part ! --------------------------------------------------
201 202
202 // TO DO update code of CXM generic form 203 // TO DO update code of CXM generic form
203 - define HTML_Row(HTML_In_Form) 204 +define HTML_Row(HTML_In_Form)
204 format_form_field 205 format_form_field
205 ( 206 (
206 FormField ff 207 FormField ff
@@ -249,7 +250,7 @@ public define HTML_Off_Form @@ -249,7 +250,7 @@ public define HTML_Off_Form
249 [ 250 [
250 cell([right ], text([size(10)],tag)), 251 cell([right ], text([size(10)],tag)),
251 cell([width(7) ], star(mand)), 252 cell([width(7) ], star(mand)),
252 - cell([left ], text_input("","",wan,init,if w is 253 + cell([left ], text_input([], "",htmlId(""),wan,init,if w is
253 { 254 {
254 small then 10, 255 small then 10,
255 narrow then 30, 256 narrow then 30,
@@ -260,7 +261,7 @@ public define HTML_Off_Form @@ -260,7 +261,7 @@ public define HTML_Off_Form
260 261
261 input(wan,w,init) then (List(HTML_Cell(HTML_In_Form))) 262 input(wan,w,init) then (List(HTML_Cell(HTML_In_Form)))
262 [ 263 [
263 - cell([left,columns(3) ], text_input("","",wan,init,if w is 264 + cell([left,columns(3) ], text_input([], "", htmlId(""), wan,init,if w is
264 { 265 {
265 small then 10, 266 small then 10,
266 narrow then 30, 267 narrow then 30,
@@ -273,7 +274,7 @@ public define HTML_Off_Form @@ -273,7 +274,7 @@ public define HTML_Off_Form
273 [ 274 [
274 cell([right ], tag([size(10)])), 275 cell([right ], tag([size(10)])),
275 cell([width(7) ], star(mand)), 276 cell([width(7) ], star(mand)),
276 - cell([left ], text_input("","",wan,init,if w is 277 + cell([left ], text_input([], "", htmlId(""),wan,init,if w is
277 { 278 {
278 small then 15, 279 small then 15,
279 narrow then 30, 280 narrow then 30,
@@ -286,14 +287,14 @@ public define HTML_Off_Form @@ -286,14 +287,14 @@ public define HTML_Off_Form
286 [ 287 [
287 cell([right ], text([size(10)],tag)), 288 cell([right ], text([size(10)],tag)),
288 cell([width(7) ], star(mand)), 289 cell([width(7) ], star(mand)),
289 - cell([left ], password_input("","",wan,30)) 290 + cell([left ], password_input([], "",htmlId(""), wan, init(""), 30))
290 ], 291 ],
291 292
292 password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) 293 password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form)))
293 [ 294 [
294 cell([right ], tag([size(10)])), 295 cell([right ], tag([size(10)])),
295 cell([width(7) ], star(mand)), 296 cell([width(7) ], star(mand)),
296 - cell([left ], password_input("","",wan,30)) 297 + cell([left ], password_input([], "",htmlId(""), wan, init(""), 30))
297 ], 298 ],
298 299
299 explain(t) then (List(HTML_Cell(HTML_In_Form))) 300 explain(t) then (List(HTML_Cell(HTML_In_Form)))
@@ -328,8 +329,8 @@ public define HTML_Off_Form @@ -328,8 +329,8 @@ public define HTML_Off_Form
328 cell([width(7)], star(mand)), 329 cell([width(7)], star(mand)),
329 cell([left ], if selected is 330 cell([left ], if selected is
330 { 331 {
331 - failure then selector(wan,1,items)  
332 - success(sel) then selector(wan,1,items,sel) 332 + failure then selector([], "", htmlId(""), wan,1,items)
  333 + success(sel) then selector([], "", htmlId(""), wan,1,items, sel)
333 }) 334 })
334 ], 335 ],
335 336
@@ -339,8 +340,8 @@ public define HTML_Off_Form @@ -339,8 +340,8 @@ public define HTML_Off_Form
339 cell([width(7)], star(mand)), 340 cell([width(7)], star(mand)),
340 cell([left ], if selected is 341 cell([left ], if selected is
341 { 342 {
342 - failure then selector(wan,1,items)  
343 - success(sel) then selector(wan,1,items,sel) 343 + failure then selector([], "", htmlId(""), wan,1,items)
  344 + success(sel) then selector([], "", htmlId(""), wan,1,items, sel)
344 }) 345 })
345 ], 346 ],
346 347
@@ -350,8 +351,8 @@ public define HTML_Off_Form @@ -350,8 +351,8 @@ public define HTML_Off_Form
350 cell([width(7)], star(mand)), 351 cell([width(7)], star(mand)),
351 cell([left ], if selected is 352 cell([left ], if selected is
352 { 353 {
353 - failure then selector_c(wan,1,items)  
354 - success(sel) then selector_c(wan,1,items,sel) 354 + failure then selector_c([], "", htmlId(""), wan,1,items)
  355 + success(sel) then selector_c([], "", htmlId(""), wan,1,items,sel)
355 }) 356 })
356 ], 357 ],
357 358
@@ -359,12 +360,12 @@ public define HTML_Off_Form @@ -359,12 +360,12 @@ public define HTML_Off_Form
359 [ 360 [
360 cell([right ], text([size(10)],tag)), 361 cell([right ], text([size(10)],tag)),
361 cell([width(7)], star(mand)), 362 cell([width(7)], star(mand)),
362 - cell([left ], check_box("","",wan,checked)) 363 + cell([left ], check_box([], "",htmlId(""),wan, wav(wan.name),checked))
363 ], 364 ],
364 365
365 checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) 366 checkboxr(wan,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form)))
366 [ 367 [
367 - cell([right ], check_box("","",wan,checked)), 368 + cell([right ], check_box([], "",htmlId(""),wan, wav(wan.name),checked)),
368 cell([width(7)], star(mand)), 369 cell([width(7)], star(mand)),
369 cell([left ], text([size(10)],tag)) 370 cell([left ], text([size(10)],tag))
370 ], 371 ],
@@ -373,19 +374,19 @@ public define HTML_Off_Form @@ -373,19 +374,19 @@ public define HTML_Off_Form
373 [ 374 [
374 cell([right ], tag([size(10)])), 375 cell([right ], tag([size(10)])),
375 cell([width(7)], star(mand)), 376 cell([width(7)], star(mand)),
376 - cell([left ], check_box("","",wan,checked)) 377 + cell([left ], check_box([], "",htmlId(""),wan,wav(wan.name),checked))
377 ], 378 ],
378 379
379 radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) 380 radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form)))
380 [ 381 [
381 cell([right ], text([size(10)],tag)), 382 cell([right ], text([size(10)],tag)),
382 cell([width(7)], star(mand)), 383 cell([width(7)], star(mand)),
383 - cell([left ], radio_button("","",wan,wav,checked)) 384 + cell([left ], radio_button([], "", htmlId(""), wan, wav, checked))
384 ], 385 ],
385 386
386 radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) 387 radio_buttonr(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form)))
387 [ 388 [
388 - cell([right ], radio_button("","",wan,wav,checked)), 389 + cell([right ], radio_button([], "", htmlId(""), wan, wav, checked)),
389 cell([width(7)], star(mand)), 390 cell([width(7)], star(mand)),
390 cell([left ], text([size(10)],tag)) 391 cell([left ], text([size(10)],tag))
391 ], 392 ],
@@ -454,7 +455,7 @@ public define HTML_Off_Form @@ -454,7 +455,7 @@ public define HTML_Off_Form
454 455
455 456
456 // TO DO update code of CXM generic form 457 // TO DO update code of CXM generic form
457 - public define HTML_Off_Form 458 +public define HTML_Off_Form
458 generic_form 459 generic_form
459 ( 460 (
460 String form_name, 461 String form_name,
@@ -465,6 +466,6 @@ public define HTML_Off_Form @@ -465,6 +466,6 @@ public define HTML_Off_Form
465 table([border(0,0,5,bg_color),percentage_width(100), 466 table([border(0,0,5,bg_color),percentage_width(100),
466 background_color(bg_color)],[row(cell([h_center], 467 background_color(bg_color)],[row(cell([h_center],
467 form(form_name,[],table([border(0,2,0,bg_color)], 468 form(form_name,[],table([border(0,2,0,bg_color)],
468 - map(format_form_field,fields)))))]). 469 + map(format_form_field, fields)))))]).
469 470
470 471
calexium_lib/web/CXM_making_a_web_site.anubis
@@ -989,7 +989,7 @@ public type HTML_In_Form: @@ -989,7 +989,7 @@ public type HTML_In_Form:
989 text_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), 989 text_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
990 text_input_ro (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), 990 text_input_ro (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
991 password_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), 991 password_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width),
992 - text_area (List(TextAreaOption), String name, String init, Int32 width, Int32 height), 992 + text_area (List(TextAreaOption), WebArgName name, InitialValue init, Int32 width, Int32 height),
993 file_upload (String label, HtmlId id, WebArgName name, Int32 width), 993 file_upload (String label, HtmlId id, WebArgName name, Int32 width),
994 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices), 994 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices),
995 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices, InitialValue selected), 995 selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices, InitialValue selected),
@@ -1037,8 +1037,8 @@ public define HTML_In_Form @@ -1037,8 +1037,8 @@ public define HTML_In_Form
1037 public define HTML_In_Form 1037 public define HTML_In_Form
1038 text_area 1038 text_area
1039 ( 1039 (
1040 - String name,  
1041 - String init, 1040 + WebArgName name,
  1041 + InitialValue init,
1042 Int32 width, 1042 Int32 width,
1043 Int32 height 1043 Int32 height
1044 ) = 1044 ) =