Commit 47af25c21a0fbfe66f3fdb70531cdfedd257bdee
1 parent
50760510
Add CXM_Form_field file which contain form_field enhancements made during MailFo…
…untain development. I decided to integrate it into calexium_lib.
Showing
1 changed file
with
695 additions
and
0 deletions
Show diff stats
| 1 | +/* | ||
| 2 | + * Created by PyramIDE. | ||
| 3 | + * User: totoro | ||
| 4 | + * Date: 24/07/2007 | ||
| 5 | + * Time: 21:09 | ||
| 6 | + * | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +read tools/basis.anubis | ||
| 10 | +read system/lists.anubis | ||
| 11 | +read system/string.anubis | ||
| 12 | +read system_colors/rgb.anubis | ||
| 13 | + | ||
| 14 | +read calexium_lib/web/CXM_making_a_web_site.anubis | ||
| 15 | +read calexium_lib/web/CXM_multihost_http_server.anubis | ||
| 16 | +read calexium_lib/web/CXM_dojo.anubis | ||
| 17 | + | ||
| 18 | +read app_constants.anubis | ||
| 19 | + read app_version.anubis | ||
| 20 | +read web_pages/common/language_management.anubis | ||
| 21 | +read web_pages/common/web_widgets.anubis | ||
| 22 | +read calexium_lib/web/widgets/css_helper.anubis | ||
| 23 | +read tools/base_tools.anubis | ||
| 24 | +read utils.anubis | ||
| 25 | +read types/app_web_types.anubis | ||
| 26 | + | ||
| 27 | +define Text_Option | ||
| 28 | + menu_state_to_class | ||
| 29 | + ( | ||
| 30 | + MenuState state | ||
| 31 | + ) | ||
| 32 | + = | ||
| 33 | + if state is | ||
| 34 | + { | ||
| 35 | + none then class("item_normal"), | ||
| 36 | + highlight then class("item_highlight"), | ||
| 37 | + sub then class("subitem"), | ||
| 38 | + sub_and_highlight then class("subitem_highlight"), | ||
| 39 | + disabled then class("item_disabled") | ||
| 40 | + }. | ||
| 41 | + | ||
| 42 | +public define HTML_Off_Form | ||
| 43 | + menu_title | ||
| 44 | + ( | ||
| 45 | + String view_text | ||
| 46 | + ) = | ||
| 47 | + literal("<h1 class=\"menu_title\">" + view_text + "</h1>"). | ||
| 48 | + | ||
| 49 | +public define HTML_Off_Form | ||
| 50 | + menu_entry | ||
| 51 | + ( | ||
| 52 | + String view_text, | ||
| 53 | + String action, | ||
| 54 | + MenuState state | ||
| 55 | + )= | ||
| 56 | + paragraph([id(action), menu_state_to_class(state)], | ||
| 57 | + actioner( same, same, | ||
| 58 | + link([], view_text), | ||
| 59 | + action, | ||
| 60 | + [])). | ||
| 61 | + | ||
| 62 | +public define HTML_Off_Form | ||
| 63 | + menu_entry | ||
| 64 | + ( | ||
| 65 | + String view_text, | ||
| 66 | + String action, | ||
| 67 | + $T val, | ||
| 68 | + $T wanted | ||
| 69 | + )= | ||
| 70 | + if val = wanted then | ||
| 71 | + menu_entry(view_text, action, highlight) | ||
| 72 | + else | ||
| 73 | + menu_entry(view_text, action, none). | ||
| 74 | + | ||
| 75 | +public define HTML_Off_Form | ||
| 76 | + sub_menu_entry | ||
| 77 | + ( | ||
| 78 | + String view_text, | ||
| 79 | + String action, | ||
| 80 | + $T val, | ||
| 81 | + $T wanted | ||
| 82 | + )= | ||
| 83 | + if val = wanted then | ||
| 84 | + menu_entry(view_text, action, sub_and_highlight) | ||
| 85 | + else | ||
| 86 | + menu_entry(view_text, action, sub). | ||
| 87 | + | ||
| 88 | + | ||
| 89 | +public define HTML_Off_Form | ||
| 90 | + step_title | ||
| 91 | + ( | ||
| 92 | + String view_text | ||
| 93 | + ) = | ||
| 94 | + literal("<h1 class=\"wizard_title\">" + view_text + "</h1>"). | ||
| 95 | + | ||
| 96 | +public define HTML_Off_Form | ||
| 97 | + step_entry | ||
| 98 | + ( | ||
| 99 | + String view_text, | ||
| 100 | + String action, | ||
| 101 | + $T val, | ||
| 102 | + $T wanted, | ||
| 103 | + List($T) stepsDone | ||
| 104 | + )= | ||
| 105 | + if contains(stepsDone, wanted) | val = wanted then | ||
| 106 | + with state = if val = wanted then highlight | ||
| 107 | + else none, | ||
| 108 | + paragraph([id(action), menu_state_to_class(state)], | ||
| 109 | + actioner( same, same, | ||
| 110 | + link([], view_text), | ||
| 111 | + action, | ||
| 112 | + [])) | ||
| 113 | + else | ||
| 114 | + paragraph([id(action), class("item_disabled")], | ||
| 115 | + literal(view_text)) | ||
| 116 | + . | ||
| 117 | + | ||
| 118 | +public define HTML_In_Form | ||
| 119 | + display_info_line | ||
| 120 | + ( | ||
| 121 | + String html_id, | ||
| 122 | + String html_class, | ||
| 123 | + String txt, | ||
| 124 | + ) = | ||
| 125 | + div([class(html_class)], literal(txt)). | ||
| 126 | + | ||
| 127 | +public define HTML_Off_Form | ||
| 128 | + display_info_line | ||
| 129 | + ( | ||
| 130 | + String html_id, | ||
| 131 | + String html_class, | ||
| 132 | + String txt, | ||
| 133 | + ) = | ||
| 134 | + div([class(html_class)], literal(txt)). | ||
| 135 | + | ||
| 136 | +public define HTML_Off_Form | ||
| 137 | + display_main_info_line | ||
| 138 | + ( | ||
| 139 | + String html_class, | ||
| 140 | + String txt | ||
| 141 | + ) = | ||
| 142 | + display_info_line("informations", html_class, txt). | ||
| 143 | + | ||
| 144 | +// ************************************************************************************* | ||
| 145 | +// *** Generic form | ||
| 146 | +// ************************************************************************************* | ||
| 147 | + | ||
| 148 | +read calexium_lib/web/CXM_common.anubis | ||
| 149 | + | ||
| 150 | +public type Mandatory: // used to mark fields as mandatory. | ||
| 151 | + mandatory, | ||
| 152 | + non_mandatory. | ||
| 153 | + | ||
| 154 | +public type Width: | ||
| 155 | + small, | ||
| 156 | + narrow, | ||
| 157 | + wide, | ||
| 158 | + custom(Int). | ||
| 159 | + | ||
| 160 | +public type FormFieldWidth: | ||
| 161 | + auto, | ||
| 162 | + custom(Int). | ||
| 163 | + | ||
| 164 | +public type MF_FormTooltip: | ||
| 165 | + tooltip(String title, String content, Int width). | ||
| 166 | + | ||
| 167 | +public type CXM_Form_Field: | ||
| 168 | + no_field, // empty field | ||
| 169 | + | ||
| 170 | + //--- title field --------------------------------------------------------------------- | ||
| 171 | + title (String text), | ||
| 172 | +// title (Int text_size, | ||
| 173 | +// String text), | ||
| 174 | +// title_f (List(Text_Option) -> HTML_In_Form), | ||
| 175 | + | ||
| 176 | + //--- message field ------------------------------------------------------------------- | ||
| 177 | + message (String text), | ||
| 178 | + | ||
| 179 | + //--- text input field ---------------------------------------------------------------- | ||
| 180 | + input (List(InputAttrs) options, | ||
| 181 | + String label, | ||
| 182 | + HtmlId id, | ||
| 183 | + WebArgName web_arg_name, | ||
| 184 | + InitialValue init_value, | ||
| 185 | + Width width, | ||
| 186 | + Mandatory mandatory), | ||
| 187 | + input_readonly (List(InputAttrs) options, | ||
| 188 | + String label, | ||
| 189 | + HtmlId id, | ||
| 190 | + WebArgName web_arg_name, | ||
| 191 | + InitialValue init_value, | ||
| 192 | + Width width), | ||
| 193 | + | ||
| 194 | + //--- text area field ----------------------------------------------------------------- | ||
| 195 | + text_area (List(TextAreaOption) options, | ||
| 196 | + String label, | ||
| 197 | + HtmlId id, | ||
| 198 | + WebArgName web_arg_name, | ||
| 199 | + InitialValue init_value, | ||
| 200 | + Width width, | ||
| 201 | + Int height, | ||
| 202 | + Mandatory mandatory), | ||
| 203 | + | ||
| 204 | + //--- password input field ------------------------------------------------------------ | ||
| 205 | + password_input (List(InputAttrs) options, | ||
| 206 | + String label, | ||
| 207 | + HtmlId id, | ||
| 208 | + WebArgName web_arg_name, | ||
| 209 | + InitialValue init_value, | ||
| 210 | + Width width, | ||
| 211 | + Mandatory mandatory), | ||
| 212 | + | ||
| 213 | + //--- hidden field ------------------------------------------------------------ | ||
| 214 | + hidden (HtmlId id, | ||
| 215 | + WebArgName web_arg_name, | ||
| 216 | + InitialValue init_value), | ||
| 217 | + //--- explanation field --------------------------------------------------------------- | ||
| 218 | + explain (String text), | ||
| 219 | + | ||
| 220 | + //--- selector field ------------------------------------------------------------------ | ||
| 221 | + selector (List(InputAttrs) options, | ||
| 222 | + String label, | ||
| 223 | + HtmlId id, | ||
| 224 | + WebArgName web_arg_name, | ||
| 225 | + Int size, | ||
| 226 | + List(String) items, | ||
| 227 | + Maybe(InitialValue) selected, | ||
| 228 | + Mandatory mandatory), | ||
| 229 | + selector_c (List(InputAttrs) options, | ||
| 230 | + String label, | ||
| 231 | + HtmlId id, | ||
| 232 | + WebArgName web_arg_name, | ||
| 233 | + Int size, | ||
| 234 | + List((List(CoreAttrs),WebArgValue,String)) items, | ||
| 235 | + Maybe(InitialValue) selected, | ||
| 236 | + Mandatory mandatory), | ||
| 237 | + | ||
| 238 | + | ||
| 239 | + | ||
| 240 | + //--- checkbox field ------------------------------------------------------------------ | ||
| 241 | + checkbox (List(InputAttrs) options, | ||
| 242 | + String label, | ||
| 243 | + HtmlId id, | ||
| 244 | + WebArgName web_arg_name, | ||
| 245 | + WebArgValue web_arg_value, | ||
| 246 | + Bool checked, | ||
| 247 | + Mandatory mandatory), | ||
| 248 | + // the same one, but with the tag on the right of the checkbox | ||
| 249 | + checkboxr (List(InputAttrs) options, | ||
| 250 | + String label, | ||
| 251 | + HtmlId id, | ||
| 252 | + WebArgName web_arg_name, | ||
| 253 | + WebArgValue web_arg_value, | ||
| 254 | + Bool checked, | ||
| 255 | + Mandatory mandatory), | ||
| 256 | + | ||
| 257 | + //--- radio-button field -------------------------------------------------------------- | ||
| 258 | + radio_button (List(InputAttrs) options, | ||
| 259 | + String label, | ||
| 260 | + HtmlId id, | ||
| 261 | + WebArgName web_arg_name, | ||
| 262 | + WebArgValue web_arg_value, | ||
| 263 | + Bool checked, | ||
| 264 | + Mandatory mandatory), | ||
| 265 | + // the same one, but with the tag on the right of the radio_button | ||
| 266 | + radio_buttonr (List(InputAttrs) options, | ||
| 267 | + String label, | ||
| 268 | + HtmlId id, | ||
| 269 | + WebArgName web_arg_name, | ||
| 270 | + WebArgValue web_arg_value, | ||
| 271 | + Bool checked, | ||
| 272 | + Mandatory mandatory), | ||
| 273 | + | ||
| 274 | + radio_button_list (List(InputAttrs) options, | ||
| 275 | + String label, | ||
| 276 | + HtmlId id, | ||
| 277 | + WebArgName web_arg_name, | ||
| 278 | + List((WebArgValue, String)) web_arg_value, | ||
| 279 | + Maybe(InitialValue) selected, | ||
| 280 | + Mandatory mandatory, | ||
| 281 | + Bool is_wide), | ||
| 282 | + | ||
| 283 | +// //--- fields table -------------------------------------------------------------------- | ||
| 284 | +// fields_table (String tag, | ||
| 285 | +// List(FormField) fields), | ||
| 286 | +// | ||
| 287 | +// //--- fields line --------------------------------------------------------------------- | ||
| 288 | +// fields_line (String tag, | ||
| 289 | +// List(FormField) fields), | ||
| 290 | + one_line_fields (List(CXM_Form_Field) fields), | ||
| 291 | + | ||
| 292 | +// | ||
| 293 | +// //--- preview field ------------------------------------------------------------------- | ||
| 294 | +// preview (String html_text), | ||
| 295 | + | ||
| 296 | + //--- upload field ------------------------------------------------------------------- | ||
| 297 | + upload (List(InputAttrs) options, | ||
| 298 | + String label, | ||
| 299 | + HtmlId id, | ||
| 300 | + WebArgName name, | ||
| 301 | + Width width, | ||
| 302 | + Mandatory mandatory), | ||
| 303 | + | ||
| 304 | + raw_in_form (HTML_In_Form html), | ||
| 305 | + raw_in_form (String label, | ||
| 306 | + HtmlId id, | ||
| 307 | + HTML_In_Form input), | ||
| 308 | + div (List(CoreAttrs), HTML_In_Form content), | ||
| 309 | + partial (HTML_Partial_Content p_content), | ||
| 310 | + input_with_help (CXM_Form_Field field, | ||
| 311 | + Maybe(String) help_title, | ||
| 312 | + String help_text, | ||
| 313 | + Int width), | ||
| 314 | + | ||
| 315 | + sub_fieldset (HTML_In_Form fieldset), | ||
| 316 | + | ||
| 317 | + blank_space, | ||
| 318 | + blank_space (HtmlClass class), | ||
| 319 | + | ||
| 320 | + //--- submit button ------------------------------------------------------------------- | ||
| 321 | + submit (List(CoreAttrs) options, | ||
| 322 | + HtmlClass class, | ||
| 323 | + String action_name, | ||
| 324 | + Maybe(String) label, | ||
| 325 | + String button_text, | ||
| 326 | + List((String,String)) extra_operands), | ||
| 327 | + empty. | ||
| 328 | + | ||
| 329 | +// ////////////////////////////////////////////// | ||
| 330 | +// Alternative constructors: | ||
| 331 | + | ||
| 332 | +public define CXM_Form_Field | ||
| 333 | + input(WebArgName n, InitialValue init_value, Width width) | ||
| 334 | + = input([], "", htmlId(n.name), n, init_value, width, non_mandatory). | ||
| 335 | + | ||
| 336 | +public define CXM_Form_Field | ||
| 337 | + input(String label, WebArgName n, InitialValue init_value, Width width) | ||
| 338 | + = input([], label, htmlId(n.name), n, init_value, width, non_mandatory). | ||
| 339 | + | ||
| 340 | +public define CXM_Form_Field | ||
| 341 | + input(String label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | ||
| 342 | + = input([], label, htmlId(n.name), n, init_value, width, mand). | ||
| 343 | + | ||
| 344 | +public define CXM_Form_Field | ||
| 345 | + input_readonly(String label, WebArgName n, InitialValue init_value, Width width) | ||
| 346 | + = input_readonly([], label, htmlId(n.name), n, init_value, width). | ||
| 347 | + | ||
| 348 | +public define CXM_Form_Field | ||
| 349 | + password_input(String label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) | ||
| 350 | + = password_input([], label, htmlId(n.name), n, init_value, width, mand). | ||
| 351 | + | ||
| 352 | +public define CXM_Form_Field | ||
| 353 | + checkbox(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | ||
| 354 | + = checkbox([], label, htmlId(n.name), n, value, checked, mand). | ||
| 355 | + | ||
| 356 | +public define CXM_Form_Field | ||
| 357 | + checkboxr(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | ||
| 358 | + = checkboxr([], label, htmlId(n.name), n, value, checked, mand). | ||
| 359 | + | ||
| 360 | +public define CXM_Form_Field | ||
| 361 | + radio_button(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | ||
| 362 | + = radio_button([], label, htmlId(n.name), n, value, checked, mand). | ||
| 363 | + | ||
| 364 | +public define CXM_Form_Field | ||
| 365 | + radio_buttonr(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) | ||
| 366 | + = radio_buttonr([], label, htmlId(n.name), n, value, checked, mand). | ||
| 367 | + | ||
| 368 | +public define CXM_Form_Field | ||
| 369 | + submit(String action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands) | ||
| 370 | + = submit([], class, action_name, label, button_text, extra_operands). | ||
| 371 | + | ||
| 372 | +public define CXM_Form_Field | ||
| 373 | + submit(String action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) | ||
| 374 | + = submit([], htmlClass(""), action_name, label, button_text, extra_operands). | ||
| 375 | + | ||
| 376 | +public define CXM_Form_Field | ||
| 377 | + upload(String label, HtmlId id, WebArgName name, Width width) | ||
| 378 | + = upload([], label, id, name, width, non_mandatory). | ||
| 379 | + | ||
| 380 | +public define CXM_Form_Field | ||
| 381 | + upload(String label, HtmlId id, WebArgName name, Width width, Mandatory mand) | ||
| 382 | + = upload([], label, id, name, width, mand). | ||
| 383 | + | ||
| 384 | +public define CXM_Form_Field | ||
| 385 | + input_with_help (CXM_Form_Field field, String help_text) | ||
| 386 | + = input_with_help (field, failure, help_text, 250). | ||
| 387 | + | ||
| 388 | +public define CXM_Form_Field | ||
| 389 | + input_with_help (CXM_Form_Field field, String help_text, Int width) | ||
| 390 | + = input_with_help (field, failure, help_text, width). | ||
| 391 | + | ||
| 392 | +public define CXM_Form_Field | ||
| 393 | + ip_input | ||
| 394 | + ( | ||
| 395 | + String label, | ||
| 396 | + HtmlId id, | ||
| 397 | + WebArgName wan_prefix, | ||
| 398 | + String ip | ||
| 399 | + )= | ||
| 400 | + raw_in_form( | ||
| 401 | + label, | ||
| 402 | + id, | ||
| 403 | + ip_input(id, wan_prefix, ip) | ||
| 404 | + ). | ||
| 405 | + | ||
| 406 | + | ||
| 407 | +public define CXM_Form_Field | ||
| 408 | + partial_ip_input | ||
| 409 | + ( | ||
| 410 | + String label, | ||
| 411 | + HtmlId id, | ||
| 412 | + WebArgName wan_prefix, | ||
| 413 | + List(String) ip_fixed_part, | ||
| 414 | + String ip | ||
| 415 | + )= | ||
| 416 | + raw_in_form( | ||
| 417 | + label, | ||
| 418 | + id, | ||
| 419 | + partial_ip_input(id, wan_prefix, ip_fixed_part, ip) | ||
| 420 | + ). | ||
| 421 | + | ||
| 422 | +public define CXM_Form_Field | ||
| 423 | + hidden | ||
| 424 | + ( | ||
| 425 | + WebArgName web_arg_name, | ||
| 426 | + InitialValue init_value | ||
| 427 | + )= | ||
| 428 | + if web_arg_name is wan(name) then | ||
| 429 | + hidden(htmlId(name), web_arg_name, init_value). | ||
| 430 | + | ||
| 431 | + | ||
| 432 | + //--- explanation field --------------------- | ||
| 433 | + | ||
| 434 | +// ////////////////////////////////////////////////////////// | ||
| 435 | + | ||
| 436 | +public define HTML_In_Form | ||
| 437 | + mf_format_form_field | ||
| 438 | + ( | ||
| 439 | + CXM_Form_Field ff | ||
| 440 | + ) = | ||
| 441 | + with star = (Mandatory m) |-> (String) | ||
| 442 | + if m is | ||
| 443 | + { | ||
| 444 | + mandatory then "<span>*</span>", | ||
| 445 | + non_mandatory then "" | ||
| 446 | + }, | ||
| 447 | + pixels = (Width width) |-> | ||
| 448 | + if width is | ||
| 449 | + { | ||
| 450 | + small then 10, | ||
| 451 | + narrow then 50, | ||
| 452 | + wide then 70, | ||
| 453 | + custom(n) then n | ||
| 454 | + }, | ||
| 455 | + // special case out of the div("inputable") tag. | ||
| 456 | +// if ff is submit(attrs, action_name, mb_label, button_text, extra_operands) then | ||
| 457 | +// mf_format_form_field_inside_inputable(ff, star, pixels) | ||
| 458 | +// else if ff is hidden(name, init) then | ||
| 459 | +// mf_format_form_field_inside_inputable(ff, star, pixels) | ||
| 460 | +// else if ff is sub_fieldset(fieldset) then | ||
| 461 | +// mf_format_form_field_inside_inputable(ff, star, pixels) | ||
| 462 | +// else | ||
| 463 | +// div([class("inputable")], | ||
| 464 | +// mf_format_form_field_inside_inputable(ff, star, pixels)) | ||
| 465 | + | ||
| 466 | +// sequence([ | ||
| 467 | +// literal(" <tr class=\"form_row\">\n"), | ||
| 468 | +// mf_format_form_field_inside_inputable(ff, star, pixels, failure), | ||
| 469 | +// literal(" </tr>\n"), | ||
| 470 | +// ]) | ||
| 471 | + | ||
| 472 | + if ff is | ||
| 473 | + { | ||
| 474 | + no_field then | ||
| 475 | + literal(""), | ||
| 476 | + | ||
| 477 | + title(t) then | ||
| 478 | + literal("<h2>" + t + "</h2>"), | ||
| 479 | + | ||
| 480 | +// title(s,t) then | ||
| 481 | +// text([h_center, size(s),bold,color(rgb(0,0,0))], t), | ||
| 482 | +// | ||
| 483 | +// title_f(t) then | ||
| 484 | +// t([h_center, size(16),bold,color(rgb(0,0,0))]), | ||
| 485 | + | ||
| 486 | + message(t) then | ||
| 487 | + literal(t), | ||
| 488 | + | ||
| 489 | + input(options, label, id, name, init, w, mand) then | ||
| 490 | + text_input([class("in") . options], label + star(mand), id, name, init, pixels(w)), | ||
| 491 | + | ||
| 492 | + input_readonly(options, label, id, name, init, w) then | ||
| 493 | + text_input_ro([class("in") . options], label, id, name, init, pixels(w)), | ||
| 494 | + | ||
| 495 | + text_area(options, label, id, name, init, w, height, mand) then | ||
| 496 | + text_area([input_attrs([class("in")]) . options], label + star(mand), id, name, init, pixels(w), height), | ||
| 497 | + | ||
| 498 | + password_input(options, label, id, name, init, w, mand) then | ||
| 499 | + password_input([class("in") . options], label + star(mand), id, name, init, pixels(w)), | ||
| 500 | + | ||
| 501 | + hidden(id, name, init) then | ||
| 502 | + hidden(id, name, init), | ||
| 503 | + | ||
| 504 | + explain(t) then | ||
| 505 | + div([class("sub")], literal(t)), | ||
| 506 | + | ||
| 507 | + selector(options, label, id, wan, size, items, selected, mand) then | ||
| 508 | + if selected is | ||
| 509 | + { | ||
| 510 | + failure then selector(options, label + star(mand), id, wan, size, items), | ||
| 511 | + success(init) then selector(options, label + star(mand), id, wan, size, items, init), | ||
| 512 | + }, | ||
| 513 | + | ||
| 514 | + selector_c(options, label, id, wan, size, items, selected, mand) then | ||
| 515 | + if selected is | ||
| 516 | + { | ||
| 517 | + failure then selector_c(options, label + star(mand), id, wan, size, items), | ||
| 518 | + success(init) then selector_c(options, label + star(mand), id, wan, size, items, init), | ||
| 519 | + }, | ||
| 520 | + | ||
| 521 | + checkbox(options, label, id, name, val, checked, mand) then | ||
| 522 | + check_box(options, label + star(mand), id, name, val, checked), | ||
| 523 | + | ||
| 524 | + checkboxr(options, label, id, name, val, checked, mand) then | ||
| 525 | + check_box_r(options, label + star(mand), id, name, val, checked), | ||
| 526 | + | ||
| 527 | + radio_button(options, label, id, name, val, checked, mand) then | ||
| 528 | + radio_button(options, label + star(mand), id, name, val, checked), | ||
| 529 | + | ||
| 530 | + radio_buttonr(options, label, id, name, val, checked, mand) then | ||
| 531 | + radio_button_r(options, label + star(mand), id, name, val, checked), | ||
| 532 | + | ||
| 533 | + radio_button_list (options, label, id, wan, items, selected, mand, wide) then | ||
| 534 | + sequence([ | ||
| 535 | + literal("<label for=\"" + wan.name + "\">" + label + star(mand) + "</label>"), | ||
| 536 | + div( [class("radiolist")], sequence( | ||
| 537 | + with i = var((Int)-1), | ||
| 538 | + itemclass = if wide then "radiolistitem_wide" else "radiolistitem", | ||
| 539 | + map( ((WebArgValue, String) item) |-> | ||
| 540 | + i <- *i + 1; | ||
| 541 | + if item is (wav, item_label) then | ||
| 542 | + with id = if id is htmlId(the_id) then htmlId(the_id + "_radio_" + *i), | ||
| 543 | + div([class(itemclass)], radio_button_r(options, item_label, id, wan, wav, | ||
| 544 | + if selected is success(v) then wav.value = v.value else false)), | ||
| 545 | + items)) | ||
| 546 | + ), | ||
| 547 | + ]), | ||
| 548 | + one_line_fields(fields) then | ||
| 549 | + table([nude],[row([], | ||
| 550 | + map((CXM_Form_Field ff2) |-> cell([],mf_format_form_field(ff2)),fields))]) | ||
| 551 | + , | ||
| 552 | + | ||
| 553 | + | ||
| 554 | + upload(options, label, id, name, w, mand) then | ||
| 555 | + file_upload(options, label + star(mand), id, name, pixels(w)), | ||
| 556 | + | ||
| 557 | + raw_in_form(html) then | ||
| 558 | + html, | ||
| 559 | +// div([class("in")], html), | ||
| 560 | + raw_in_form(label, id, input) then | ||
| 561 | + sequence([ | ||
| 562 | + if id is htmlId(id) then | ||
| 563 | + literal("<label for=\"" + id + "\">" + label + "</label>"), | ||
| 564 | + input]), | ||
| 565 | + div(options, e) then div(options, e), | ||
| 566 | + partial(p_content) then partial(p_content), | ||
| 567 | + input_with_help(input, help_title, help_text, width) then | ||
| 568 | + sequence([ | ||
| 569 | + mf_format_form_field(input), | ||
| 570 | + html_tooltip(force_String(help_title), help_text, width), | ||
| 571 | + ]), | ||
| 572 | + | ||
| 573 | + sub_fieldset(fieldset) then | ||
| 574 | + fieldset, | ||
| 575 | + | ||
| 576 | + blank_space then | ||
| 577 | + div([class("blank_space")], literal(" ")), | ||
| 578 | + | ||
| 579 | + blank_space(htmlClass) then | ||
| 580 | + div([class(htmlClass.class)], literal(" ")), | ||
| 581 | + | ||
| 582 | + submit(attrs, htmlClass, action_name, mb_label, button_text, extra_operands) then | ||
| 583 | + actioner( same, // TODO change this to allow external URL | ||
| 584 | + if mb_label is | ||
| 585 | + { | ||
| 586 | + failure then same, | ||
| 587 | + success(n) then same(n) | ||
| 588 | + }, | ||
| 589 | + submit(attrs + [class(htmlClass.class)], button_text), | ||
| 590 | + action_name, | ||
| 591 | + extra_operands | ||
| 592 | + ), | ||
| 593 | + empty then literal("") | ||
| 594 | + }. | ||
| 595 | + | ||
| 596 | +public define HTML_In_Form | ||
| 597 | + cxm_generic_fieldset | ||
| 598 | + ( | ||
| 599 | + List(CoreAttrs) options, | ||
| 600 | + String legend, | ||
| 601 | + List(CXM_Form_Field)fields | ||
| 602 | + ) = | ||
| 603 | + sequence([ | ||
| 604 | + literal("<fieldset" + format_attrs(options) + ">"), | ||
| 605 | + literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""), | ||
| 606 | + sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], mf_format_form_field(ff)), fields) ), | ||
| 607 | + literal("</fieldset>")]). | ||
| 608 | + | ||
| 609 | +public define HTML_In_Form | ||
| 610 | + cxm_generic_fieldset | ||
| 611 | + ( | ||
| 612 | + HtmlId fieldSetId, | ||
| 613 | + List(CXM_Form_Field)fields | ||
| 614 | + ) = | ||
| 615 | + cxm_generic_fieldset([id(fieldSetId.id), class("aligned")], "", fields). | ||
| 616 | + | ||
| 617 | +public define HTML_Off_Form | ||
| 618 | + cxm_generic_form | ||
| 619 | + ( | ||
| 620 | + String form_name, | ||
| 621 | + List(CoreAttrs) options, | ||
| 622 | + String action_name, | ||
| 623 | + List((String,String)) extra_ops, | ||
| 624 | + List(HTML_In_Form) fieldSets | ||
| 625 | + ) = | ||
| 626 | + //div([class("formulaire")], | ||
| 627 | + form( form_name, | ||
| 628 | + [class("formulaire") . options], | ||
| 629 | + action_name, | ||
| 630 | + extra_ops, | ||
| 631 | + sequence( fieldSets ) | ||
| 632 | + // ) | ||
| 633 | + ). | ||
| 634 | + | ||
| 635 | +public define HTML_Off_Form | ||
| 636 | + cxm_generic_form | ||
| 637 | + ( | ||
| 638 | + String form_name, | ||
| 639 | + List(CoreAttrs) options, | ||
| 640 | + List(HTML_In_Form) fieldSets | ||
| 641 | + ) = | ||
| 642 | + //div([class("formulaire")], | ||
| 643 | + form( form_name, | ||
| 644 | + [class("formulaire") . options], | ||
| 645 | + sequence( fieldSets ) | ||
| 646 | + // ) | ||
| 647 | + ). | ||
| 648 | + | ||
| 649 | +public define HTML_Off_Form | ||
| 650 | + cxm_generic_form | ||
| 651 | + ( | ||
| 652 | + String form_name, | ||
| 653 | + List(CoreAttrs) options, | ||
| 654 | + HtmlId fieldSetId, | ||
| 655 | + String action_name, | ||
| 656 | + List((String,String)) extra_ops, | ||
| 657 | + | ||
| 658 | + List(CXM_Form_Field) fields | ||
| 659 | + ) = | ||
| 660 | + cxm_generic_form(form_name, options, action_name, extra_ops, | ||
| 661 | + [ | ||
| 662 | + cxm_generic_fieldset([id(fieldSetId.id), class("aligned")], "", fields) | ||
| 663 | + ]). | ||
| 664 | + | ||
| 665 | +public define HTML_Off_Form | ||
| 666 | + cxm_generic_form | ||
| 667 | + ( | ||
| 668 | + String form_name, | ||
| 669 | + List(CoreAttrs) options, | ||
| 670 | + HtmlId fieldSetId, | ||
| 671 | + List(CXM_Form_Field) fields | ||
| 672 | + ) = | ||
| 673 | + cxm_generic_form(form_name, options, | ||
| 674 | + [ | ||
| 675 | + cxm_generic_fieldset([id(fieldSetId.id), class("aligned")], "", fields) | ||
| 676 | + ]). | ||
| 677 | + | ||
| 678 | +public define HTML_Off_Form | ||
| 679 | + cxm_generic_form | ||
| 680 | + ( | ||
| 681 | + String form_name, | ||
| 682 | + List(HTML_In_Form) fieldSets | ||
| 683 | + ) = | ||
| 684 | + cxm_generic_form(form_name, [], fieldSets). | ||
| 685 | + | ||
| 686 | +public define HTML_Off_Form | ||
| 687 | + cxm_generic_form | ||
| 688 | + ( | ||
| 689 | + String form_name, | ||
| 690 | + HtmlId fieldSetId, | ||
| 691 | + List(CXM_Form_Field) fields | ||
| 692 | + ) = | ||
| 693 | + cxm_generic_form(form_name, [], fieldSetId, fields). | ||
| 694 | + | ||
| 695 | + |