Commit 5e5890497943ea4f8d511dedba0809e84b4b36f5

Authored by totoro
1 parent 90042c30

replace sub_fielset by fieldset

harmonize cxm_form arguments
Showing 2 changed files with 115 additions and 92 deletions   Show diff stats
web/CXM_form.anubis
... ... @@ -207,7 +207,9 @@ public type CXM_Form_Field:
207 207 String help_text,
208 208 Int width),
209 209  
210   - sub_fieldset (HTML_In_Form fieldset),
  210 + fieldset (List(CoreAttrs) options,
  211 + String legend,
  212 + List(CXM_Form_Field) fields),
211 213  
212 214 blank_space,
213 215 blank_space (HtmlClass class),
... ... @@ -222,9 +224,32 @@ public type CXM_Form_Field:
222 224 empty.
223 225  
224 226 // //////////////////////////////////////////////
225   -// Alternative constructors:
  227 +// Alternate constructors:
226 228  
227 229 public define CXM_Form_Field
  230 + fieldset
  231 + (
  232 + HtmlId fieldSetId,
  233 + List(CXM_Form_Field) fields
  234 + ) =
  235 + fieldset([id(fieldSetId.id)], "", fields).
  236 +
  237 +public define CXM_Form_Field
  238 + fieldset
  239 + (
  240 + List(CXM_Form_Field) fields
  241 + ) =
  242 + fieldset([], "", fields).
  243 +
  244 +public define CXM_Form_Field
  245 + fieldset
  246 + (
  247 + String legend,
  248 + List(CXM_Form_Field) fields
  249 + ) =
  250 + fieldset([], legend, fields).
  251 +
  252 +public define CXM_Form_Field
228 253 input(WebArgName n, InitialValue init_value, Width width)
229 254 = input([], "", htmlId(n.name), n, init_value, width, non_mandatory).
230 255  
... ... @@ -354,7 +379,7 @@ define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)
354 379 ) = construct_selector_hide_show(div_id, items, [], [], 0).
355 380  
356 381 public define HTML_In_Form
357   - cxm_format_form_field
  382 + format_CXM_Form_Field
358 383 (
359 384 CXM_Form_Field ff,
360 385 List(Web_arg) lwa
... ... @@ -457,7 +482,7 @@ public define HTML_In_Form
457 482 with div_id = generate_random_string(15),
458 483 sequence([
459 484 check_box([class("in"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)),
460   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], cxm_format_form_field(ff2, lwa)),fields)))
  485 + div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], format_CXM_Form_Field(ff2, lwa)),fields)))
461 486 ]),
462 487  
463 488 radio_button(options, label, id, wan, val, checked, mand) then
... ... @@ -467,7 +492,7 @@ public define HTML_In_Form
467 492 with div_id = generate_random_string(15),
468 493 sequence([
469 494 radio_button([data("show_id", div_id), class("in"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)),
470   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], cxm_format_form_field(ff2, lwa)),fields)))
  495 + div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], format_CXM_Form_Field(ff2, lwa)),fields)))
471 496 ]),
472 497  
473 498 radio_buttonr(options, label, id, wan, val, checked, mand) then
... ... @@ -497,7 +522,7 @@ public define HTML_In_Form
497 522 ]),
498 523 one_line_fields(fields) then
499 524 table([nude],[row([],
500   - map((CXM_Form_Field ff2) |-> cell([],cxm_format_form_field(ff2, lwa)),fields))])
  525 + map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))])
501 526 ,
502 527  
503 528 upload(options, label, id, name, w, mand) then
... ... @@ -509,17 +534,27 @@ public define HTML_In_Form
509 534 sequence([
510 535 if id is htmlId(_id) then
511 536 literal("<label for=\"" + _id + "\">" + label + "</label>"),
512   - input]),
513   - div(options, e) then div(options, e),
514   - partial(p_content) then partial(p_content),
  537 + input
  538 + ]),
  539 +
  540 + div(options, e) then div(options, e),
  541 +
  542 + partial(p_content) then partial(p_content),
  543 +
515 544 input_with_help(input, help_title, help_text, width) then
516 545 sequence([
517   - cxm_format_form_field(input, lwa),
  546 + format_CXM_Form_Field(input, lwa),
518 547 html_tooltip(force_String(help_title), help_text, width),
519 548 ]),
520 549  
521   - sub_fieldset(fieldset) then fieldset,
522   -
  550 + fieldset(options, legend, fields) then
  551 + sequence([
  552 + literal("<fieldset" + format_attrs(options) + ">"),
  553 + literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""),
  554 + sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], format_CXM_Form_Field(ff, lwa)), fields) ),
  555 + literal("</fieldset>")
  556 + ]),
  557 +
523 558 blank_space then
524 559 div([class("blank_space")], literal("&nbsp")),
525 560  
... ... @@ -541,30 +576,32 @@ public define HTML_In_Form
541 576 }.
542 577  
543 578 public define HTML_In_Form
544   - cxm_fieldset
  579 + format_CXM_Form_Field
545 580 (
546   - List(CoreAttrs) options,
547   - String legend,
548   - List(Web_arg) lwa,
549   - List(CXM_Form_Field) fields
  581 + List(CXM_Form_Field) fields,
  582 + List(Web_arg) lwa
550 583 )=
551   - sequence([
552   - literal("<fieldset" + format_attrs(options) + ">"),
553   - literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""),
554   - sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], cxm_format_form_field(ff, lwa)), fields) ),
555   - literal("</fieldset>")]
556   - )
557   - .
558   -
559   -public define HTML_In_Form
560   - cxm_fieldset
  584 + sequence( map((CXM_Form_Field ff) |-> div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ).
  585 +
  586 +public define HTML_Off_Form
  587 + cxm_form
561 588 (
562   - HtmlId fieldSetId,
  589 + HtmlId form_Id,
  590 + List(CoreAttrs) options,
  591 + String action_name,
  592 + List((String,String)) extra_ops,
563 593 List(Web_arg) lwa,
564 594 List(CXM_Form_Field) fields
565 595 ) =
566   - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields).
567   -
  596 +
  597 + form(
  598 + form_Id,
  599 + [class("cxm_form") . options],
  600 + action_name,
  601 + extra_ops,
  602 + format_CXM_Form_Field(fields, lwa)
  603 + ).
  604 +
568 605 public define HTML_Off_Form
569 606 cxm_form
570 607 (
... ... @@ -572,76 +609,62 @@ public define HTML_Off_Form
572 609 List(CoreAttrs) options,
573 610 String action_name,
574 611 List((String,String)) extra_ops,
575   - List(HTML_In_Form) fieldSets
  612 + List(Web_arg) lwa,
  613 + List(CXM_Form_Field) form_fields
576 614 )=
577   - //div([class("formulaire")],
578   - form( form_name,
579   - [class("formulaire") . options],
580   - action_name,
581   - extra_ops,
582   - sequence( fieldSets )
583   - // )
584   - ).
  615 + cxm_form(htmlId(form_name), options, action_name, extra_ops, lwa, form_fields).
  616 +
  617 + public define HTML_In_Form
  618 + cxm_fieldset
  619 + (
  620 + HtmlId fieldSetId,
  621 + List(Web_arg) lwa,
  622 + List(CXM_Form_Field) fields
  623 + ) =
  624 + cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields).
  625 +
  626 +
585 627  
586 628 public define HTML_Off_Form
587 629 cxm_form
588 630 (
589   - String form_name,
  631 + String form_id,
590 632 List(CoreAttrs) options,
591   - List(HTML_In_Form) fieldSets
  633 + List(HTML_In_Form) fields
592 634 ) =
593   - //div([class("formulaire")],
594   - form( form_name,
595   - [class("formulaire") . options],
596   - sequence( fieldSets )
597   - // )
598   - ).
  635 + cxm_form(htmlId(form_id), options, "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
599 636  
600 637 public define HTML_Off_Form
601 638 cxm_form
602 639 (
603   - String form_name,
  640 + String form_id,
604 641 List(CoreAttrs) options,
605   - HtmlId fieldSetId,
606   - String action_name,
607   - List((String,String)) extra_ops,
608   - List(Web_arg) lwa,
  642 + List(Web_arg) lwa,
609 643 List(CXM_Form_Field) fields
610 644 ) =
611   - cxm_form(form_name, options, action_name, extra_ops,
612   - [
613   - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields)
614   - ]).
615   -
  645 + cxm_form(htmlId(form_id), options, "", [], lwa, fields).
  646 +
616 647 public define HTML_Off_Form
617 648 cxm_form
618 649 (
619   - String form_name,
620   - List(CoreAttrs) options,
621   - HtmlId fieldSetId,
622   - List(Web_arg) lwa,
623   - List(CXM_Form_Field) fields
  650 + String form_id,
  651 + List(HTML_In_Form) fields
624 652 ) =
625   - cxm_form(form_name, options,
626   - [
627   - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields)
628   - ]).
  653 + cxm_form(htmlId(form_id), [], "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
629 654  
630 655 public define HTML_Off_Form
631 656 cxm_form
632 657 (
633   - String form_name,
634   - List(HTML_In_Form) fieldSets
  658 + String form_id,
  659 + List(Web_arg) lwa,
  660 + List(CXM_Form_Field) fields
635 661 ) =
636   - cxm_form(form_name, [], fieldSets).
  662 + cxm_form(form_id, [], lwa, fields).
637 663  
638 664 public define HTML_Off_Form
639 665 cxm_form
640 666 (
641   - String form_name,
642   - HtmlId fieldSetId,
643   - List(Web_arg) lwa,
  667 + String form_id,
644 668 List(CXM_Form_Field) fields
645 669 ) =
646   - cxm_form(form_name, [], fieldSetId, lwa, fields).
647   -
  670 + cxm_form(htmlId(form_id), [], "", [], [], fields).
... ...
web/CXM_making_a_web_site.anubis
... ... @@ -4207,42 +4207,42 @@ define Printable_tree
4207 4207 format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags),
4208 4208 text_input(options, label_text, id, name, i, w) then
4209 4209 [ maybe_label(label_text, id),
4210   - "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
  4210 + "<input type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs([class("in") . options])," />"],
4211 4211 text_input_ro(options, label_text, id, name,i,w) then
4212 4212 [ maybe_label(label_text, id),
4213   - "<input readonly=\"readonly\" type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
  4213 + "<input readonly=\"readonly\" type=\"text\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs([class("in") . options])," />"],
4214 4214 password_input(options, label_text, id, name,i,w) then
4215 4215 [ maybe_label(label_text, id),
4216   - "<input type=\"password\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs(options)," />"],
4217   - text_area(opts,label_text, id, n,i,w,h) then
4218   - [ maybe_label(label_text, id), "<textarea ",format(opts)," id=\"",id,"\" name=\"",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"],
  4216 + "<input type=\"password\" name=\"",name,"\" id=\"",id,"\" size=\"",w,"\" value=\"",i,"\"",format_attrs([class("in") . options])," />"],
  4217 + text_area(options,label_text, id, n,i,w,h) then
  4218 + [ maybe_label(label_text, id), "<textarea ",format(options)," id=\"",id,"\" name=\"",n,"\" cols=\"",w,"\" rows=\"",h,"\">",i,"</textarea>"],
4219 4219 file_upload(options, label, id, n, w) then
4220 4220 [ maybe_label(label, id),
4221   - "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"",n,"\"",format_attrs(options)," />"],
4222   - selector(opts, label, id, n,s,cs) then
  4221 + "<input type=\"file\" id=\"",id,"\" size=\"",w,"\" name=\"",n,"\"",format_attrs([class("in") . options])," />"],
  4222 + selector(options, label, id, n,s,cs) then
4223 4223 [ maybe_label(label, id),
4224   - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"],
4225   - selector(opts, label, id, n,s,cs,sd) then
  4224 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"],
  4225 + selector(options, label, id, n,s,cs,sd) then
4226 4226 [ maybe_label(label, id),
4227   - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"],
4228   - selector_c(opts, label, id, n,s,cs) then
  4227 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"],
  4228 + selector_c(options, label, id, n,s,cs) then
4229 4229 [ maybe_label(label, id),
4230   - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs),"</select>"],
4231   - selector_c(opts, label, id, n,s,cs,sd) then
  4230 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs),"</select>"],
  4231 + selector_c(options, label, id, n,s,cs,sd) then
4232 4232 [ maybe_label(label, id),
4233   - "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs(opts),">",format_choices(cs,sd),"</select>"],
  4233 + "<select id=\"",id,"\" name=\"",n,"\" size=\"",s,"\" ",format_attrs([class("in") . options]),">",format_choices(cs,sd),"</select>"],
4234 4234  
4235 4235 radio_button(options, label_text, id, n, v, c) then
4236 4236 [ maybe_label(label_text, id),
4237   - "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />"],
  4237 + "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />"],
4238 4238 radio_button_r(options, label_text, id, n, v, c) then
4239   - [ "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs(options)," />",
  4239 + [ "<input type=\"radio\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\"" else ""),format_attrs([class("in") . options])," />",
4240 4240 maybe_label(label_text, id)],
4241 4241 check_box(options, label_text, id, n, v, c) then
4242 4242 [ maybe_label(label_text, id),
4243   - "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />"]
  4243 + "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />"]
4244 4244 check_box_r(options, label_text, id, n, v, c) then
4245   - [ "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs(options)," />",
  4245 + [ "<input type=\"checkbox\" name=\"",n,"\" id=\"",id,"\" value=\"",v,"\"",(if c then " checked=\"checked\" " else ""),format_attrs([class("in") . options])," />",
4246 4246 maybe_label(label_text, id)]
4247 4247 div(options, e) then
4248 4248 format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags),
... ...