Commit 90042c30195c4ce3a97d3b35726799695c6c66f3
1 parent
4e1f9778
add "selector_hide_show" to show/hide elements when the selection change
add helper functions due to the addition of class list as parameter to "left_menu_entry" and "title"
Showing
2 changed files
with
64 additions
and
5 deletions
Show diff stats
web/CXM_form.anubis
| @@ -97,17 +97,24 @@ public type CXM_Form_Field: | @@ -97,17 +97,24 @@ public type CXM_Form_Field: | ||
| 97 | Maybe(InitialValue) selected, | 97 | Maybe(InitialValue) selected, |
| 98 | Mandatory mandatory), | 98 | Mandatory mandatory), |
| 99 | 99 | ||
| 100 | - selector_c (List(InputAttrs) options, | 100 | + selector_c (List(InputAttrs) options, |
| 101 | + String label, | ||
| 102 | + HtmlId id, | ||
| 103 | + WebArgName web_arg_name, | ||
| 104 | + Int size, | ||
| 105 | + List((List(CoreAttrs), WebArgValue, String)) items, | ||
| 106 | + Maybe(InitialValue) selected, | ||
| 107 | + Mandatory mandatory), | ||
| 108 | + | ||
| 109 | + selector_hide_show (List(InputAttrs) options, | ||
| 101 | String label, | 110 | String label, |
| 102 | HtmlId id, | 111 | HtmlId id, |
| 103 | WebArgName web_arg_name, | 112 | WebArgName web_arg_name, |
| 104 | Int size, | 113 | Int size, |
| 105 | - List((List(CoreAttrs),WebArgValue,String)) items, | 114 | + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, |
| 106 | Maybe(InitialValue) selected, | 115 | Maybe(InitialValue) selected, |
| 107 | Mandatory mandatory), | 116 | Mandatory mandatory), |
| 108 | 117 | ||
| 109 | - | ||
| 110 | - | ||
| 111 | //--- checkbox field ------------------------------------------------------------------ | 118 | //--- checkbox field ------------------------------------------------------------------ |
| 112 | checkbox (List(InputAttrs) options, | 119 | checkbox (List(InputAttrs) options, |
| 113 | String label, | 120 | String label, |
| @@ -321,6 +328,31 @@ public define CXM_Form_Field | @@ -321,6 +328,31 @@ public define CXM_Form_Field | ||
| 321 | 328 | ||
| 322 | // ////////////////////////////////////////////////////////// | 329 | // ////////////////////////////////////////////////////////// |
| 323 | 330 | ||
| 331 | +define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) | ||
| 332 | + construct_selector_hide_show | ||
| 333 | + ( | ||
| 334 | + String div_id, | ||
| 335 | + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items, | ||
| 336 | + List((List(CoreAttrs), WebArgValue, String)) so_far_1, | ||
| 337 | + List(HTML_Partial_Content) so_far_2, | ||
| 338 | + Int n | ||
| 339 | + ) = | ||
| 340 | + if items is | ||
| 341 | + { | ||
| 342 | + [] then (so_far_1, so_far_2), | ||
| 343 | + [h . t] then | ||
| 344 | + since h is (cores, wav, label, content), | ||
| 345 | + with linked_element = div_id + n, | ||
| 346 | + 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) | ||
| 347 | + }. | ||
| 348 | + | ||
| 349 | +define (List((List(CoreAttrs), WebArgValue, String)), List(HTML_Partial_Content)) | ||
| 350 | + construct_selector_hide_show | ||
| 351 | + ( | ||
| 352 | + String div_id, | ||
| 353 | + List((List(CoreAttrs), WebArgValue, String, HTML_Partial_Content)) items | ||
| 354 | + ) = construct_selector_hide_show(div_id, items, [], [], 0). | ||
| 355 | + | ||
| 324 | public define HTML_In_Form | 356 | public define HTML_In_Form |
| 325 | cxm_format_form_field | 357 | cxm_format_form_field |
| 326 | ( | 358 | ( |
| @@ -407,6 +439,14 @@ public define HTML_In_Form | @@ -407,6 +439,14 @@ public define HTML_In_Form | ||
| 407 | success(default) then selector_c([class("in") . options], label + star(mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), | 439 | success(default) then selector_c([class("in") . options], label + star(mand), id, wan, size, items, init(get_String(lwa, wan.name, default.value))), |
| 408 | }, | 440 | }, |
| 409 | 441 | ||
| 442 | + selector_hide_show(options, label, id, wan, size, items_with_partial, selected, mand) then | ||
| 443 | + with div_id = generate_random_string(15), | ||
| 444 | + since construct_selector_hide_show(div_id, items_with_partial) is (items, partial_content_list), | ||
| 445 | + sequence([ | ||
| 446 | + 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)) } ), | ||
| 447 | + partial(partial_content(partial_content_list)) | ||
| 448 | + ]), | ||
| 449 | + | ||
| 410 | checkbox(options, label, id, wan, val, checked, mand) then | 450 | checkbox(options, label, id, wan, val, checked, mand) then |
| 411 | check_box([class("in") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), | 451 | check_box([class("in") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), |
| 412 | 452 |
web/widgets/left_menu.anubis
| @@ -41,11 +41,30 @@ public define Left_Menu_Entry | @@ -41,11 +41,30 @@ public define Left_Menu_Entry | ||
| 41 | . | 41 | . |
| 42 | 42 | ||
| 43 | public define Left_Menu_Entry | 43 | public define Left_Menu_Entry |
| 44 | + left_menu_entry | ||
| 45 | + ( | ||
| 46 | + String entry_id, //it's also use as icon prefix | ||
| 47 | + String action, //action (url to apply when click | ||
| 48 | + String text, //text to show | ||
| 49 | + List((String, String)) extra //extra web arguments to send when click | ||
| 50 | + )= | ||
| 51 | + left_menu_entry(entry_id, [], action, text, extra) | ||
| 52 | + . | ||
| 53 | + | ||
| 54 | +public define Left_Menu_Entry | ||
| 44 | title | 55 | title |
| 45 | ( | 56 | ( |
| 46 | String text | 57 | String text |
| 47 | )= | 58 | )= |
| 48 | - title("", [], text). | 59 | + title("", [], text). |
| 60 | + | ||
| 61 | +public define Left_Menu_Entry | ||
| 62 | + title | ||
| 63 | + ( | ||
| 64 | + String title_id, | ||
| 65 | + String text | ||
| 66 | + )= | ||
| 67 | + title(title_id, [], text). | ||
| 49 | 68 | ||
| 50 | define List(HTML_Off_Form) | 69 | define List(HTML_Off_Form) |
| 51 | make_left_menu | 70 | make_left_menu |