From 5e5890497943ea4f8d511dedba0809e84b4b36f5 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 2 Apr 2016 15:52:13 +0200 Subject: [PATCH] replace sub_fielset by fieldset harmonize cxm_form arguments --- web/CXM_form.anubis | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------- web/CXM_making_a_web_site.anubis | 36 ++++++++++++++++++------------------ 2 files changed, 115 insertions(+), 92 deletions(-) diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index 4ca15f3..cc1c3aa 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -207,7 +207,9 @@ public type CXM_Form_Field: String help_text, Int width), - sub_fieldset (HTML_In_Form fieldset), + fieldset (List(CoreAttrs) options, + String legend, + List(CXM_Form_Field) fields), blank_space, blank_space (HtmlClass class), @@ -222,9 +224,32 @@ public type CXM_Form_Field: empty. // ////////////////////////////////////////////// -// Alternative constructors: +// Alternate constructors: public define CXM_Form_Field + fieldset + ( + HtmlId fieldSetId, + List(CXM_Form_Field) fields + ) = + fieldset([id(fieldSetId.id)], "", fields). + +public define CXM_Form_Field + fieldset + ( + List(CXM_Form_Field) fields + ) = + fieldset([], "", fields). + +public define CXM_Form_Field + fieldset + ( + String legend, + List(CXM_Form_Field) fields + ) = + fieldset([], legend, fields). + +public define CXM_Form_Field input(WebArgName n, InitialValue init_value, Width width) = input([], "", htmlId(n.name), n, init_value, width, non_mandatory). @@ -354,7 +379,7 @@ define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content) ) = construct_selector_hide_show(div_id, items, [], [], 0). public define HTML_In_Form - cxm_format_form_field + format_CXM_Form_Field ( CXM_Form_Field ff, List(Web_arg) lwa @@ -457,7 +482,7 @@ public define HTML_In_Form with div_id = generate_random_string(15), sequence([ check_box([class("in"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)), - 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))) + 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))) ]), radio_button(options, label, id, wan, val, checked, mand) then @@ -467,7 +492,7 @@ public define HTML_In_Form with div_id = generate_random_string(15), sequence([ 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)), - 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))) + 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))) ]), radio_buttonr(options, label, id, wan, val, checked, mand) then @@ -497,7 +522,7 @@ public define HTML_In_Form ]), one_line_fields(fields) then table([nude],[row([], - map((CXM_Form_Field ff2) |-> cell([],cxm_format_form_field(ff2, lwa)),fields))]) + map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))]) , upload(options, label, id, name, w, mand) then @@ -509,17 +534,27 @@ public define HTML_In_Form sequence([ if id is htmlId(_id) then literal(""), - input]), - div(options, e) then div(options, e), - partial(p_content) then partial(p_content), + input + ]), + + div(options, e) then div(options, e), + + partial(p_content) then partial(p_content), + input_with_help(input, help_title, help_text, width) then sequence([ - cxm_format_form_field(input, lwa), + format_CXM_Form_Field(input, lwa), html_tooltip(force_String(help_title), help_text, width), ]), - sub_fieldset(fieldset) then fieldset, - + fieldset(options, legend, fields) then + sequence([ + literal(""), + literal(if length(legend) > 0 then "" + legend + "" else ""), + sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], format_CXM_Form_Field(ff, lwa)), fields) ), + literal("") + ]), + blank_space then div([class("blank_space")], literal(" ")), @@ -541,30 +576,32 @@ public define HTML_In_Form }. public define HTML_In_Form - cxm_fieldset + format_CXM_Form_Field ( - List(CoreAttrs) options, - String legend, - List(Web_arg) lwa, - List(CXM_Form_Field) fields + List(CXM_Form_Field) fields, + List(Web_arg) lwa )= - sequence([ - literal(""), - literal(if length(legend) > 0 then "" + legend + "" else ""), - sequence( map((CXM_Form_Field ff) |-> div([class("form_field")], cxm_format_form_field(ff, lwa)), fields) ), - literal("")] - ) - . - -public define HTML_In_Form - cxm_fieldset + sequence( map((CXM_Form_Field ff) |-> div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ). + +public define HTML_Off_Form + cxm_form ( - HtmlId fieldSetId, + HtmlId form_Id, + List(CoreAttrs) options, + String action_name, + List((String,String)) extra_ops, List(Web_arg) lwa, List(CXM_Form_Field) fields ) = - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields). - + + form( + form_Id, + [class("cxm_form") . options], + action_name, + extra_ops, + format_CXM_Form_Field(fields, lwa) + ). + public define HTML_Off_Form cxm_form ( @@ -572,76 +609,62 @@ public define HTML_Off_Form List(CoreAttrs) options, String action_name, List((String,String)) extra_ops, - List(HTML_In_Form) fieldSets + List(Web_arg) lwa, + List(CXM_Form_Field) form_fields )= - //div([class("formulaire")], - form( form_name, - [class("formulaire") . options], - action_name, - extra_ops, - sequence( fieldSets ) - // ) - ). + cxm_form(htmlId(form_name), options, action_name, extra_ops, lwa, form_fields). + + public define HTML_In_Form + cxm_fieldset + ( + HtmlId fieldSetId, + List(Web_arg) lwa, + List(CXM_Form_Field) fields + ) = + cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields). + + public define HTML_Off_Form cxm_form ( - String form_name, + String form_id, List(CoreAttrs) options, - List(HTML_In_Form) fieldSets + List(HTML_In_Form) fields ) = - //div([class("formulaire")], - form( form_name, - [class("formulaire") . options], - sequence( fieldSets ) - // ) - ). + cxm_form(htmlId(form_id), options, "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ). public define HTML_Off_Form cxm_form ( - String form_name, + String form_id, List(CoreAttrs) options, - HtmlId fieldSetId, - String action_name, - List((String,String)) extra_ops, - List(Web_arg) lwa, + List(Web_arg) lwa, List(CXM_Form_Field) fields ) = - cxm_form(form_name, options, action_name, extra_ops, - [ - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields) - ]). - + cxm_form(htmlId(form_id), options, "", [], lwa, fields). + public define HTML_Off_Form cxm_form ( - String form_name, - List(CoreAttrs) options, - HtmlId fieldSetId, - List(Web_arg) lwa, - List(CXM_Form_Field) fields + String form_id, + List(HTML_In_Form) fields ) = - cxm_form(form_name, options, - [ - cxm_fieldset([id(fieldSetId.id), class("aligned")], "", lwa, fields) - ]). + cxm_form(htmlId(form_id), [], "", [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ). public define HTML_Off_Form cxm_form ( - String form_name, - List(HTML_In_Form) fieldSets + String form_id, + List(Web_arg) lwa, + List(CXM_Form_Field) fields ) = - cxm_form(form_name, [], fieldSets). + cxm_form(form_id, [], lwa, fields). public define HTML_Off_Form cxm_form ( - String form_name, - HtmlId fieldSetId, - List(Web_arg) lwa, + String form_id, List(CXM_Form_Field) fields ) = - cxm_form(form_name, [], fieldSetId, lwa, fields). - + cxm_form(htmlId(form_id), [], "", [], [], fields). diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index b107db7..16db090 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -4207,42 +4207,42 @@ define Printable_tree format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https, action_count, head_tags), text_input(options, label_text, id, name, i, w) then [ maybe_label(label_text, id), - ""], + ""], text_input_ro(options, label_text, id, name,i,w) then [ maybe_label(label_text, id), - ""], + ""], password_input(options, label_text, id, name,i,w) then [ maybe_label(label_text, id), - ""], - text_area(opts,label_text, id, n,i,w,h) then - [ maybe_label(label_text, id), ""], + ""], + text_area(options,label_text, id, n,i,w,h) then + [ maybe_label(label_text, id), ""], file_upload(options, label, id, n, w) then [ maybe_label(label, id), - ""], - selector(opts, label, id, n,s,cs) then + ""], + selector(options, label, id, n,s,cs) then [ maybe_label(label, id), - ""], - selector(opts, label, id, n,s,cs,sd) then + ""], + selector(options, label, id, n,s,cs,sd) then [ maybe_label(label, id), - ""], - selector_c(opts, label, id, n,s,cs) then + ""], + selector_c(options, label, id, n,s,cs) then [ maybe_label(label, id), - ""], - selector_c(opts, label, id, n,s,cs,sd) then + ""], + selector_c(options, label, id, n,s,cs,sd) then [ maybe_label(label, id), - ""], + ""], radio_button(options, label_text, id, n, v, c) then [ maybe_label(label_text, id), - ""], + ""], radio_button_r(options, label_text, id, n, v, c) then - [ "", + [ "", maybe_label(label_text, id)], check_box(options, label_text, id, n, v, c) then [ maybe_label(label_text, id), - ""] + ""] check_box_r(options, label_text, id, n, v, c) then - [ "", + [ "", maybe_label(label_text, id)] div(options, e) then format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https, action_count, head_tags), -- libgit2 0.21.4