Commit 974c8566fd29876100e5d7ffcfa3031246273447
1 parent
e8b05959
change phone_field and remove mobile_phone.
Now phone_field has attribute for describing the phone number type like (cellphone, landline, fax, etc)
Showing
5 changed files
with
145 additions
and
26 deletions
Show diff stats
ds_files/ds_types.anubis
| ... | ... | @@ -109,8 +109,12 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 109 | 109 | component(extern_type("HK_Text_Field_Attr", model_types+"hk_text_field_attr.anubis"), "hk_text_field_attr"), |
| 110 | 110 | ]), |
| 111 | 111 | enum("color_field", comment("String which representing RGBA color like HTML")), |
| 112 | - enum("phone_field", comment("phone field")), | |
| 113 | - enum("mobile_field", comment("mobile phone field")), | |
| 112 | + | |
| 113 | + alternative("phone_field", comment("phone field"), [ | |
| 114 | + component(extern_type("HK_Phone_Field_Attr", model_types+"hk_phone_field_attr.anubis"), "hk_ph_f_attr", comment("phone line number type like (cellphone, landline, fax, etc)")), | |
| 115 | + ]), | |
| 116 | + | |
| 117 | + //enum("mobile_field", comment("mobile phone field")), | |
| 114 | 118 | enum("url_field", comment("url field for website and so forth")), |
| 115 | 119 | enum("email_field", comment("email field")), |
| 116 | 120 | ]), |
| ... | ... | @@ -168,6 +172,13 @@ public define List(DS_Type_File) hayamiki_lib_types_description = |
| 168 | 172 | enum("auto_now", comment("Always update datetime at SQL update")), |
| 169 | 173 | enum("auto_now_add", comment("Set current datetime when row is created and can't be edited anymore")) |
| 170 | 174 | ]), |
| 175 | + | |
| 176 | + ds_type("HK_Phone_Field_Attr", [ | |
| 177 | + enum("generic", comment("Nothing special, normal phone number like home, mobile, etc..")), | |
| 178 | + enum("landline", comment("wired phone line number")), | |
| 179 | + enum("cellphone", comment("mobile or cell phone line number")), | |
| 180 | + enum("fax", comment("fax line number")), | |
| 181 | + ]), | |
| 171 | 182 | |
| 172 | 183 | ds_type("HK_Model_Attr", [ |
| 173 | 184 | enum("unique", comment("by default, the values in a column are not required to be all different ")), | ... | ... |
model/fields.anubis
| ... | ... | @@ -15,6 +15,7 @@ transmit hayamiki_lib/model/types/hk_model_field.anubis |
| 15 | 15 | transmit hayamiki_lib/model/types/hk_app_name.anubis |
| 16 | 16 | transmit hayamiki_lib/model/types/hk_text_field_attr.anubis |
| 17 | 17 | transmit hayamiki_lib/model/types/hk_datetime_field_attr.anubis |
| 18 | +transmit hayamiki_lib/model/types/hk_phone_field_attr.anubis | |
| 18 | 19 | transmit hayamiki_lib/model/types/hk_int_choices.anubis |
| 19 | 20 | transmit hayamiki_lib/model/types/hk_text_choices.anubis |
| 20 | 21 | |
| ... | ... | @@ -132,8 +133,29 @@ define HK_Datetime_Field_Attr |
| 132 | 133 | failure then none, |
| 133 | 134 | success(dt_attrib) then to_HK_Datetime_Field_Attr(dt_attrib) |
| 134 | 135 | }. |
| 136 | + | |
| 137 | +define String | |
| 138 | + to_String | |
| 139 | + ( | |
| 140 | + HK_Phone_Field_Attr attr | |
| 141 | + )= | |
| 142 | + if attr is | |
| 143 | + { | |
| 144 | + generic then "generic", | |
| 145 | + landline then "landline", | |
| 146 | + cellphone then "cellphone", | |
| 147 | + fax then "fax" | |
| 148 | + }. | |
| 135 | 149 | |
| 136 | 150 | |
| 151 | +public define String | |
| 152 | + to_Anubis_source | |
| 153 | + ( | |
| 154 | + HK_Phone_Field_Attr attr | |
| 155 | + )= | |
| 156 | + to_String(attr) | |
| 157 | +. | |
| 158 | + | |
| 137 | 159 | //default initialization |
| 138 | 160 | public define HK_Model_Field |
| 139 | 161 | char_field |
| ... | ... | @@ -251,12 +273,9 @@ public define JsonValue |
| 251 | 273 | [ json_member("type", json_string("color_field")) |
| 252 | 274 | ], |
| 253 | 275 | |
| 254 | - phone_field then | |
| 255 | - [ json_member("type", json_string("phone_field")) | |
| 256 | - ], | |
| 257 | - | |
| 258 | - mobile_field then | |
| 259 | - [ json_member("type", json_string("mobile_field")) | |
| 276 | + phone_field(attr) then | |
| 277 | + [ json_member("type", json_string("phone_field")), | |
| 278 | + json_member("phone_attribute", json_string(to_String(attr))) | |
| 260 | 279 | ], |
| 261 | 280 | |
| 262 | 281 | url_field then | ... | ... |
model/types/hk_model_field.anubis
| 1 | 1 | /* |
| 2 | 2 | * Created by 伝作 (Densaku). |
| 3 | 3 | * Types & Messages generator written by フランスのトトロ aka (David RENÉ) |
| 4 | - * Date: 2017-07-23 | |
| 5 | - * Time: 21:35:44 | |
| 4 | + * Date: 2017-09-16 | |
| 5 | + * Time: 09:48:18 | |
| 6 | 6 | * |
| 7 | 7 | */ |
| 8 | 8 | |
| ... | ... | @@ -10,6 +10,7 @@ transmit system/muscle.anubis |
| 10 | 10 | transmit system/convert.anubis |
| 11 | 11 | transmit tools/basis.anubis |
| 12 | 12 | |
| 13 | +transmit hayamiki_lib/model/types/hk_phone_field_attr.anubis | |
| 13 | 14 | transmit hayamiki_lib/model/types/hk_text_field_attr.anubis |
| 14 | 15 | transmit hayamiki_lib/model/types/hk_text_choices.anubis |
| 15 | 16 | transmit hayamiki_lib/model/types/hk_int_choices.anubis |
| ... | ... | @@ -54,8 +55,11 @@ public type HK_Model_Field: |
| 54 | 55 | HK_Text_Field_Attr hk_text_field_attr |
| 55 | 56 | ), |
| 56 | 57 | color_field, //String which representing RGBA color like HTML |
| 57 | - phone_field, //phone field | |
| 58 | - mobile_field, //mobile phone field | |
| 58 | + //phone field | |
| 59 | + | |
| 60 | + phone_field( | |
| 61 | + HK_Phone_Field_Attr hk_ph_f_attr //phone line number type like (cellphone, landline, fax, etc) | |
| 62 | + ), | |
| 59 | 63 | url_field, //url field for website and so forth |
| 60 | 64 | email_field //email field |
| 61 | 65 | . |
| ... | ... | @@ -145,13 +149,12 @@ public define Message |
| 145 | 149 | color_field then |
| 146 | 150 | forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "color_field")), |
| 147 | 151 | |
| 148 | - //Alternative phone_field (NO TYPE) | |
| 149 | - phone_field then | |
| 150 | - forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "phone_field")), | |
| 151 | - | |
| 152 | - //Alternative mobile_field (NO TYPE) | |
| 153 | - mobile_field then | |
| 154 | - forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "mobile_field")), | |
| 152 | + //Alternative phone_field | |
| 153 | + //phone field | |
| 154 | + phone_field(_hk_ph_f_attr) then | |
| 155 | + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "phone_field")); | |
| 156 | + // [type = HK_Phone_Field_Attr] phone_field.hk_ph_f_attr | |
| 157 | + forget(add_message(_hk_model_field_message, "hk_ph_f_attr", to_Message(_hk_ph_f_attr))), | |
| 155 | 158 | |
| 156 | 159 | //Alternative url_field (NO TYPE) |
| 157 | 160 | url_field then |
| ... | ... | @@ -258,12 +261,15 @@ public define Maybe(HK_Model_Field) |
| 258 | 261 | else //Alternative color_field (NO TYPE) |
| 259 | 262 | if __type_alt__ = "color_field" then |
| 260 | 263 | success(color_field) |
| 261 | - else //Alternative phone_field (NO TYPE) | |
| 262 | - if __type_alt__ = "phone_field" then | |
| 263 | - success(phone_field) | |
| 264 | - else //Alternative mobile_field (NO TYPE) | |
| 265 | - if __type_alt__ = "mobile_field" then | |
| 266 | - success(mobile_field) | |
| 264 | + else //Alternative phone_field | |
| 265 | + //phone field | |
| 266 | + if __type_alt__ = "phone_field" then //Alternative phone_field | |
| 267 | + // [type = HK_Phone_Field_Attr] phone_field.hk_ph_f_attr | |
| 268 | + if find_message(_hk_model_field_message, "hk_ph_f_attr") is {failure then failure, success(_hk_ph_f_attr__msg) then | |
| 269 | + if (Maybe(HK_Phone_Field_Attr))from_Message(_hk_ph_f_attr__msg) is {failure then failure, success(_hk_ph_f_attr_) then | |
| 270 | + | |
| 271 | + success(phone_field(_hk_ph_f_attr_)) | |
| 272 | + }} | |
| 267 | 273 | else //Alternative url_field (NO TYPE) |
| 268 | 274 | if __type_alt__ = "url_field" then |
| 269 | 275 | success(url_field) | ... | ... |
| 1 | +/* | |
| 2 | + * Created by 伝作 (Densaku). | |
| 3 | + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) | |
| 4 | + * Date: 2017-09-16 | |
| 5 | + * Time: 09:48:18 | |
| 6 | + * | |
| 7 | + */ | |
| 8 | + | |
| 9 | +transmit system/muscle.anubis | |
| 10 | +transmit system/convert.anubis | |
| 11 | +transmit tools/basis.anubis | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | +public type HK_Phone_Field_Attr: | |
| 17 | + generic, //Nothing special, normal phone number like home, mobile, etc.. | |
| 18 | + landline, //wired phone line number | |
| 19 | + cellphone, //mobile or cell phone line number | |
| 20 | + fax //fax line number | |
| 21 | +. | |
| 22 | + | |
| 23 | + HK_Phone_Field_Attr message format | |
| 24 | + ================================== | |
| 25 | + | |
| 26 | + | |
| 27 | +public define Message | |
| 28 | + to_Message | |
| 29 | + ( | |
| 30 | + HK_Phone_Field_Attr _hk_phone_field_attr | |
| 31 | + )= | |
| 32 | + with _hk_phone_field_attr_message = message((Word32)0), // | |
| 33 | + forget(add_string(_hk_phone_field_attr_message, "__TYPE__", "HK_Phone_Field_Attr")); | |
| 34 | + if _hk_phone_field_attr is | |
| 35 | + { | |
| 36 | + //Alternative generic (NO TYPE) | |
| 37 | + generic then | |
| 38 | + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "generic")), | |
| 39 | + | |
| 40 | + //Alternative landline (NO TYPE) | |
| 41 | + landline then | |
| 42 | + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "landline")), | |
| 43 | + | |
| 44 | + //Alternative cellphone (NO TYPE) | |
| 45 | + cellphone then | |
| 46 | + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "cellphone")), | |
| 47 | + | |
| 48 | + //Alternative fax (NO TYPE) | |
| 49 | + fax then | |
| 50 | + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "fax")), | |
| 51 | + | |
| 52 | + }; | |
| 53 | + _hk_phone_field_attr_message | |
| 54 | +. | |
| 55 | + | |
| 56 | +public define Maybe(HK_Phone_Field_Attr) | |
| 57 | + from_Message | |
| 58 | + ( | |
| 59 | + Message _hk_phone_field_attr_message | |
| 60 | + )= | |
| 61 | + if find_string(_hk_phone_field_attr_message, "__TYPE__") is {failure then failure, success(__type__) then | |
| 62 | + if find_string(_hk_phone_field_attr_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then | |
| 63 | + if __type__ = "HK_Phone_Field_Attr" then | |
| 64 | + //Alternative generic (NO TYPE) | |
| 65 | + if __type_alt__ = "generic" then | |
| 66 | + success(generic) | |
| 67 | + else //Alternative landline (NO TYPE) | |
| 68 | + if __type_alt__ = "landline" then | |
| 69 | + success(landline) | |
| 70 | + else //Alternative cellphone (NO TYPE) | |
| 71 | + if __type_alt__ = "cellphone" then | |
| 72 | + success(cellphone) | |
| 73 | + else //Alternative fax (NO TYPE) | |
| 74 | + if __type_alt__ = "fax" then | |
| 75 | + success(fax) | |
| 76 | + else | |
| 77 | + failure //No valid Alternative found ! | |
| 78 | + else | |
| 79 | + failure //Type not found in message ! | |
| 80 | + }} | |
| 81 | +. | |
| 82 | + | ... | ... |
view/types/hk_view.anubis
| ... | ... | @@ -72,7 +72,8 @@ public type VT_view_model_entry: |
| 72 | 72 | datetime (String label, String column_name, HK_Help_Text help), |
| 73 | 73 | color (String label, String column_name, HK_Help_Text help), |
| 74 | 74 | phone (String label, String column_name, HK_Help_Text help), |
| 75 | - email (String label, String column_name, HK_Help_Text help) | |
| 75 | + email (String label, String column_name, HK_Help_Text help), | |
| 76 | + url (String label, String column_name, HK_Help_Text help) | |
| 76 | 77 | . |
| 77 | 78 | |
| 78 | 79 | ... | ... |