Commit d0c372c0967fc2f8a22fc1377632c4b51b26846d
1 parent
e04d167e
add alternative fields_set in WEB_Session. This let create some fields gathered …
…into named fields_set.
Showing
3 changed files
with
153 additions
and
17 deletions
Show diff stats
web/CXM_making_a_web_site.anubis
| @@ -1392,6 +1392,7 @@ public define HTML_Off_Form footer(HTML_Off_Form content) | @@ -1392,6 +1392,7 @@ public define HTML_Off_Form footer(HTML_Off_Form content) | ||
| 1392 | 1392 | ||
| 1393 | // <form> | 1393 | // <form> |
| 1394 | public define HTML_Off_Form form(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("form", attrs, content). | 1394 | public define HTML_Off_Form form(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("form", attrs, content). |
| 1395 | +public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("form", [attr], content). | ||
| 1395 | 1396 | ||
| 1396 | // <header> | 1397 | // <header> |
| 1397 | public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content). | 1398 | public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content). |
| @@ -1527,7 +1528,11 @@ public define HTML_Off_Form strong(HTML_Off_Form content) | @@ -1527,7 +1528,11 @@ public define HTML_Off_Form strong(HTML_Off_Form content) | ||
| 1527 | 1528 | ||
| 1528 | // <textarea> | 1529 | // <textarea> |
| 1529 | public define HTML_Off_Form textarea(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("textarea", attrs, content). | 1530 | public define HTML_Off_Form textarea(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("textarea", attrs, content). |
| 1531 | +public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int cols, Int rows, List(HTML_Off_Form) content) | ||
| 1532 | + = html_tag("textarea", [attr("cols",to_String(cols)), attr("rows",to_String(rows)) . attrs], content). | ||
| 1530 | public define HTML_Off_Form textarea(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("textarea", attrs, [content]). | 1533 | public define HTML_Off_Form textarea(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("textarea", attrs, [content]). |
| 1534 | +public define HTML_Off_Form textarea(List(CoreAttrs) attrs, Int cols, Int rows, HTML_Off_Form content) | ||
| 1535 | + = html_tag("textarea", [attr("cols",to_String(cols)), attr("rows",to_String(rows)) . attrs], [content]). | ||
| 1531 | public define HTML_Off_Form textarea(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("textarea", [attr], content). | 1536 | public define HTML_Off_Form textarea(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("textarea", [attr], content). |
| 1532 | public define HTML_Off_Form textarea(CoreAttrs attr, HTML_Off_Form content) = html_tag("textarea", [attr], [content]). | 1537 | public define HTML_Off_Form textarea(CoreAttrs attr, HTML_Off_Form content) = html_tag("textarea", [attr], [content]). |
| 1533 | 1538 |
web/CXM_web_session.anubis
| @@ -53,7 +53,27 @@ define Var(List(WEB_Session_Field)) | @@ -53,7 +53,27 @@ define Var(List(WEB_Session_Field)) | ||
| 53 | ( | 53 | ( |
| 54 | List(WEB_Session_Field_No_Var) fields | 54 | List(WEB_Session_Field_No_Var) fields |
| 55 | )= | 55 | )= |
| 56 | - var(map((WEB_Session_Field_No_Var field) |-> session_field(field.field_name, field.field_type, var(field.field_datum)), fields)) | 56 | + var(map((WEB_Session_Field_No_Var field) |-> |
| 57 | + with datum = if field.field_datum is{ | ||
| 58 | + string(v) then string(v), | ||
| 59 | + bool(v) then bool(v), | ||
| 60 | + int(v) then int(v), | ||
| 61 | + db_id(v) then db_id(v), | ||
| 62 | + message(v) then message(v), | ||
| 63 | + byte_array(v) then byte_array(v), | ||
| 64 | + float(v) then float(v), | ||
| 65 | + word128(v) then word128(v), | ||
| 66 | + word64(v) then word64(v), | ||
| 67 | + word32(v) then word32(v), | ||
| 68 | + word16(v) then word16(v), | ||
| 69 | + word8(v) then word8(v), | ||
| 70 | + word4(v) then word4(v), | ||
| 71 | + fields_set(v) then fields_set(to_WEB_Session_Field(v)) | ||
| 72 | + }, | ||
| 73 | + session_field(field.field_name, field.field_type, var(datum)) | ||
| 74 | + , | ||
| 75 | + fields) | ||
| 76 | + ) | ||
| 57 | . | 77 | . |
| 58 | 78 | ||
| 59 | define List(WEB_Session_Field_No_Var) | 79 | define List(WEB_Session_Field_No_Var) |
| @@ -61,7 +81,24 @@ define List(WEB_Session_Field_No_Var) | @@ -61,7 +81,24 @@ define List(WEB_Session_Field_No_Var) | ||
| 61 | ( | 81 | ( |
| 62 | List(WEB_Session_Field) fields | 82 | List(WEB_Session_Field) fields |
| 63 | )= | 83 | )= |
| 64 | - map((WEB_Session_Field field) |-> session_field(field.field_name, field.field_type, *field.field_datum), fields) | 84 | + map((WEB_Session_Field field) |-> |
| 85 | + with datum = if *field.field_datum is{ | ||
| 86 | + string(v) then string(v), | ||
| 87 | + bool(v) then bool(v), | ||
| 88 | + int(v) then int(v), | ||
| 89 | + db_id(v) then db_id(v), | ||
| 90 | + message(v) then message(v), | ||
| 91 | + byte_array(v) then byte_array(v), | ||
| 92 | + float(v) then float(v), | ||
| 93 | + word128(v) then word128(v), | ||
| 94 | + word64(v) then word64(v), | ||
| 95 | + word32(v) then word32(v), | ||
| 96 | + word16(v) then word16(v), | ||
| 97 | + word8(v) then word8(v), | ||
| 98 | + word4(v) then word4(v), | ||
| 99 | + fields_set(v) then fields_set(to_WEB_Session_Field_No_Var(*v)) | ||
| 100 | + }, | ||
| 101 | + session_field(field.field_name, field.field_type, datum), fields) | ||
| 65 | . | 102 | . |
| 66 | 103 | ||
| 67 | public define WEB_Session | 104 | public define WEB_Session |
| @@ -1008,6 +1045,70 @@ public define One | @@ -1008,6 +1045,70 @@ public define One | ||
| 1008 | remove_any(fields, word4_t, _field_name) | 1045 | remove_any(fields, word4_t, _field_name) |
| 1009 | . | 1046 | . |
| 1010 | 1047 | ||
| 1048 | + /*************** Fields_set *****************/ | ||
| 1049 | + | ||
| 1050 | + Maybe(Word4) get_Word4(fields, _field_name) | ||
| 1051 | + Word4 get_Word4(fields, _field_name, default_value) | ||
| 1052 | + | ||
| 1053 | +public define Maybe(Var(List(WEB_Session_Field))) | ||
| 1054 | + get_Fields_set | ||
| 1055 | + ( | ||
| 1056 | + Var(List(WEB_Session_Field)) fields, | ||
| 1057 | + String _field_name, | ||
| 1058 | + ) = | ||
| 1059 | + if get_field(*fields, fields_set_t, _field_name) is | ||
| 1060 | + { | ||
| 1061 | + failure then failure, | ||
| 1062 | + success(datum) then | ||
| 1063 | + if datum is fields_set(value) then | ||
| 1064 | + success(value) | ||
| 1065 | + else | ||
| 1066 | + failure | ||
| 1067 | + } | ||
| 1068 | +. | ||
| 1069 | + | ||
| 1070 | +public define Var(List(WEB_Session_Field)) | ||
| 1071 | + get_Fields_set | ||
| 1072 | + ( | ||
| 1073 | + Var(List(WEB_Session_Field)) fields, | ||
| 1074 | + String _field_name, | ||
| 1075 | + Var(List(WEB_Session_Field)) default_value | ||
| 1076 | + ) = | ||
| 1077 | + if get_Fields_set(fields, _field_name) is | ||
| 1078 | + { | ||
| 1079 | + failure then default_value | ||
| 1080 | + success(value) then value | ||
| 1081 | + }. | ||
| 1082 | + | ||
| 1083 | + | ||
| 1084 | +public define One | ||
| 1085 | + put_Fields_set | ||
| 1086 | + ( | ||
| 1087 | + Var(List(WEB_Session_Field)) _fields, | ||
| 1088 | + String _field_name, | ||
| 1089 | + Var(List(WEB_Session_Field)) _field_value | ||
| 1090 | + )= | ||
| 1091 | + _fields <- [session_field(_field_name, fields_set_t, var(fields_set(_field_value))) . *_fields] | ||
| 1092 | +. | ||
| 1093 | + | ||
| 1094 | +public define One | ||
| 1095 | + replace_Fields_set | ||
| 1096 | + ( | ||
| 1097 | + Var(List(WEB_Session_Field)) _fields, | ||
| 1098 | + String _field_name, | ||
| 1099 | + Var(List(WEB_Session_Field)) _field_value | ||
| 1100 | + )= | ||
| 1101 | + replace_any(_fields, fields_set_t, _field_name, fields_set(_field_value)) | ||
| 1102 | +. | ||
| 1103 | + | ||
| 1104 | +public define One | ||
| 1105 | + remove_Fields_set | ||
| 1106 | + ( | ||
| 1107 | + Var(List(WEB_Session_Field)) _fields, | ||
| 1108 | + String _field_name | ||
| 1109 | + )= | ||
| 1110 | + remove_any(_fields, fields_set_t, _field_name) | ||
| 1111 | +. | ||
| 1011 | 1112 | ||
| 1012 | /************************************************/ | 1113 | /************************************************/ |
| 1013 | "AWS_CURRENT_PAGE_TITLE" String current web page title | 1114 | "AWS_CURRENT_PAGE_TITLE" String current web page title |
| @@ -1039,10 +1140,13 @@ public define String get_renderer(WEB_Session s) = get_String (s. | @@ -1039,10 +1140,13 @@ public define String get_renderer(WEB_Session s) = get_String (s. | ||
| 1039 | 1140 | ||
| 1040 | /************************************************/ | 1141 | /************************************************/ |
| 1041 | 1142 | ||
| 1143 | +public define String dump_WEB_Session_Field_list(List(WEB_Session_Field) _fields, String indent). | ||
| 1144 | + | ||
| 1042 | public define String | 1145 | public define String |
| 1043 | dump_WEB_Session_Field | 1146 | dump_WEB_Session_Field |
| 1044 | ( | 1147 | ( |
| 1045 | - WEB_Session_Field _field | 1148 | + WEB_Session_Field _field, |
| 1149 | + String indent | ||
| 1046 | )= | 1150 | )= |
| 1047 | with name = "Name = ["+_field.field_name+"]", | 1151 | with name = "Name = ["+_field.field_name+"]", |
| 1048 | if *_field.field_datum is | 1152 | if *_field.field_datum is |
| @@ -1060,35 +1164,39 @@ public define String | @@ -1060,35 +1164,39 @@ public define String | ||
| 1060 | word16(_word16) then name+", Type = Word16, Value = ["+to_decimal(_word16)+"]", | 1164 | word16(_word16) then name+", Type = Word16, Value = ["+to_decimal(_word16)+"]", |
| 1061 | word8(_word8) then name+", Type = Word8, Value = ["+to_decimal(_word8)+"]", | 1165 | word8(_word8) then name+", Type = Word8, Value = ["+to_decimal(_word8)+"]", |
| 1062 | word4(_word4) then name+", Type = Word4, Value = ["+to_decimal(_word4)+"]", | 1166 | word4(_word4) then name+", Type = Word4, Value = ["+to_decimal(_word4)+"]", |
| 1167 | + fields_set(_fields) then name+", Type = Fields_set, \n"+dump_WEB_Session_Field_list(*_fields, indent+" ") | ||
| 1063 | } | 1168 | } |
| 1064 | . | 1169 | . |
| 1065 | 1170 | ||
| 1066 | public define String | 1171 | public define String |
| 1067 | dump_WEB_Session_Field_list | 1172 | dump_WEB_Session_Field_list |
| 1068 | ( | 1173 | ( |
| 1069 | - List(WEB_Session_Field) _fields | 1174 | + List(WEB_Session_Field) _fields, |
| 1175 | + String indent | ||
| 1070 | )= | 1176 | )= |
| 1071 | - join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field), _fields)) | 1177 | + join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field, indent), _fields)) |
| 1072 | . | 1178 | . |
| 1073 | 1179 | ||
| 1074 | 1180 | ||
| 1075 | public define String | 1181 | public define String |
| 1076 | dump_WEB_Session_Fields | 1182 | dump_WEB_Session_Fields |
| 1077 | ( | 1183 | ( |
| 1078 | - List(WEB_Session_Field) _fields | 1184 | + List(WEB_Session_Field) _fields, |
| 1185 | + String indent | ||
| 1079 | )= | 1186 | )= |
| 1080 | "\n"+ | 1187 | "\n"+ |
| 1081 | - "-- BEGIN Fields of Session:---------------- \n"+ | ||
| 1082 | - join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field), _fields))+ | ||
| 1083 | - "\n-- END Fields of Session:---------------- \n" | 1188 | + indent+"-- BEGIN Fields of Session:---------------- \n"+ |
| 1189 | + join("\n", map((WEB_Session_Field _field) |-> dump_WEB_Session_Field(_field, indent), _fields))+ | ||
| 1190 | + "\n"+indent+"-- END Fields of Session:---------------- \n" | ||
| 1084 | . | 1191 | . |
| 1085 | 1192 | ||
| 1086 | public define String | 1193 | public define String |
| 1087 | dump_WEB_Session_Fields | 1194 | dump_WEB_Session_Fields |
| 1088 | ( | 1195 | ( |
| 1089 | - Var(List(WEB_Session_Field)) _fields | 1196 | + Var(List(WEB_Session_Field)) _fields, |
| 1197 | + String indent | ||
| 1090 | )= | 1198 | )= |
| 1091 | - dump_WEB_Session_Fields(*_fields) | 1199 | + dump_WEB_Session_Fields(*_fields, indent) |
| 1092 | . | 1200 | . |
| 1093 | 1201 | ||
| 1094 | *---------------------- DUMP ------------------* | 1202 | *---------------------- DUMP ------------------* |
| @@ -1108,7 +1216,7 @@ public define String | @@ -1108,7 +1216,7 @@ public define String | ||
| 1108 | "----------------- \n"+ | 1216 | "----------------- \n"+ |
| 1109 | "Session ID : ["+id+"]\n"+ | 1217 | "Session ID : ["+id+"]\n"+ |
| 1110 | "Language : ["+language+"]\n\n"+ | 1218 | "Language : ["+language+"]\n\n"+ |
| 1111 | - dump_WEB_Session_Fields(*fields)+ | 1219 | + dump_WEB_Session_Fields(*fields, "")+ |
| 1112 | "-----------------------------------------------------------------------------\n"+ | 1220 | "-----------------------------------------------------------------------------\n"+ |
| 1113 | "Current WEB REQUEST:\n"+ | 1221 | "Current WEB REQUEST:\n"+ |
| 1114 | "-----------------------------------------------------------------------------\n"+ | 1222 | "-----------------------------------------------------------------------------\n"+ |
web/types/web_session.anubis
| @@ -9,6 +9,9 @@ | @@ -9,6 +9,9 @@ | ||
| 9 | read calexium_lib/web/CXM_common.anubis | 9 | read calexium_lib/web/CXM_common.anubis |
| 10 | read calexium_lib/database/db_types.anubis | 10 | read calexium_lib/database/db_types.anubis |
| 11 | 11 | ||
| 12 | +public type WEB_Session_Field:... | ||
| 13 | +public type WEB_Session_Field_No_Var:... | ||
| 14 | + | ||
| 12 | public type WEB_Session_Field_Datum: | 15 | public type WEB_Session_Field_Datum: |
| 13 | string(String), //fully implented | 16 | string(String), //fully implented |
| 14 | bool(Bool), //fully implented | 17 | bool(Bool), //fully implented |
| @@ -22,7 +25,26 @@ public type WEB_Session_Field_Datum: | @@ -22,7 +25,26 @@ public type WEB_Session_Field_Datum: | ||
| 22 | word32(Word32), | 25 | word32(Word32), |
| 23 | word16(Word16), | 26 | word16(Word16), |
| 24 | word8(Word8), | 27 | word8(Word8), |
| 25 | - word4(Word4) | 28 | + word4(Word4), |
| 29 | + fields_set(Var(List(WEB_Session_Field))) | ||
| 30 | + //WEB_Request | ||
| 31 | +. | ||
| 32 | + | ||
| 33 | +public type WEB_Session_Field_Datum_No_Var: | ||
| 34 | + string(String), //fully implented | ||
| 35 | + bool(Bool), //fully implented | ||
| 36 | + int(Int), //fully implemented | ||
| 37 | + db_id(DB_id), | ||
| 38 | + message(Message), //fully implemented | ||
| 39 | + byte_array(ByteArray), | ||
| 40 | + float(Float), | ||
| 41 | + word128(Word128), | ||
| 42 | + word64(Word64), | ||
| 43 | + word32(Word32), | ||
| 44 | + word16(Word16), | ||
| 45 | + word8(Word8), | ||
| 46 | + word4(Word4), | ||
| 47 | + fields_set(List(WEB_Session_Field_No_Var)) | ||
| 26 | //WEB_Request | 48 | //WEB_Request |
| 27 | . | 49 | . |
| 28 | 50 | ||
| @@ -39,7 +61,8 @@ public type WEB_Session_Field_Type: | @@ -39,7 +61,8 @@ public type WEB_Session_Field_Type: | ||
| 39 | word32_t, | 61 | word32_t, |
| 40 | word16_t, | 62 | word16_t, |
| 41 | word8_t, | 63 | word8_t, |
| 42 | - word4_t | 64 | + word4_t, |
| 65 | + fields_set_t | ||
| 43 | . | 66 | . |
| 44 | 67 | ||
| 45 | public type WEB_Session_Field: | 68 | public type WEB_Session_Field: |
| @@ -51,9 +74,9 @@ public type WEB_Session_Field: | @@ -51,9 +74,9 @@ public type WEB_Session_Field: | ||
| 51 | 74 | ||
| 52 | public type WEB_Session_Field_No_Var: | 75 | public type WEB_Session_Field_No_Var: |
| 53 | session_field( | 76 | session_field( |
| 54 | - String field_name, | ||
| 55 | - WEB_Session_Field_Type field_type, | ||
| 56 | - WEB_Session_Field_Datum field_datum //Var because it can be replaced | 77 | + String field_name, |
| 78 | + WEB_Session_Field_Type field_type, | ||
| 79 | + WEB_Session_Field_Datum_No_Var field_datum //Var because it can be replaced | ||
| 57 | ). | 80 | ). |
| 58 | 81 | ||
| 59 | public type WEB_Request: | 82 | public type WEB_Request: |