/* * Created by PyramIDE. * User: フランスのトトロ * Date: 07/12/2014 * Time: 16:49 * © Calexium */ // ************************************************************************************* // *** Generic form // ************************************************************************************* read tools/basis.anubis read system/string.anubis read calexium_lib/web/CXM_common.anubis read calexium_lib/web/CXM_making_a_web_site.anubis read calexium_lib/web/CXM_html_tooltip.anubis read calexium_lib/web/CXM_widgets.anubis public type Mandatory: // used to mark fields as mandatory. mandatory, non_mandatory. public type Width: small, narrow, wide, custom(Int). public type FormFieldWidth: auto, custom(Int). public type CXM_FormTooltip: tooltip(String title, String content, Int width). public type CXM_Form_Field: no_field, // empty field //--- title field --------------------------------------------------------------------- title (String text), // title (Int text_size, // String text), // title_f (List(Text_Option) -> HTML_In_Form), //--- message field ------------------------------------------------------------------- message (String text), //--- text input field ---------------------------------------------------------------- input (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, InitialValue init_value, Width width, Mandatory mandatory), input_readonly (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, InitialValue init_value, Width width), //--- text area field ----------------------------------------------------------------- text_area (List(TextAreaOption) options, String label, HtmlId id, WebArgName web_arg_name, InitialValue init_value, Width width, Int height, Mandatory mandatory), //--- password input field ------------------------------------------------------------ password_input (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, InitialValue init_value, Width width, Mandatory mandatory), //--- hidden field ------------------------------------------------------------ hidden (HtmlId id, WebArgName web_arg_name, InitialValue init_value), //--- explanation field --------------------------------------------------------------- explain (String text), //--- selector field ------------------------------------------------------------------ selector (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, Int size, List(String) items, Maybe(InitialValue) selected, Mandatory mandatory), selector_c (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, Int size, List((List(CoreAttrs),WebArgValue,String)) items, Maybe(InitialValue) selected, Mandatory mandatory), //--- checkbox field ------------------------------------------------------------------ checkbox (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, WebArgValue web_arg_value, Bool checked, Mandatory mandatory), // the same one, but with the tag on the right of the checkbox checkboxr (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, WebArgValue web_arg_value, Bool checked, Mandatory mandatory), //checkbox_hide_show checkbox_hide_show( List(InputAttrs) options, String label, WebArgName web_arg_name, WebArgValue web_arg_value, Bool checked, List(CXM_Form_Field) fields), //--- radio-button field -------------------------------------------------------------- radio_button (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, WebArgValue web_arg_value, Bool checked, Mandatory mandatory), // the same one, but with the tag on the right of the radio_button radio_buttonr (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, WebArgValue web_arg_value, Bool checked, Mandatory mandatory), radio_button_list (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, List((WebArgValue, String)) web_arg_value, Maybe(InitialValue) selected, Mandatory mandatory, Bool is_wide), // //--- fields table -------------------------------------------------------------------- // fields_table (String tag, // List(FormField) fields), // // //--- fields line --------------------------------------------------------------------- // fields_line (String tag, // List(FormField) fields), one_line_fields (List(CXM_Form_Field) fields), // // //--- preview field ------------------------------------------------------------------- // preview (String html_text), //--- upload field ------------------------------------------------------------------- upload (List(InputAttrs) options, String label, HtmlId id, WebArgName name, Width width, Mandatory mandatory), raw_in_form (HTML_In_Form html), raw_in_form (String label, HtmlId id, HTML_In_Form input), div (List(CoreAttrs), HTML_In_Form content), partial (HTML_Partial_Content p_content), input_with_help (CXM_Form_Field field, Maybe(String) help_title, String help_text, Int width), sub_fieldset (HTML_In_Form fieldset), blank_space, blank_space (HtmlClass class), //--- submit button ------------------------------------------------------------------- submit (List(CoreAttrs) options, HtmlClass class, String action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands), empty. // ////////////////////////////////////////////// // Alternative constructors: public define CXM_Form_Field input(WebArgName n, InitialValue init_value, Width width) = input([], "", htmlId(n.name), n, init_value, width, non_mandatory). public define CXM_Form_Field input(String label, WebArgName n, InitialValue init_value, Width width) = input([], label, htmlId(n.name), n, init_value, width, non_mandatory). public define CXM_Form_Field input(String label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) = input([], label, htmlId(n.name), n, init_value, width, mand). public define CXM_Form_Field input_readonly(String label, WebArgName n, InitialValue init_value, Width width) = input_readonly([], label, htmlId(n.name), n, init_value, width). public define CXM_Form_Field password_input(String label, WebArgName n, InitialValue init_value, Width width, Mandatory mand) = password_input([], label, htmlId(n.name), n, init_value, width, mand). public define CXM_Form_Field checkbox(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) = checkbox([], label, htmlId(n.name), n, value, checked, mand). public define CXM_Form_Field checkboxr(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) = checkboxr([], label, htmlId(n.name), n, value, checked, mand). public define CXM_Form_Field radio_button(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) = radio_button([], label, htmlId(n.name), n, value, checked, mand). public define CXM_Form_Field radio_buttonr(String label, WebArgName n, WebArgValue value, Bool checked, Mandatory mand) = radio_buttonr([], label, htmlId(n.name), n, value, checked, mand). public define CXM_Form_Field submit(String action_name, HtmlClass class, Maybe(String) label, String button_text, List((String,String)) extra_operands) = submit([], class, action_name, label, button_text, extra_operands). public define CXM_Form_Field submit(String action_name, Maybe(String) label, String button_text, List((String,String)) extra_operands) = submit([], htmlClass(""), action_name, label, button_text, extra_operands). public define CXM_Form_Field upload(String label, HtmlId id, WebArgName name, Width width) = upload([], label, id, name, width, non_mandatory). public define CXM_Form_Field upload(String label, HtmlId id, WebArgName name, Width width, Mandatory mand) = upload([], label, id, name, width, mand). public define CXM_Form_Field input_with_help (CXM_Form_Field field, String help_text) = input_with_help (field, failure, help_text, 250). public define CXM_Form_Field input_with_help (CXM_Form_Field field, String help_text, Int width) = input_with_help (field, failure, help_text, width). public define CXM_Form_Field ip_input ( String label, HtmlId id, WebArgName wan_prefix, String ip )= raw_in_form( label, id, ip_input(id, wan_prefix, ip) ). public define CXM_Form_Field partial_ip_input ( String label, HtmlId id, WebArgName wan_prefix, List(String) ip_fixed_part, String ip )= raw_in_form( label, id, partial_ip_input(id, wan_prefix, ip_fixed_part, ip) ). public define CXM_Form_Field hidden ( WebArgName web_arg_name, InitialValue init_value )= if web_arg_name is wan(name) then hidden(htmlId(name), web_arg_name, init_value). //--- explanation field --------------------- // ////////////////////////////////////////////////////////// public define HTML_In_Form cxm_format_form_field ( CXM_Form_Field ff ) = with star = (Mandatory m) |-> (String) if m is { mandatory then "*", non_mandatory then "" }, pixels = (Width width) |-> if width is { small then 10, narrow then 50, wide then 70, custom(n) then n }, // special case out of the div("inputable") tag. // if ff is submit(attrs, action_name, mb_label, button_text, extra_operands) then // mf_format_form_field_inside_inputable(ff, star, pixels) // else if ff is hidden(name, init) then // mf_format_form_field_inside_inputable(ff, star, pixels) // else if ff is sub_fieldset(fieldset) then // mf_format_form_field_inside_inputable(ff, star, pixels) // else // div([class("inputable")], // mf_format_form_field_inside_inputable(ff, star, pixels)) // sequence([ // literal("