diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index 27ddaee..4ca15f3 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -97,17 +97,24 @@ public type CXM_Form_Field: Maybe(InitialValue) selected, Mandatory mandatory), - selector_c (List(InputAttrs) options, + 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), + + selector_hide_show (List(InputAttrs) options, String label, HtmlId id, WebArgName web_arg_name, Int size, - List((List(CoreAttrs),WebArgValue,String)) items, + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, Maybe(InitialValue) selected, Mandatory mandatory), - - //--- checkbox field ------------------------------------------------------------------ checkbox (List(InputAttrs) options, String label, @@ -321,6 +328,31 @@ public define CXM_Form_Field // ////////////////////////////////////////////////////////// +define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) + construct_selector_hide_show + ( + String div_id, + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, + List((List(CoreAttrs), WebArgValue, String)) so_far_1, + List(HTML_Partial_Content) so_far_2, + Int n + ) = + if items is + { + [] then (so_far_1, so_far_2), + [h . t] then + since h is (cores, wav, label, content), + with linked_element = div_id + n, + construct_selector_hide_show(div_id, t, [([data("linked_element", linked_element) . cores], wav, label) . so_far_1], [ partial_content([], div([id(linked_element), style("display: none")], content)) . so_far_2 ], n + 1) + }. + +define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) + construct_selector_hide_show + ( + String div_id, + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items + ) = construct_selector_hide_show(div_id, items, [], [], 0). + public define HTML_In_Form cxm_format_form_field ( @@ -407,6 +439,14 @@ public define HTML_In_Form success(default) then selector_c([class("in") . options], label + star(mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), }, + selector_hide_show(options, label, id, wan, size, items_with_partial, selected, mand) then + with div_id = generate_random_string(15), + since construct_selector_hide_show(div_id, items_with_partial) is (items, partial_content_list), + sequence([ + selector_c([class("in"), event(onchange, "select_hide_show('" + div_id + "', this);")], label + star(mand), id, wan, size, reverse(items), if selected is { failure then init(""), success(default) then init(get_String(lwa, wan.name, default.value)) } ), + partial(partial_content(partial_content_list)) + ]), + checkbox(options, label, id, wan, val, checked, mand) then check_box([class("in") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), diff --git a/web/widgets/left_menu.anubis b/web/widgets/left_menu.anubis index 3905cbb..5155c1a 100644 --- a/web/widgets/left_menu.anubis +++ b/web/widgets/left_menu.anubis @@ -41,11 +41,30 @@ public define Left_Menu_Entry . public define Left_Menu_Entry + left_menu_entry + ( + String entry_id, //it's also use as icon prefix + String action, //action (url to apply when click + String text, //text to show + List((String, String)) extra //extra web arguments to send when click + )= + left_menu_entry(entry_id, [], action, text, extra) + . + +public define Left_Menu_Entry title ( String text )= - title("", [], text). + title("", [], text). + +public define Left_Menu_Entry + title + ( + String title_id, + String text + )= + title(title_id, [], text). define List(HTML_Off_Form) make_left_menu -- libgit2 0.21.4