Commit 2956d18a255ba4803f9ad890f5b2464c63fd2eb2
1 parent
bd400dd2
Adding table footer row
Showing
1 changed file
with
78 additions
and
22 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| @@ -864,6 +864,10 @@ public type HTML_Row($T): | @@ -864,6 +864,10 @@ public type HTML_Row($T): | ||
| 864 | public type HTML_Header_Row($T): | 864 | public type HTML_Header_Row($T): |
| 865 | empty, | 865 | empty, |
| 866 | header_row(List(Cell_Option) options, List(HTML_Header_Cell($T)) cells). | 866 | header_row(List(Cell_Option) options, List(HTML_Header_Cell($T)) cells). |
| 867 | + | ||
| 868 | +public type HTML_Footer_Row($T): | ||
| 869 | + empty, | ||
| 870 | + footer_row(List(Cell_Option) options, List(HTML_Cell($T)) cells). | ||
| 867 | 871 | ||
| 868 | Same remark as for 'HTML_Cell($T)'. We define several convenience functions: | 872 | Same remark as for 'HTML_Cell($T)'. We define several convenience functions: |
| 869 | 873 | ||
| @@ -974,7 +978,7 @@ public type HTML_In_Form: | @@ -974,7 +978,7 @@ public type HTML_In_Form: | ||
| 974 | paragraph (List(Text_Option), HTML_In_Form content), | 978 | paragraph (List(Text_Option), HTML_In_Form content), |
| 975 | image (String url), | 979 | image (String url), |
| 976 | image (String url, Int32 width, Int32 height), | 980 | image (String url, Int32 width, Int32 height), |
| 977 | - table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form))), | 981 | + table (List(Table_Option), HTML_Header_Row(HTML_In_Form), List(HTML_Row(HTML_In_Form)), HTML_Footer_Row(HTML_In_Form)), |
| 978 | center (HTML_In_Form), | 982 | center (HTML_In_Form), |
| 979 | mail_to (String email, HTML_In_Form element), | 983 | mail_to (String email, HTML_In_Form element), |
| 980 | scroller (Int32 width, Int32 height, | 984 | scroller (Int32 width, Int32 height, |
| @@ -1058,15 +1062,15 @@ public define HTML_In_Form | @@ -1058,15 +1062,15 @@ public define HTML_In_Form | ||
| 1058 | ( | 1062 | ( |
| 1059 | List(HTML_Row(HTML_In_Form)) rows | 1063 | List(HTML_Row(HTML_In_Form)) rows |
| 1060 | ) = | 1064 | ) = |
| 1061 | - table([],empty,rows). | 1065 | + table([],empty,rows,empty). |
| 1062 | 1066 | ||
| 1063 | public define HTML_In_Form | 1067 | public define HTML_In_Form |
| 1064 | table | 1068 | table |
| 1065 | ( | 1069 | ( |
| 1066 | - List(Table_Option) options, | ||
| 1067 | - List(HTML_Row(HTML_In_Form)) rows | 1070 | + List(Table_Option) options, |
| 1071 | + List(HTML_Row(HTML_In_Form)) rows | ||
| 1068 | ) = | 1072 | ) = |
| 1069 | - table(options,empty,rows). | 1073 | + table(options,empty,rows,empty). |
| 1070 | 1074 | ||
| 1071 | public define HTML_In_Form | 1075 | public define HTML_In_Form |
| 1072 | table | 1076 | table |
| @@ -1074,7 +1078,16 @@ public define HTML_In_Form | @@ -1074,7 +1078,16 @@ public define HTML_In_Form | ||
| 1074 | HTML_Header_Row(HTML_In_Form) h_row, | 1078 | HTML_Header_Row(HTML_In_Form) h_row, |
| 1075 | List(HTML_Row(HTML_In_Form)) rows | 1079 | List(HTML_Row(HTML_In_Form)) rows |
| 1076 | ) = | 1080 | ) = |
| 1077 | - table([],h_row,rows). | 1081 | + table([],h_row,rows,empty). |
| 1082 | + | ||
| 1083 | +public define HTML_In_Form | ||
| 1084 | + table | ||
| 1085 | + ( | ||
| 1086 | + List(Table_Option) options, | ||
| 1087 | + HTML_Header_Row(HTML_In_Form) h_row, | ||
| 1088 | + List(HTML_Row(HTML_In_Form)) rows | ||
| 1089 | + ) = | ||
| 1090 | + table(options,h_row,rows,empty). | ||
| 1078 | 1091 | ||
| 1079 | public define HTML_In_Form | 1092 | public define HTML_In_Form |
| 1080 | private_download | 1093 | private_download |
| @@ -1133,7 +1146,7 @@ public type HTML_Off_Form: | @@ -1133,7 +1146,7 @@ public type HTML_Off_Form: | ||
| 1133 | paragraph (List(Text_Option), HTML_Off_Form content), | 1146 | paragraph (List(Text_Option), HTML_Off_Form content), |
| 1134 | image (String url), | 1147 | image (String url), |
| 1135 | image (String url, Int32 width, Int32 height), | 1148 | image (String url, Int32 width, Int32 height), |
| 1136 | - table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form))), | 1149 | + table (List(Table_Option), HTML_Header_Row(HTML_Off_Form), List(HTML_Row(HTML_Off_Form)), HTML_Footer_Row(HTML_Off_Form)), |
| 1137 | center (HTML_Off_Form), | 1150 | center (HTML_Off_Form), |
| 1138 | mail_to (String email, HTML_Off_Form element), | 1151 | mail_to (String email, HTML_Off_Form element), |
| 1139 | scroller (Int32 width, Int32 height, | 1152 | scroller (Int32 width, Int32 height, |
| @@ -1193,7 +1206,7 @@ public define HTML_Off_Form | @@ -1193,7 +1206,7 @@ public define HTML_Off_Form | ||
| 1193 | ( | 1206 | ( |
| 1194 | List(HTML_Row(HTML_Off_Form)) rows | 1207 | List(HTML_Row(HTML_Off_Form)) rows |
| 1195 | ) = | 1208 | ) = |
| 1196 | - table([],empty,rows). | 1209 | + table([],empty,rows,empty). |
| 1197 | 1210 | ||
| 1198 | public define HTML_Off_Form | 1211 | public define HTML_Off_Form |
| 1199 | table | 1212 | table |
| @@ -1201,15 +1214,24 @@ public define HTML_Off_Form | @@ -1201,15 +1214,24 @@ public define HTML_Off_Form | ||
| 1201 | List(Table_Option) options, | 1214 | List(Table_Option) options, |
| 1202 | List(HTML_Row(HTML_Off_Form)) rows | 1215 | List(HTML_Row(HTML_Off_Form)) rows |
| 1203 | ) = | 1216 | ) = |
| 1204 | - table(options,empty,rows). | 1217 | + table(options,empty,rows,empty). |
| 1218 | + | ||
| 1219 | +public define HTML_Off_Form | ||
| 1220 | + table | ||
| 1221 | + ( | ||
| 1222 | + HTML_Header_Row(HTML_Off_Form) h_row, | ||
| 1223 | + List(HTML_Row(HTML_Off_Form)) rows | ||
| 1224 | + ) = | ||
| 1225 | + table([],h_row,rows,empty). | ||
| 1205 | 1226 | ||
| 1206 | public define HTML_Off_Form | 1227 | public define HTML_Off_Form |
| 1207 | table | 1228 | table |
| 1208 | ( | 1229 | ( |
| 1230 | + List(Table_Option) options, | ||
| 1209 | HTML_Header_Row(HTML_Off_Form) h_row, | 1231 | HTML_Header_Row(HTML_Off_Form) h_row, |
| 1210 | List(HTML_Row(HTML_Off_Form)) rows | 1232 | List(HTML_Row(HTML_Off_Form)) rows |
| 1211 | ) = | 1233 | ) = |
| 1212 | - table([],h_row,rows). | 1234 | + table(options,h_row,rows,empty). |
| 1213 | 1235 | ||
| 1214 | We add two convenience functions for 'row'. The reason why we add two functions, one | 1236 | We add two convenience functions for 'row'. The reason why we add two functions, one |
| 1215 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an | 1237 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an |
| @@ -2364,7 +2386,7 @@ type HTML_Any($T): | @@ -2364,7 +2386,7 @@ type HTML_Any($T): | ||
| 2364 | any_paragraph (List(Text_Option), $T content), | 2386 | any_paragraph (List(Text_Option), $T content), |
| 2365 | any_image (String url), | 2387 | any_image (String url), |
| 2366 | any_image (String url, Int32 width, Int32 height), | 2388 | any_image (String url, Int32 width, Int32 height), |
| 2367 | - any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T))), | 2389 | + any_table (List(Table_Option), HTML_Header_Row($T), List(HTML_Row($T)), HTML_Footer_Row($T)), |
| 2368 | any_center ($T), | 2390 | any_center ($T), |
| 2369 | any_mail_to (String email, $T element), | 2391 | any_mail_to (String email, $T element), |
| 2370 | any_scroller (Int32 width, Int32 height, | 2392 | any_scroller (Int32 width, Int32 height, |
| @@ -2687,7 +2709,7 @@ public define Printable_tree | @@ -2687,7 +2709,7 @@ public define Printable_tree | ||
| 2687 | { | 2709 | { |
| 2688 | [ ] then [ ], | 2710 | [ ] then [ ], |
| 2689 | [h . t] then if h = selected.value | 2711 | [h . t] then if h = selected.value |
| 2690 | - then ["<option selected>", h, "</option>\n" . format_choices(t)] | 2712 | + then ["<option selected=\"selected\">", h, "</option>\n" . format_choices(t)] |
| 2691 | else ["<option>", h, "</option>\n" . format_choices(t,selected)] | 2713 | else ["<option>", h, "</option>\n" . format_choices(t,selected)] |
| 2692 | }. | 2714 | }. |
| 2693 | 2715 | ||
| @@ -3107,6 +3129,9 @@ define Printable_tree | @@ -3107,6 +3129,9 @@ define Printable_tree | ||
| 3107 | text, "</a>" | 3129 | text, "</a>" |
| 3108 | ], | 3130 | ], |
| 3109 | javascript(s,h) then | 3131 | javascript(s,h) then |
| 3132 | + if action_name = "" then | ||
| 3133 | + ["<input type=\"button\" value=\"",text,"\"", format_attrs(options), " />"] | ||
| 3134 | + else | ||
| 3110 | [s,"<input type=\"button\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"] | 3135 | [s,"<input type=\"button\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"] |
| 3111 | } | 3136 | } |
| 3112 | ], | 3137 | ], |
| @@ -3350,7 +3375,7 @@ define Printable_tree | @@ -3350,7 +3375,7 @@ define Printable_tree | ||
| 3350 | [h . t] then if h is row(options,cells) then | 3375 | [h . t] then if h is row(options,cells) then |
| 3351 | ["<tr ",format(reverse(options)),">", | 3376 | ["<tr ",format(reverse(options)),">", |
| 3352 | format(cells,format_element), | 3377 | format(cells,format_element), |
| 3353 | - "</tr>" | 3378 | + "</tr>\n" |
| 3354 | . format(t,format_element)] | 3379 | . format(t,format_element)] |
| 3355 | }. | 3380 | }. |
| 3356 | 3381 | ||
| @@ -3366,7 +3391,23 @@ define Printable_tree | @@ -3366,7 +3391,23 @@ define Printable_tree | ||
| 3366 | header_row(options,cells) then | 3391 | header_row(options,cells) then |
| 3367 | ["<thead> <tr ",format(reverse(options)),">", | 3392 | ["<thead> <tr ",format(reverse(options)),">", |
| 3368 | format(cells,format_element), | 3393 | format(cells,format_element), |
| 3369 | - "</tr> </thead>" | 3394 | + "</tr> </thead>\n" |
| 3395 | + ] | ||
| 3396 | + }. | ||
| 3397 | + | ||
| 3398 | +define Printable_tree | ||
| 3399 | + format | ||
| 3400 | + ( | ||
| 3401 | + HTML_Footer_Row($T) row, | ||
| 3402 | + $T -> Printable_tree format_element | ||
| 3403 | + ) = | ||
| 3404 | + if row is | ||
| 3405 | + { | ||
| 3406 | + empty then [ ], | ||
| 3407 | + footer_row(options,cells) then | ||
| 3408 | + ["<tfoot> <tr ",format(reverse(options)),">", | ||
| 3409 | + format(cells,format_element), | ||
| 3410 | + "</tr> </tfoot>\n" | ||
| 3370 | ] | 3411 | ] |
| 3371 | }. | 3412 | }. |
| 3372 | 3413 | ||
| @@ -3572,10 +3613,12 @@ define Printable_tree | @@ -3572,10 +3613,12 @@ define Printable_tree | ||
| 3572 | ["<img alt=\"",url,"\" src=\"",url,"\">"], | 3613 | ["<img alt=\"",url,"\" src=\"",url,"\">"], |
| 3573 | any_image(url,w,h) then | 3614 | any_image(url,w,h) then |
| 3574 | ["<img alt=\"",url,"\" src=\"",url,"\" width=",w," height=",h," />"], | 3615 | ["<img alt=\"",url,"\" src=\"",url,"\" width=",w," height=",h," />"], |
| 3575 | - any_table(opts,h_row, rows) then | 3616 | + any_table(opts,h_row, rows, f_row) then |
| 3576 | ["<table ",format(reverse(opts),false),">", | 3617 | ["<table ",format(reverse(opts),false),">", |
| 3577 | - format(h_row,format_element), | ||
| 3578 | - "<tbody>",format(rows,format_element),"</tbody></table>\n"], | 3618 | + format(h_row, format_element), |
| 3619 | + "<tbody>",format(rows,format_element),"</tbody>", | ||
| 3620 | + format(f_row, format_element), | ||
| 3621 | + "</table>\n"], | ||
| 3579 | any_center(e) then | 3622 | any_center(e) then |
| 3580 | ["<center>",format_element(e),"</center>"], | 3623 | ["<center>",format_element(e),"</center>"], |
| 3581 | any_mail_to(email,elem) then | 3624 | any_mail_to(email,elem) then |
| @@ -3652,8 +3695,8 @@ define Printable_tree | @@ -3652,8 +3695,8 @@ define Printable_tree | ||
| 3652 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), | 3695 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3653 | image(url,w,h) then | 3696 | image(url,w,h) then |
| 3654 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), | 3697 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), |
| 3655 | - table(opts,header_row,rows) then | ||
| 3656 | - format(cinfo,sn,ic_v,any_table(opts, header_row, rows),format_element,is_https), | 3698 | + table(opts,header_row,rows,footer_row) then |
| 3699 | + format(cinfo,sn,ic_v,any_table(opts, header_row, rows, footer_row),format_element,is_https), | ||
| 3657 | center(e) then | 3700 | center(e) then |
| 3658 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), | 3701 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3659 | mail_to(a,e) then | 3702 | mail_to(a,e) then |
| @@ -3740,6 +3783,18 @@ define Bool | @@ -3740,6 +3783,18 @@ define Bool | ||
| 3740 | mapor(contains_an_upload, | 3783 | mapor(contains_an_upload, |
| 3741 | map(content,cells(row))). | 3784 | map(content,cells(row))). |
| 3742 | 3785 | ||
| 3786 | +define Bool | ||
| 3787 | + contains_an_upload | ||
| 3788 | + ( | ||
| 3789 | + HTML_Footer_Row(HTML_In_Form) row | ||
| 3790 | + ) = | ||
| 3791 | + if row is | ||
| 3792 | + { | ||
| 3793 | + empty then false, | ||
| 3794 | + footer_row(_, cells) then | ||
| 3795 | + mapor(contains_an_upload, | ||
| 3796 | + map(content,cells)) | ||
| 3797 | + }. | ||
| 3743 | 3798 | ||
| 3744 | define Bool | 3799 | define Bool |
| 3745 | contains_an_upload | 3800 | contains_an_upload |
| @@ -3756,7 +3811,8 @@ define Bool | @@ -3756,7 +3811,8 @@ define Bool | ||
| 3756 | paragraph(o,t) then false, | 3811 | paragraph(o,t) then false, |
| 3757 | image(u) then false, | 3812 | image(u) then false, |
| 3758 | image(u,w,h) then false, | 3813 | image(u,w,h) then false, |
| 3759 | - table(o,_,rows) then mapor(contains_an_upload,rows), | 3814 | + table(o,_,rows,f_row) then if mapor(contains_an_upload,rows) then true |
| 3815 | + else contains_an_upload(f_row), | ||
| 3760 | center(e) then contains_an_upload(e), | 3816 | center(e) then contains_an_upload(e), |
| 3761 | mail_to(m,e) then false, // 'e' may but should not contain an upload | 3817 | mail_to(m,e) then false, // 'e' may but should not contain an upload |
| 3762 | scroller(w,h,cw,ch,e) then contains_an_upload(e), | 3818 | scroller(w,h,cw,ch,e) then contains_an_upload(e), |
| @@ -3819,8 +3875,8 @@ define Printable_tree | @@ -3819,8 +3875,8 @@ define Printable_tree | ||
| 3819 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), | 3875 | format(cinfo,sn,ic_v,any_image(url),format_element,is_https), |
| 3820 | image(url,w,h) then | 3876 | image(url,w,h) then |
| 3821 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), | 3877 | format(cinfo,sn,ic_v,any_image(url,w,h),format_element,is_https), |
| 3822 | - table(opts,header_row, rows) then | ||
| 3823 | - format(cinfo,sn,ic_v,any_table(opts,header_row, rows),format_element,is_https), | 3878 | + table(opts,header_row, rows, footer_row) then |
| 3879 | + format(cinfo,sn,ic_v,any_table(opts,header_row, rows, footer_row),format_element,is_https), | ||
| 3824 | center(e) then | 3880 | center(e) then |
| 3825 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), | 3881 | format(cinfo,sn,ic_v,any_center(e),format_element,is_https), |
| 3826 | mail_to(a,e) then | 3882 | mail_to(a,e) then |