Commit f14ca7a65222c3e2788f861a8b0c9b2d78e6e057
1 parent
4b41c49d
Updating the 'old' generic_form to the new typed declarations.
Showing
2 changed files
with
57 additions
and
56 deletions
Show diff stats
calexium_lib/web/CXM_generic_form.anubis
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | read CXM_making_a_web_site.anubis |
| 20 | +read tools/basis.anubis | |
| 20 | 21 | |
| 21 | 22 | |
| 22 | 23 | public type Mandatory: // used to mark fields as mandatory. |
| ... | ... | @@ -50,25 +51,25 @@ public type FormField: |
| 50 | 51 | message_f (Result(List(Text_Option) -> HTML_In_Form,List(Text_Option) -> HTML_In_Form)), |
| 51 | 52 | |
| 52 | 53 | //--- text input field ---------------------------------------------------------------- |
| 53 | - input (String web_arg_name, | |
| 54 | + input (WebArgName web_arg_name, | |
| 54 | 55 | String tag, |
| 55 | 56 | Width width, |
| 56 | - String init_value, | |
| 57 | + InitialValue init_value, | |
| 57 | 58 | Mandatory mandatory), |
| 58 | - input (String web_arg_name, | |
| 59 | + input (WebArgName web_arg_name, | |
| 59 | 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 | 63 | List(Text_Option) -> HTML_In_Form tag, |
| 63 | 64 | Width width, |
| 64 | - String init_value, | |
| 65 | + InitialValue init_value, | |
| 65 | 66 | Mandatory mandatory), |
| 66 | 67 | |
| 67 | 68 | //--- password input field ------------------------------------------------------------ |
| 68 | - password_input (String web_arg_name, | |
| 69 | + password_input (WebArgName web_arg_name, | |
| 69 | 70 | String tag, |
| 70 | 71 | Mandatory mandatory), |
| 71 | - password_input_f (String web_arg_name, | |
| 72 | + password_input_f (WebArgName web_arg_name, | |
| 72 | 73 | List(Text_Option) -> HTML_In_Form tag, |
| 73 | 74 | Mandatory mandatory), |
| 74 | 75 | |
| ... | ... | @@ -79,61 +80,61 @@ public type FormField: |
| 79 | 80 | explain_f (List(Text_Option) -> HTML_In_Form), |
| 80 | 81 | |
| 81 | 82 | //--- selector field ------------------------------------------------------------------ |
| 82 | - selector (String web_arg_name, | |
| 83 | + selector (WebArgName web_arg_name, | |
| 83 | 84 | String tag, |
| 84 | 85 | List(String) items, |
| 85 | - Maybe(String) selected, | |
| 86 | + Maybe(InitialValue) selected, | |
| 86 | 87 | Mandatory mandatory), |
| 87 | - selector_f (String web_arg_name, | |
| 88 | + selector_f (WebArgName web_arg_name, | |
| 88 | 89 | List(Text_Option) -> HTML_In_Form, |
| 89 | 90 | List(String) items, |
| 90 | - Maybe(String) selected, | |
| 91 | + Maybe(InitialValue) selected, | |
| 91 | 92 | Mandatory mandatory), |
| 92 | - selector_c (String web_arg_name, | |
| 93 | + selector_c (WebArgName web_arg_name, | |
| 93 | 94 | String tag, |
| 94 | - List((String,String)) items, | |
| 95 | - Maybe(String) selected, | |
| 95 | + List((WebArgValue,String)) items, | |
| 96 | + Maybe(InitialValue) selected, | |
| 96 | 97 | Mandatory mandatory), |
| 97 | 98 | |
| 98 | 99 | |
| 99 | 100 | |
| 100 | 101 | //--- checkbox field ------------------------------------------------------------------ |
| 101 | - checkbox (String web_arg_name, | |
| 102 | + checkbox (WebArgName web_arg_name, | |
| 102 | 103 | String tag, |
| 103 | 104 | Bool checked, |
| 104 | 105 | Mandatory mandatory), |
| 105 | 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 | 108 | String tag, |
| 108 | 109 | Bool checked, |
| 109 | 110 | Mandatory mandatory), |
| 110 | - checkbox_f (String web_arg_name, | |
| 111 | + checkbox_f (WebArgName web_arg_name, | |
| 111 | 112 | List(Text_Option) -> HTML_In_Form, |
| 112 | 113 | Bool checked, |
| 113 | 114 | Mandatory mandatory), |
| 114 | 115 | |
| 115 | 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 | 119 | String tag, |
| 119 | 120 | Bool checked, |
| 120 | 121 | Mandatory mandatory), |
| 121 | 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 | 125 | String tag, |
| 125 | 126 | Bool checked, |
| 126 | 127 | Mandatory mandatory), |
| 127 | 128 | |
| 128 | 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 | 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 | 136 | String tag, |
| 136 | - String initial_text, | |
| 137 | + InitialValue initial_text, | |
| 137 | 138 | Int32 width, |
| 138 | 139 | Int32 height), |
| 139 | 140 | |
| ... | ... | @@ -161,24 +162,24 @@ public type FormField: |
| 161 | 162 | public define FormField title(List(Text_Option) -> HTML_In_Form f) = title_f(f). |
| 162 | 163 | public define FormField |
| 163 | 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 | 166 | List(Text_Option) -> HTML_In_Form tag, |
| 166 | 167 | Width width, |
| 167 | - String init_value, | |
| 168 | + InitialValue init_value, | |
| 168 | 169 | Mandatory mandatory) |
| 169 | 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 | 172 | List(Text_Option) -> HTML_In_Form tag, |
| 172 | 173 | Mandatory mandatory) |
| 173 | 174 | = password_input_f(web_arg_name,tag,mandatory). |
| 174 | 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 | 177 | List(Text_Option) -> HTML_In_Form f, |
| 177 | 178 | List(String) items, |
| 178 | - Maybe(String) selected, | |
| 179 | + Maybe(InitialValue) selected, | |
| 179 | 180 | Mandatory mandatory) |
| 180 | 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 | 183 | List(Text_Option) -> HTML_In_Form f, |
| 183 | 184 | Bool checked, |
| 184 | 185 | Mandatory mandatory) |
| ... | ... | @@ -200,7 +201,7 @@ public define HTML_Off_Form |
| 200 | 201 | --- That's all for the public part ! -------------------------------------------------- |
| 201 | 202 | |
| 202 | 203 | // TO DO update code of CXM generic form |
| 203 | - define HTML_Row(HTML_In_Form) | |
| 204 | +define HTML_Row(HTML_In_Form) | |
| 204 | 205 | format_form_field |
| 205 | 206 | ( |
| 206 | 207 | FormField ff |
| ... | ... | @@ -249,7 +250,7 @@ public define HTML_Off_Form |
| 249 | 250 | [ |
| 250 | 251 | cell([right ], text([size(10)],tag)), |
| 251 | 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 | 255 | small then 10, |
| 255 | 256 | narrow then 30, |
| ... | ... | @@ -260,7 +261,7 @@ public define HTML_Off_Form |
| 260 | 261 | |
| 261 | 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 | 266 | small then 10, |
| 266 | 267 | narrow then 30, |
| ... | ... | @@ -273,7 +274,7 @@ public define HTML_Off_Form |
| 273 | 274 | [ |
| 274 | 275 | cell([right ], tag([size(10)])), |
| 275 | 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 | 279 | small then 15, |
| 279 | 280 | narrow then 30, |
| ... | ... | @@ -286,14 +287,14 @@ public define HTML_Off_Form |
| 286 | 287 | [ |
| 287 | 288 | cell([right ], text([size(10)],tag)), |
| 288 | 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 | 293 | password_input_f(wan,tag,mand) then (List(HTML_Cell(HTML_In_Form))) |
| 293 | 294 | [ |
| 294 | 295 | cell([right ], tag([size(10)])), |
| 295 | 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 | 300 | explain(t) then (List(HTML_Cell(HTML_In_Form))) |
| ... | ... | @@ -328,8 +329,8 @@ public define HTML_Off_Form |
| 328 | 329 | cell([width(7)], star(mand)), |
| 329 | 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 | 340 | cell([width(7)], star(mand)), |
| 340 | 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 | 351 | cell([width(7)], star(mand)), |
| 351 | 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 | 360 | [ |
| 360 | 361 | cell([right ], text([size(10)],tag)), |
| 361 | 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 | 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 | 369 | cell([width(7)], star(mand)), |
| 369 | 370 | cell([left ], text([size(10)],tag)) |
| 370 | 371 | ], |
| ... | ... | @@ -373,19 +374,19 @@ public define HTML_Off_Form |
| 373 | 374 | [ |
| 374 | 375 | cell([right ], tag([size(10)])), |
| 375 | 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 | 380 | radio_button(wan,wav,tag,checked,mand) then (List(HTML_Cell(HTML_In_Form))) |
| 380 | 381 | [ |
| 381 | 382 | cell([right ], text([size(10)],tag)), |
| 382 | 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 | 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 | 390 | cell([width(7)], star(mand)), |
| 390 | 391 | cell([left ], text([size(10)],tag)) |
| 391 | 392 | ], |
| ... | ... | @@ -454,7 +455,7 @@ public define HTML_Off_Form |
| 454 | 455 | |
| 455 | 456 | |
| 456 | 457 | // TO DO update code of CXM generic form |
| 457 | - public define HTML_Off_Form | |
| 458 | +public define HTML_Off_Form | |
| 458 | 459 | generic_form |
| 459 | 460 | ( |
| 460 | 461 | String form_name, |
| ... | ... | @@ -465,6 +466,6 @@ public define HTML_Off_Form |
| 465 | 466 | table([border(0,0,5,bg_color),percentage_width(100), |
| 466 | 467 | background_color(bg_color)],[row(cell([h_center], |
| 467 | 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 | 989 | text_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), |
| 990 | 990 | text_input_ro (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), |
| 991 | 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 | 993 | file_upload (String label, HtmlId id, WebArgName name, Int32 width), |
| 994 | 994 | selector (List(InputAttrs), String label_text, HtmlId id, WebArgName name, Int32 size, List(String) choices), |
| 995 | 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 | 1037 | public define HTML_In_Form |
| 1038 | 1038 | text_area |
| 1039 | 1039 | ( |
| 1040 | - String name, | |
| 1041 | - String init, | |
| 1040 | + WebArgName name, | |
| 1041 | + InitialValue init, | |
| 1042 | 1042 | Int32 width, |
| 1043 | 1043 | Int32 height |
| 1044 | 1044 | ) = | ... | ... |