From 5f5eba12df642d967e7320dfd75f534b7e2b8b8a Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 29 Apr 2017 09:13:31 +0900 Subject: [PATCH] add option to not show label with the CXM_Form_Field --- web/CXM_form.anubis | 269 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------- 1 file changed, 169 insertions(+), 100 deletions(-) diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index b2038fe..2f55e4d 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -417,38 +417,48 @@ define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content) public define HTML_In_Form format_div_CXM_Form_Field ( - CXM_Form_Field field, - List(Web_arg) lwa, - String _class + List(CXM_Form_Field) field, + List(Web_arg) lwa, + String _class, + Bool b_with_label ). - + + public define HTML_In_Form format_CXM_Form_Field ( - CXM_Form_Field ff, - List(Web_arg) lwa + CXM_Form_Field ff, //CXM_Form_Field to format + List(Web_arg) lwa, //web arguments of the session, can be useful for the current drawing + String _class, + Bool b_with_label //if false, no need to show/generate label ) = - with star = (HTML_Label l, Mandatory m) |-> (HTML_Label) - if m is - { - mandatory then - if l is - { - no_label then l, - label(str, help) then label(str + "*", help), - } - - non_mandatory then l - }, - pixels = (Width width) |-> - if width is - { - small then 10, - narrow_small then 20, - narrow then 50, - wide then 70, - custom(n) then n - }, + with star = (HTML_Label l, Mandatory m) + |-> + (HTML_Label) + if b_with_label then + if m is + { + mandatory then + if l is + { + no_label then l, + label(str, help) then label(str + "*", help), + } + non_mandatory then l + } + else + no_label + , + pixels = (Width width) + |-> + if width is + { + small then 10, + narrow_small then 20, + narrow then 50, + wide then 70, + custom(n) then n + }, if ff is @@ -512,7 +522,7 @@ public define HTML_In_Form with div_id = generate_random_string(15), sequence([ 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)), - 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))) + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) ]), radio_button(options, _label, id, wan, val, checked, mand) then @@ -522,7 +532,7 @@ public define HTML_In_Form with div_id = generate_random_string(15), sequence([ 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)), - 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))) + div([id(div_id), style("display:"+if checked then "block" else "none")], format_div_CXM_Form_Field(fields, lwa, _class, b_with_label)) ]), radio_buttonr(options, _label, id, wan, val, checked, mand) then @@ -552,7 +562,7 @@ public define HTML_In_Form ]), one_line_fields(fields) then table([nude, class("form_one_line")],[row([], - map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa)),fields))]) + map((CXM_Form_Field ff2) |-> cell([],format_CXM_Form_Field(ff2, lwa, _class, b_with_label)),fields))]) , upload(options, _label, id, name, w, mand) then @@ -580,7 +590,7 @@ public define HTML_In_Form sequence([ literal(""), literal(if length(legend) > 0 then "" + legend + "" else ""), - sequence( map((CXM_Form_Field ffield) |-> format_div_CXM_Form_Field(ffield, lwa, "form_field"), fields) ), + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label), literal("") ]), @@ -604,92 +614,93 @@ public define HTML_In_Form empty then literal("") }. -public define HTML_In_Form + public define HTML_In_Form format_div_CXM_Form_Field ( CXM_Form_Field field, List(Web_arg) lwa, - String _class + String _class, + Bool b_with_label )= if field is empty then empty else if field is no_field then empty else if field is hidden(id, name, init) then - format_CXM_Form_Field(field, lwa) + format_CXM_Form_Field(field, lwa, _class, b_with_label) else if field is br then - format_CXM_Form_Field(field, lwa) + format_CXM_Form_Field(field, lwa, _class, b_with_label) else if field is text_area(options, _label, id, wan, default, w, height, mand) then - div([], format_CXM_Form_Field(field, lwa)) + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label)) else - div([class(_class)], format_CXM_Form_Field(field, lwa)) + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) . + + public define HTML_In_Form - format_CXM_Form_Field + format_div_CXM_Form_Field ( List(CXM_Form_Field) fields, - List(Web_arg) lwa + List(Web_arg) lwa, + String _class, + Bool b_with_label )= - sequence( map((CXM_Form_Field ff) + //println("format_div_CXM_Form_Field"); + sequence( map((CXM_Form_Field field) |-> - format_div_CXM_Form_Field(ff, lwa, "form_field aligned"), fields)) + //with css_line = if line = 0 then " odd_line" else " even_line", + //println("class "+css_line+" line "+line); + if field is empty then + empty + else if field is no_field then + empty + else if field is hidden(id, name, init) then + format_CXM_Form_Field(field, lwa, _class, b_with_label) + else if field is br then + format_CXM_Form_Field(field, lwa, _class, b_with_label) + else if field is text_area(options, _label, id, wan, default, w, height, mand) then + div([], format_CXM_Form_Field(field, lwa, _class, b_with_label)) + else + div([class(_class)], format_CXM_Form_Field(field, lwa, _class, b_with_label)) + , fields)) . public define HTML_In_Form - fieldset + to_HTML_In_Form ( - List(Web_arg) lwa, List(CXM_Form_Field) fields, + List(Web_arg) lwa, + String _class, + Bool b_with_label )= - sequence( map((CXM_Form_Field ff) |-> - if ff is empty then - empty - else if ff is no_field then - empty - else if ff is hidden(id, name, init) then - format_CXM_Form_Field(ff, lwa) - else if ff is br then - format_CXM_Form_Field(ff, lwa) - else - div([class("form_field aligned")], format_CXM_Form_Field(ff, lwa)), fields) ). + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) +. -public define HTML_In_Form + "form_field aligned" + + public define HTML_In_Form fieldset ( - List(Web_arg) lwa, CXM_Form_Field field, + List(Web_arg) lwa, + String _class, + Bool b_with_label )= - if field is empty then - empty - else if field is no_field then - empty - else if field is hidden(id, name, init) then - format_CXM_Form_Field(field, lwa) - else if field is br then - format_CXM_Form_Field(field, lwa) - else - div([class("form_field aligned")], format_CXM_Form_Field(field, lwa)) + fieldset([field], lwa, _class, b_with_label) . public define HTML_In_Form - fieldset + to_HTML_In_Form ( - List(CXM_Form_Field) fields + List(CXM_Form_Field) fields, + String _class, + Bool b_with_label )= - sequence( map((CXM_Form_Field ff) |-> - if ff is empty then - empty - else if ff is no_field then - empty - else if ff is hidden(id, name, init) then - format_CXM_Form_Field(ff, []) - else if ff is br then - format_CXM_Form_Field(ff, []) - else - div([class("form_field aligned")], format_CXM_Form_Field(ff, [])), fields) ). + to_HTML_In_Form(fields, [], _class, b_with_label). +public public define HTML_Off_Form cxm_form @@ -699,15 +710,16 @@ public define HTML_Off_Form WEB_Action_Name action, List((String,String)) extra_ops, List(Web_arg) lwa, - List(CXM_Form_Field) fields + List(CXM_Form_Field) fields, + String _class, + Bool b_with_label ) = - form( form_Id, [class("cxm_form") . options], action, extra_ops, - format_CXM_Form_Field(fields, lwa) + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) ). public define HTML_Off_Form @@ -722,7 +734,9 @@ public define HTML_Off_Form String action, //older manner to call action with String List((String,String)) extra_ops, List(Web_arg) lwa, - List(CXM_Form_Field) fields + List(CXM_Form_Field) fields, + String _class, + Bool b_with_label ) = form( @@ -730,7 +744,7 @@ public define HTML_Off_Form [class("cxm_form") . options], action_name(action), extra_ops, - format_CXM_Form_Field(fields, lwa) + format_div_CXM_Form_Field(fields, lwa, _class, b_with_label) ). public define HTML_Off_Form @@ -741,63 +755,118 @@ public define HTML_Off_Form WEB_Action_Name action, List((String,String)) extra_ops, List(Web_arg) lwa, - List(CXM_Form_Field) form_fields + List(CXM_Form_Field) form_fields, + String _class, + Bool b_with_label )= - cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields). + cxm_form(html_Id(form_name), options, action, extra_ops, lwa, form_fields, _class, b_with_label). public define HTML_Off_Form cxm_form ( String form_name, List(CoreAttrs) options, - String action, + WEB_Action_Name action, List((String,String)) extra_ops, List(Web_arg) lwa, List(CXM_Form_Field) form_fields )= - cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields). + cxm_form(form_name, options, action, extra_ops, lwa, form_fields, "form_field aligned", true) +. +public define HTML_Off_Form + cxm_form + ( + String form_name, + List(CoreAttrs) options, + String action, + List((String,String)) extra_ops, + List(Web_arg) lwa, + List(CXM_Form_Field) form_fields, + + Bool b_with_label + )= + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", b_with_label) +. + +public define HTML_Off_Form + cxm_form + ( + String form_name, + List(CoreAttrs) options, + String action, + List((String,String)) extra_ops, + List(Web_arg) lwa, + List(CXM_Form_Field) form_fields + )= + cxm_form(html_Id(form_name), options, action_name(action), extra_ops, lwa, form_fields, "form_field aligned", true) +. public define HTML_Off_Form cxm_form ( String form_id, List(CoreAttrs) options, - List(HTML_In_Form) fields + List(HTML_In_Form) fields, + String _class ) = - cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ). + cxm_form(html_Id(form_id), options, action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ) +. public define HTML_Off_Form cxm_form ( - String form_id, + String form_id, List(CoreAttrs) options, - List(Web_arg) lwa, - List(CXM_Form_Field) fields + List(Web_arg) lwa, + List(CXM_Form_Field) fields, + String _class, + Bool b_with_label ) = - cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields). + cxm_form(html_Id(form_id), options, action_name(""), [], lwa, fields, _class, b_with_label). public define HTML_Off_Form cxm_form ( - String form_id, - List(HTML_In_Form) fields + String form_id, + List(HTML_In_Form) fields, + String _class ) = - cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields) ). + cxm_form(html_Id(form_id), [], action_name(""), [], [], map((HTML_In_Form field) |-> raw_in_form(field), fields), _class, true ). public define HTML_Off_Form cxm_form ( String form_id, List(Web_arg) lwa, - List(CXM_Form_Field) fields + List(CXM_Form_Field) fields, + String _class + ) = + cxm_form(form_id, [], lwa, fields, _class, true). + +public define HTML_Off_Form + cxm_form + ( + String form_id, + List(Web_arg) lwa, + List(CXM_Form_Field) fields, ) = - cxm_form(form_id, [], lwa, fields). + cxm_form(form_id, [], lwa, fields, "form_field aligned", true). + public define HTML_Off_Form cxm_form ( String form_id, + List(CXM_Form_Field) fields, + String _class + ) = + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, _class, true). + +public define HTML_Off_Form + cxm_form + ( + String form_id, List(CXM_Form_Field) fields ) = - cxm_form(html_Id(form_id), [], action_name(""), [], [], fields). + cxm_form(html_Id(form_id), [], action_name(""), [], [], fields, "form_field aligned", true). -- libgit2 0.21.4