Commit 5f5eba12df642d967e7320dfd75f534b7e2b8b8a

Authored by totoro
1 parent 97670472

add option to not show label with the CXM_Form_Field

Showing 1 changed file with 169 additions and 100 deletions   Show diff stats
web/CXM_form.anubis
... ... @@ -417,38 +417,48 @@ define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)
417 417 public define HTML_In_Form
418 418 format_div_CXM_Form_Field
419 419 (
420   - CXM_Form_Field field,
421   - List(Web_arg) lwa,
422   - String _class
  420 + List(CXM_Form_Field) field,
  421 + List(Web_arg) lwa,
  422 + String _class,
  423 + Bool b_with_label
423 424 ).
424   -
  425 +
  426 +
425 427 public define HTML_In_Form
426 428 format_CXM_Form_Field
427 429 (
428   - CXM_Form_Field ff,
429   - List(Web_arg) lwa
  430 + CXM_Form_Field ff, //CXM_Form_Field to format
  431 + List(Web_arg) lwa, //web arguments of the session, can be useful for the current drawing
  432 + String _class,
  433 + Bool b_with_label //if false, no need to show/generate label
430 434 ) =
431   - with star = (HTML_Label l, Mandatory m) |-> (HTML_Label)
432   - if m is
433   - {
434   - mandatory then
435   - if l is
436   - {
437   - no_label then l,
438   - label(str, help) then label(str + "<span>*</span>", help),
439   - }
440   -
441   - non_mandatory then l
442   - },
443   - pixels = (Width width) |->
444   - if width is
445   - {
446   - small then 10,
447   - narrow_small then 20,
448   - narrow then 50,
449   - wide then 70,
450   - custom(n) then n
451   - },
  435 + with star = (HTML_Label l, Mandatory m)
  436 + |->
  437 + (HTML_Label)
  438 + if b_with_label then
  439 + if m is
  440 + {
  441 + mandatory then
  442 + if l is
  443 + {
  444 + no_label then l,
  445 + label(str, help) then label(str + "<span>*</span>", help),
  446 + }
  447 + non_mandatory then l
  448 + }
  449 + else
  450 + no_label
  451 + ,
  452 + pixels = (Width width)
  453 + |->
  454 + if width is
  455 + {
  456 + small then 10,
  457 + narrow_small then 20,
  458 + narrow then 50,
  459 + wide then 70,
  460 + custom(n) then n
  461 + },
452 462  
453 463  
454 464 if ff is
... ... @@ -512,7 +522,7 @@ public define HTML_In_Form
512 522 with div_id = generate_random_string(15),
513 523 sequence([
514 524 check_box([data("show_id", div_id), class("in"), class("cxm_checkbox_hide_show"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], _label, html_Id("checkbox_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)),
515   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> format_div_CXM_Form_Field(ff2, lwa, "form_field"),fields)))
  525 + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label))
516 526 ]),
517 527  
518 528 radio_button(options, _label, id, wan, val, checked, mand) then
... ... @@ -522,7 +532,7 @@ public define HTML_In_Form
522 532 with div_id = generate_random_string(15),
523 533 sequence([
524 534 radio_button([data("show_id", div_id), class("in"), class("cxm_radio_hide_show"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], _label, html_Id("radio_button_hide_show_"+div_id), wan, val, get_Bool(lwa, wan.name, checked)),
525   - div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> format_div_CXM_Form_Field(ff2, lwa, "form_field"),fields)))
  535 + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label))
526 536 ]),
527 537  
528 538 radio_buttonr(options, _label, id, wan, val, checked, mand) then
... ... @@ -552,7 +562,7 @@ public define HTML_In_Form
552 562 ]),
553 563 one_line_fields(fields) then
554 564 table([nude, class("form_one_line")],[row([],
555   - map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))])
  565 + map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa, _class, b_with_label)),fields))])
556 566 ,
557 567  
558 568 upload(options, _label, id, name, w, mand) then
... ... @@ -580,7 +590,7 @@ public define HTML_In_Form
580 590 sequence([
581 591 literal("<fieldset" + format_attrs(options) + ">"),
582 592 literal(if length(legend) > 0 then "<legend>" + legend + "</legend>" else ""),
583   - sequence( map((CXM_Form_Field ffield) |-> format_div_CXM_Form_Field(ffield, lwa, "form_field"), fields) ),
  593 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label),
584 594 literal("</fieldset>")
585 595 ]),
586 596  
... ... @@ -604,92 +614,93 @@ public define HTML_In_Form
604 614 empty then literal("")
605 615 }.
606 616  
607   -public define HTML_In_Form
  617 + public define HTML_In_Form
608 618 format_div_CXM_Form_Field
609 619 (
610 620 CXM_Form_Field field,
611 621 List(Web_arg) lwa,
612   - String _class
  622 + String _class,
  623 + Bool b_with_label
613 624 )=
614 625 if field is empty then
615 626 empty
616 627 else if field is no_field then
617 628 empty
618 629 else if field is hidden(id, name, init) then
619   - format_CXM_Form_Field(field, lwa)
  630 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
620 631 else if field is br then
621   - format_CXM_Form_Field(field, lwa)
  632 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
622 633 else if field is text_area(options, _label, id, wan, default, w, height, mand) then
623   - div([], format_CXM_Form_Field(field, lwa))
  634 + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label))
624 635 else
625   - div([class(_class)], format_CXM_Form_Field(field, lwa))
  636 + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label))
626 637 .
627 638  
  639 +
  640 +
628 641 public define HTML_In_Form
629   - format_CXM_Form_Field
  642 + format_div_CXM_Form_Field
630 643 (
631 644 List(CXM_Form_Field) fields,
632   - List(Web_arg) lwa
  645 + List(Web_arg) lwa,
  646 + String _class,
  647 + Bool b_with_label
633 648 )=
634   - sequence( map((CXM_Form_Field ff)
  649 + //println("format_div_CXM_Form_Field");
  650 + sequence( map((CXM_Form_Field field)
635 651 |->
636   - format_div_CXM_Form_Field(ff, lwa, "form_field aligned"), fields))
  652 + //with css_line = if line = 0 then " odd_line" else " even_line",
  653 + //println("class "+css_line+" line "+line);
  654 + if field is empty then
  655 + empty
  656 + else if field is no_field then
  657 + empty
  658 + else if field is hidden(id, name, init) then
  659 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  660 + else if field is br then
  661 + format_CXM_Form_Field(field, lwa, _class, b_with_label)
  662 + else if field is text_area(options, _label, id, wan, default, w, height, mand) then
  663 + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  664 + else
  665 + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label))
  666 + , fields))
637 667 .
638 668  
639 669 public define HTML_In_Form
640   - fieldset
  670 + to_HTML_In_Form
641 671 (
642   - List(Web_arg) lwa,
643 672 List(CXM_Form_Field) fields,
  673 + List(Web_arg) lwa,
  674 + String _class,
  675 + Bool b_with_label
644 676 )=
645   - sequence( map((CXM_Form_Field ff) |->
646   - if ff is empty then
647   - empty
648   - else if ff is no_field then
649   - empty
650   - else if ff is hidden(id, name, init) then
651   - format_CXM_Form_Field(ff, lwa)
652   - else if ff is br then
653   - format_CXM_Form_Field(ff, lwa)
654   - else
655   - div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ).
  677 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
  678 +.
656 679  
657   -public define HTML_In_Form
  680 + "form_field aligned"
  681 +
  682 + public define HTML_In_Form
658 683 fieldset
659 684 (
660   - List(Web_arg) lwa,
661 685 CXM_Form_Field field,
  686 + List(Web_arg) lwa,
  687 + String _class,
  688 + Bool b_with_label
662 689 )=
663   - if field is empty then
664   - empty
665   - else if field is no_field then
666   - empty
667   - else if field is hidden(id, name, init) then
668   - format_CXM_Form_Field(field, lwa)
669   - else if field is br then
670   - format_CXM_Form_Field(field, lwa)
671   - else
672   - div([class("form_field aligned")], format_CXM_Form_Field(field, lwa))
  690 + fieldset([field], lwa, _class, b_with_label)
673 691 .
674 692  
675 693  
676 694 public define HTML_In_Form
677   - fieldset
  695 + to_HTML_In_Form
678 696 (
679   - List(CXM_Form_Field) fields
  697 + List(CXM_Form_Field) fields,
  698 + String _class,
  699 + Bool b_with_label
680 700 )=
681   - sequence( map((CXM_Form_Field ff) |->
682   - if ff is empty then
683   - empty
684   - else if ff is no_field then
685   - empty
686   - else if ff is hidden(id, name, init) then
687   - format_CXM_Form_Field(ff, [])
688   - else if ff is br then
689   - format_CXM_Form_Field(ff, [])
690   - else
691   - div([class("form_field aligned")], format_CXM_Form_Field(ff, [])), fields) ).
  701 + to_HTML_In_Form(fields, [], _class, b_with_label).
692 702  
  703 +public
693 704  
694 705 public define HTML_Off_Form
695 706 cxm_form
... ... @@ -699,15 +710,16 @@ public define HTML_Off_Form
699 710 WEB_Action_Name action,
700 711 List((String,String)) extra_ops,
701 712 List(Web_arg) lwa,
702   - List(CXM_Form_Field) fields
  713 + List(CXM_Form_Field) fields,
  714 + String _class,
  715 + Bool b_with_label
703 716 ) =
704   -
705 717 form(
706 718 form_Id,
707 719 [class("cxm_form") . options],
708 720 action,
709 721 extra_ops,
710   - format_CXM_Form_Field(fields, lwa)
  722 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
711 723 ).
712 724  
713 725 public define HTML_Off_Form
... ... @@ -722,7 +734,9 @@ public define HTML_Off_Form
722 734 String action, //older manner to call action with String
723 735 List((String,String)) extra_ops,
724 736 List(Web_arg) lwa,
725   - List(CXM_Form_Field) fields
  737 + List(CXM_Form_Field) fields,
  738 + String _class,
  739 + Bool b_with_label
726 740 ) =
727 741  
728 742 form(
... ... @@ -730,7 +744,7 @@ public define HTML_Off_Form
730 744 [class("cxm_form") . options],
731 745 action_name(action),
732 746 extra_ops,
733   - format_CXM_Form_Field(fields, lwa)
  747 + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)
734 748 ).
735 749  
736 750 public define HTML_Off_Form
... ... @@ -741,63 +755,118 @@ public define HTML_Off_Form
741 755 WEB_Action_Name action,
742 756 List((String,String)) extra_ops,
743 757 List(Web_arg) lwa,
744   - List(CXM_Form_Field) form_fields
  758 + List(CXM_Form_Field) form_fields,
  759 + String _class,
  760 + Bool b_with_label
745 761 )=
746   - cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields).
  762 + cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields, _class, b_with_label).
747 763  
748 764 public define HTML_Off_Form
749 765 cxm_form
750 766 (
751 767 String form_name,
752 768 List(CoreAttrs) options,
753   - String action,
  769 + WEB_Action_Name action,
754 770 List((String,String)) extra_ops,
755 771 List(Web_arg) lwa,
756 772 List(CXM_Form_Field) form_fields
757 773 )=
758   - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields).
  774 + cxm_form(form_name, options, action, extra_ops, lwa, form_fields, "form_field aligned", true)
  775 +.
759 776  
  777 +public define HTML_Off_Form
  778 + cxm_form
  779 + (
  780 + String form_name,
  781 + List(CoreAttrs) options,
  782 + String action,
  783 + List((String,String)) extra_ops,
  784 + List(Web_arg) lwa,
  785 + List(CXM_Form_Field) form_fields,
  786 +
  787 + Bool b_with_label
  788 + )=
  789 + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", b_with_label)
  790 +.
  791 +
  792 +public define HTML_Off_Form
  793 + cxm_form
  794 + (
  795 + String form_name,
  796 + List(CoreAttrs) options,
  797 + String action,
  798 + List((String,String)) extra_ops,
  799 + List(Web_arg) lwa,
  800 + List(CXM_Form_Field) form_fields
  801 + )=
  802 + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", true)
  803 +.
760 804  
761 805 public define HTML_Off_Form
762 806 cxm_form
763 807 (
764 808 String form_id,
765 809 List(CoreAttrs) options,
766   - List(HTML_In_Form) fields
  810 + List(HTML_In_Form) fields,
  811 + String _class
767 812 ) =
768   - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  813 + cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true )
  814 +.
769 815  
770 816 public define HTML_Off_Form
771 817 cxm_form
772 818 (
773   - String form_id,
  819 + String form_id,
774 820 List(CoreAttrs) options,
775   - List(Web_arg) lwa,
776   - List(CXM_Form_Field) fields
  821 + List(Web_arg) lwa,
  822 + List(CXM_Form_Field) fields,
  823 + String _class,
  824 + Bool b_with_label
777 825 ) =
778   - cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields).
  826 + cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields, _class, b_with_label).
779 827  
780 828 public define HTML_Off_Form
781 829 cxm_form
782 830 (
783   - String form_id,
784   - List(HTML_In_Form) fields
  831 + String form_id,
  832 + List(HTML_In_Form) fields,
  833 + String _class
785 834 ) =
786   - cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ).
  835 + cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ).
787 836  
788 837 public define HTML_Off_Form
789 838 cxm_form
790 839 (
791 840 String form_id,
792 841 List(Web_arg) lwa,
793   - List(CXM_Form_Field) fields
  842 + List(CXM_Form_Field) fields,
  843 + String _class
  844 + ) =
  845 + cxm_form(form_id, [], lwa, fields, _class, true).
  846 +
  847 +public define HTML_Off_Form
  848 + cxm_form
  849 + (
  850 + String form_id,
  851 + List(Web_arg) lwa,
  852 + List(CXM_Form_Field) fields,
794 853 ) =
795   - cxm_form(form_id, [], lwa, fields).
  854 + cxm_form(form_id, [], lwa, fields, "form_field aligned", true).
  855 +
796 856  
797 857 public define HTML_Off_Form
798 858 cxm_form
799 859 (
800 860 String form_id,
  861 + List(CXM_Form_Field) fields,
  862 + String _class
  863 + ) =
  864 + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, _class, true).
  865 +
  866 +public define HTML_Off_Form
  867 + cxm_form
  868 + (
  869 + String form_id,
801 870 List(CXM_Form_Field) fields
802 871 ) =
803   - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields).
  872 + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, "form_field aligned", true).
... ...