Commit 3f69ca7ef6e03a7a4ecbf4513cda1446d8122d94
1 parent
36e23d45
Minor improvements on selectors
Showing
1 changed file
with
25 additions
and
12 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -915,7 +915,9 @@ public type Actioner_Aspect: |
| 915 | 915 | submit (List(CoreAttrs),String text), |
| 916 | 916 | button (String url_off, String url_on), // rollover button |
| 917 | 917 | button (String url_off, String url_on, Int32 w, Int32 h), // idem with size |
| 918 | - immediate_selector (String name, Int32 size, List(String) choices). | |
| 918 | + immediate_selector (WebArgName name, Int32 size, List((WebArgValue,String)) choices), | |
| 919 | + immediate_selector (WebArgName name, Int32 size, List((WebArgValue,String)) choices, String selected). | |
| 920 | + | |
| 919 | 921 | |
| 920 | 922 | |
| 921 | 923 | public type Actioner_Local_Action: |
| ... | ... | @@ -989,13 +991,13 @@ public type HTML_In_Form: |
| 989 | 991 | password_input (List(InputAttrs), String label_text, HtmlId id, WebArgName name, InitialValue init, Int32 width), |
| 990 | 992 | text_area (List(TextAreaOption), String name, String init, Int32 width, Int32 height), |
| 991 | 993 | file_upload (String label, HtmlId id, WebArgName name, Int32 width), |
| 992 | - selector (String name, Int32 size, List(String) choices), | |
| 993 | - selector (String name, Int32 size, List(String) choices, String selected), | |
| 994 | + selector (WebArgName name, Int32 size, List(String) choices), | |
| 995 | + selector (WebArgName name, Int32 size, List(String) choices, String selected), | |
| 994 | 996 | // List((String,String)) = List((code,name)) where : |
| 995 | - // name appears in selector | |
| 996 | 997 | // code is the web-arg value |
| 997 | - selector_c (String name, Int32 size, List((String,String)) choices), | |
| 998 | - selector_c (String name, Int32 size, List((String,String)) choices, String selected), | |
| 998 | + // name appears in selector | |
| 999 | + selector_c (WebArgName name, Int32 size, List((WebArgValue,String)) choices), | |
| 1000 | + selector_c (WebArgName name, Int32 size, List((WebArgValue,String)) choices, String selected), | |
| 999 | 1001 | radio_button (List(InputAttrs), String label_text, HtmlId id, WebArgName name, WebArgValue value, Bool checked), |
| 1000 | 1002 | radio_button_r (List(InputAttrs), String label_text, HtmlId id, WebArgName name, WebArgValue value, Bool checked), |
| 1001 | 1003 | check_box (List(InputAttrs), String label_text, HtmlId id, WebArgName name, WebArgValue value, Bool checked), |
| ... | ... | @@ -2676,20 +2678,20 @@ public define Printable_tree |
| 2676 | 2678 | public define Printable_tree |
| 2677 | 2679 | format_choices |
| 2678 | 2680 | ( |
| 2679 | - List((String,String)) l | |
| 2681 | + List((WebArgValue,String)) l | |
| 2680 | 2682 | ) = |
| 2681 | 2683 | if l is |
| 2682 | 2684 | { |
| 2683 | 2685 | [ ] then [ ], |
| 2684 | 2686 | [h . t] then |
| 2685 | 2687 | if h is (val,item) |
| 2686 | - then ["<option value=\""+val+"\">",item . format_choices(t)] | |
| 2688 | + then ["<option value=\""+val.value+"\">",item . format_choices(t)] | |
| 2687 | 2689 | }. |
| 2688 | 2690 | |
| 2689 | 2691 | public define Printable_tree |
| 2690 | 2692 | format_choices |
| 2691 | 2693 | ( |
| 2692 | - List((String,String)) l, | |
| 2694 | + List((WebArgValue,String)) l, | |
| 2693 | 2695 | String selected |
| 2694 | 2696 | ) = |
| 2695 | 2697 | if l is |
| ... | ... | @@ -2698,8 +2700,8 @@ public define Printable_tree |
| 2698 | 2700 | [h . t] then |
| 2699 | 2701 | if h is (val,item) then |
| 2700 | 2702 | if item = selected |
| 2701 | - then ["<option value=\""+val+"\" selected>",item . format_choices(t)] | |
| 2702 | - else ["<option value=\""+val+"\">",item . format_choices(t,selected)] | |
| 2703 | + then ["<option value=\""+val.value+"\" selected>",item . format_choices(t)] | |
| 2704 | + else ["<option value=\""+val.value+"\">",item . format_choices(t,selected)] | |
| 2703 | 2705 | }. |
| 2704 | 2706 | |
| 2705 | 2707 | |
| ... | ... | @@ -3038,6 +3040,7 @@ define Maybe(String) |
| 3038 | 3040 | button(_,_) then failure, |
| 3039 | 3041 | button(_,_,_,_) then failure, |
| 3040 | 3042 | immediate_selector(_,_,_) then failure, |
| 3043 | + immediate_selector(_,_,_,_) then failure, | |
| 3041 | 3044 | }. |
| 3042 | 3045 | |
| 3043 | 3046 | define Printable_tree |
| ... | ... | @@ -3131,7 +3134,16 @@ define Printable_tree |
| 3131 | 3134 | }, |
| 3132 | 3135 | "\" name=o",name," size=",size,">", |
| 3133 | 3136 | format_choices(choices),"</select>" |
| 3134 | - ] | |
| 3137 | + ], | |
| 3138 | + immediate_selector(name,size,choices,selected) then | |
| 3139 | + [ if action is | |
| 3140 | + { | |
| 3141 | + url(u) then ["<select href=\"",u] | |
| 3142 | + javascript(s,h) then [s,"<select onchange=\"",h] | |
| 3143 | + }, | |
| 3144 | + "\" name=o",name," size=",size,">", | |
| 3145 | + format_choices(choices, selected),"</select>" | |
| 3146 | + ], | |
| 3135 | 3147 | }. |
| 3136 | 3148 | |
| 3137 | 3149 | |
| ... | ... | @@ -3168,6 +3180,7 @@ define Printable_tree |
| 3168 | 3180 | ], |
| 3169 | 3181 | |
| 3170 | 3182 | immediate_selector(name,size,choices) then alert, |
| 3183 | + immediate_selector(name,size,choices,selected) then alert, | |
| 3171 | 3184 | |
| 3172 | 3185 | }, |
| 3173 | 3186 | "</a>"]. | ... | ... |