Commit 4eeb47a275bd6a512a15b2284c27d3408caaead5
1 parent
7c92546d
add color_field
Showing
3 changed files
with
19 additions
and
58 deletions
Show diff stats
ds_files/ds_types.anubis
| @@ -103,7 +103,8 @@ public define List(DS_Type) hayamiki_lib_types_description = | @@ -103,7 +103,8 @@ public define List(DS_Type) hayamiki_lib_types_description = | ||
| 103 | alternative("text_field", comment("text of variable size"), | 103 | alternative("text_field", comment("text of variable size"), |
| 104 | [ | 104 | [ |
| 105 | component(extern_type("HK_Text_Field_Attr", model_types+"hk_text_field_attr.anubis"), "hk_text_field_attr"), | 105 | component(extern_type("HK_Text_Field_Attr", model_types+"hk_text_field_attr.anubis"), "hk_text_field_attr"), |
| 106 | - ]) | 106 | + ]), |
| 107 | + enum("color_field", comment("String which representing RGBA color like HTML")) | ||
| 107 | ]), | 108 | ]), |
| 108 | 109 | ||
| 109 | // | 110 | // |
model/fields.anubis
| @@ -35,6 +35,7 @@ transmit hayamiki_lib/model/types/hk_text_choices.anubis | @@ -35,6 +35,7 @@ transmit hayamiki_lib/model/types/hk_text_choices.anubis | ||
| 35 | float_field | Float | | 35 | float_field | Float | |
| 36 | char_field | String | max size text | 36 | char_field | String | max size text |
| 37 | text_field | String | arbitrary size text | 37 | text_field | String | arbitrary size text |
| 38 | + color_field | String | String which representing RGBA color like HTML | ||
| 38 | 39 | ||
| 39 | 40 | ||
| 40 | 41 | ||
| @@ -186,60 +187,7 @@ public define HK_Model_Field | @@ -186,60 +187,7 @@ public define HK_Model_Field | ||
| 186 | 187 | ||
| 187 | */ | 188 | */ |
| 188 | 189 | ||
| 189 | - public define Message | ||
| 190 | - to_Message | ||
| 191 | - ( | ||
| 192 | - HK_Model_Field hk_model_field | ||
| 193 | - )= | ||
| 194 | - with hk_model_field_message = message(_HK_FIELD), | ||
| 195 | - if hk_model_field is | ||
| 196 | - { | ||
| 197 | - p_key then | ||
| 198 | - forget(add_string(hk_model_field_message, "type", "p_key")), | ||
| 199 | - | ||
| 200 | - boolean_field then | ||
| 201 | - forget(add_string(hk_model_field_message, "type", "boolean_field")), | ||
| 202 | - | ||
| 203 | - date_field(attr) then | ||
| 204 | - forget(add_string(hk_model_field_message, "type", "date_field")); | ||
| 205 | - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), | ||
| 206 | - | ||
| 207 | - time_field(attr) then | ||
| 208 | - forget(add_string(hk_model_field_message, "type", "time_field")); | ||
| 209 | - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), | ||
| 210 | - | ||
| 211 | - datetime_field(attr) then | ||
| 212 | - forget(add_string(hk_model_field_message, "type", "datetime_field")); | ||
| 213 | - forget(add_string(hk_model_field_message, "dt_attribute", to_String(attr))), | ||
| 214 | - | ||
| 215 | - foreign_key(app_name, table_name) then // foreign key to 'id' in another (or same) table and column_name for choice selector. | ||
| 216 | - forget(add_string(hk_model_field_message, "type", "foreign_key")); | ||
| 217 | - forget(add_message(hk_model_field_message, "app_name", to_Message(app_name))); | ||
| 218 | - forget(add_string(hk_model_field_message, "table_name", table_name)), | ||
| 219 | - | ||
| 220 | - integer_field(choices) then // integer of arbitrary size | ||
| 221 | - //TODO add choices if need | ||
| 222 | - forget(add_string(hk_model_field_message, "type", "integer_field")), | ||
| 223 | - | ||
| 224 | - float_field then | ||
| 225 | - forget(add_string(hk_model_field_message, "type", "float_field")), | ||
| 226 | - | ||
| 227 | - char_field (choices, size) then // text of maximal size 'size' (number of characters) | ||
| 228 | - //TODO add choices if need | ||
| 229 | - forget(add_string(hk_model_field_message, "type", "char_field")); | ||
| 230 | - forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), | ||
| 231 | - | ||
| 232 | - password_field(size) then | ||
| 233 | - forget(add_string(hk_model_field_message, "type", "password_field")); | ||
| 234 | - forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))), | ||
| 235 | - | ||
| 236 | - text_field(text_attr) then // text of variable size | ||
| 237 | - forget(add_string(hk_model_field_message, "type", "text_field")); | ||
| 238 | - forget(add_string(hk_model_field_message, "text_attribute", to_String(text_attr))), | ||
| 239 | - | ||
| 240 | - }; | ||
| 241 | - hk_model_field_message | ||
| 242 | - . | 190 | + |
| 243 | 191 | ||
| 244 | public define JsonValue | 192 | public define JsonValue |
| 245 | to_JSON | 193 | to_JSON |
| @@ -298,6 +246,10 @@ public define JsonValue | @@ -298,6 +246,10 @@ public define JsonValue | ||
| 298 | [ json_member("type", json_string("text_field")), | 246 | [ json_member("type", json_string("text_field")), |
| 299 | json_member("text_attribute", json_string(to_String(attr))) | 247 | json_member("text_attribute", json_string(to_String(attr))) |
| 300 | ] | 248 | ] |
| 249 | + | ||
| 250 | + color_field then | ||
| 251 | + [ json_member("type", json_string("color_field")) | ||
| 252 | + ] | ||
| 301 | }, | 253 | }, |
| 302 | 254 | ||
| 303 | json_object("_HK_FIELD", members). | 255 | json_object("_HK_FIELD", members). |
model/types/hk_model_field.anubis
| 1 | /* | 1 | /* |
| 2 | * Created by 伝作 (Densaku). | 2 | * Created by 伝作 (Densaku). |
| 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) | 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2017-03-18 | ||
| 5 | - * Time: 23:38:31 | 4 | + * Date: 2017-03-29 |
| 5 | + * Time: 23:08:07 | ||
| 6 | * | 6 | * |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| @@ -49,7 +49,8 @@ public type HK_Model_Field: | @@ -49,7 +49,8 @@ public type HK_Model_Field: | ||
| 49 | 49 | ||
| 50 | text_field( | 50 | text_field( |
| 51 | HK_Text_Field_Attr hk_text_field_attr | 51 | HK_Text_Field_Attr hk_text_field_attr |
| 52 | - ) | 52 | + ), |
| 53 | + color_field //String which representing RGBA color like HTML | ||
| 53 | . | 54 | . |
| 54 | 55 | ||
| 55 | HK_Model_Field message format | 56 | HK_Model_Field message format |
| @@ -131,6 +132,10 @@ public define Message | @@ -131,6 +132,10 @@ public define Message | ||
| 131 | // [type = HK_Text_Field_Attr] text_field.hk_text_field_attr | 132 | // [type = HK_Text_Field_Attr] text_field.hk_text_field_attr |
| 132 | forget(add_message(_hk_model_field_message, "hk_text_field_attr", to_Message(_hk_text_field_attr))), | 133 | forget(add_message(_hk_model_field_message, "hk_text_field_attr", to_Message(_hk_text_field_attr))), |
| 133 | 134 | ||
| 135 | + //Alternative color_field (NO TYPE) | ||
| 136 | + color_field then | ||
| 137 | + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "color_field")), | ||
| 138 | + | ||
| 134 | }; | 139 | }; |
| 135 | _hk_model_field_message | 140 | _hk_model_field_message |
| 136 | . | 141 | . |
| @@ -223,6 +228,9 @@ public define Maybe(HK_Model_Field) | @@ -223,6 +228,9 @@ public define Maybe(HK_Model_Field) | ||
| 223 | 228 | ||
| 224 | success(text_field(hk_text_field_attr)) | 229 | success(text_field(hk_text_field_attr)) |
| 225 | }} | 230 | }} |
| 231 | + else //Alternative color_field (NO TYPE) | ||
| 232 | + if __type_alt__ = "color_field" then | ||
| 233 | + success(color_field) | ||
| 226 | else | 234 | else |
| 227 | failure //No valid Alternative found ! | 235 | failure //No valid Alternative found ! |
| 228 | else | 236 | else |