From 974c8566fd29876100e5d7ffcfa3031246273447 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 16 Sep 2017 10:53:40 +0900 Subject: [PATCH] change phone_field and remove mobile_phone. Now phone_field has attribute for describing the phone number type like (cellphone, landline, fax, etc) --- ds_files/ds_types.anubis | 15 +++++++++++++-- model/fields.anubis | 31 +++++++++++++++++++++++++------ model/types/hk_model_field.anubis | 40 +++++++++++++++++++++++----------------- model/types/hk_phone_field_attr.anubis | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ view/types/hk_view.anubis | 3 ++- 5 files changed, 145 insertions(+), 26 deletions(-) create mode 100644 model/types/hk_phone_field_attr.anubis diff --git a/ds_files/ds_types.anubis b/ds_files/ds_types.anubis index 00e0719..aab23f2 100644 --- a/ds_files/ds_types.anubis +++ b/ds_files/ds_types.anubis @@ -109,8 +109,12 @@ public define List(DS_Type_File) hayamiki_lib_types_description = component(extern_type("HK_Text_Field_Attr", model_types+"hk_text_field_attr.anubis"), "hk_text_field_attr"), ]), enum("color_field", comment("String which representing RGBA color like HTML")), - enum("phone_field", comment("phone field")), - enum("mobile_field", comment("mobile phone field")), + + alternative("phone_field", comment("phone field"), [ + 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)")), + ]), + + //enum("mobile_field", comment("mobile phone field")), enum("url_field", comment("url field for website and so forth")), enum("email_field", comment("email field")), ]), @@ -168,6 +172,13 @@ public define List(DS_Type_File) hayamiki_lib_types_description = enum("auto_now", comment("Always update datetime at SQL update")), enum("auto_now_add", comment("Set current datetime when row is created and can't be edited anymore")) ]), + + ds_type("HK_Phone_Field_Attr", [ + enum("generic", comment("Nothing special, normal phone number like home, mobile, etc..")), + enum("landline", comment("wired phone line number")), + enum("cellphone", comment("mobile or cell phone line number")), + enum("fax", comment("fax line number")), + ]), ds_type("HK_Model_Attr", [ enum("unique", comment("by default, the values in a column are not required to be all different ")), diff --git a/model/fields.anubis b/model/fields.anubis index 2ffd7ae..91542d1 100644 --- a/model/fields.anubis +++ b/model/fields.anubis @@ -15,6 +15,7 @@ transmit hayamiki_lib/model/types/hk_model_field.anubis transmit hayamiki_lib/model/types/hk_app_name.anubis transmit hayamiki_lib/model/types/hk_text_field_attr.anubis transmit hayamiki_lib/model/types/hk_datetime_field_attr.anubis +transmit hayamiki_lib/model/types/hk_phone_field_attr.anubis transmit hayamiki_lib/model/types/hk_int_choices.anubis transmit hayamiki_lib/model/types/hk_text_choices.anubis @@ -132,8 +133,29 @@ define HK_Datetime_Field_Attr failure then none, success(dt_attrib) then to_HK_Datetime_Field_Attr(dt_attrib) }. + +define String + to_String + ( + HK_Phone_Field_Attr attr + )= + if attr is + { + generic then "generic", + landline then "landline", + cellphone then "cellphone", + fax then "fax" + }. +public define String + to_Anubis_source + ( + HK_Phone_Field_Attr attr + )= + to_String(attr) +. + //default initialization public define HK_Model_Field char_field @@ -251,12 +273,9 @@ public define JsonValue [ json_member("type", json_string("color_field")) ], - phone_field then - [ json_member("type", json_string("phone_field")) - ], - - mobile_field then - [ json_member("type", json_string("mobile_field")) + phone_field(attr) then + [ json_member("type", json_string("phone_field")), + json_member("phone_attribute", json_string(to_String(attr))) ], url_field then diff --git a/model/types/hk_model_field.anubis b/model/types/hk_model_field.anubis index 89686da..8b5eab1 100644 --- a/model/types/hk_model_field.anubis +++ b/model/types/hk_model_field.anubis @@ -1,8 +1,8 @@ /* * Created by 伝作 (Densaku). * Types & Messages generator written by フランスのトトロ aka (David RENÉ) - * Date: 2017-07-23 - * Time: 21:35:44 + * Date: 2017-09-16 + * Time: 09:48:18 * */ @@ -10,6 +10,7 @@ transmit system/muscle.anubis transmit system/convert.anubis transmit tools/basis.anubis +transmit hayamiki_lib/model/types/hk_phone_field_attr.anubis transmit hayamiki_lib/model/types/hk_text_field_attr.anubis transmit hayamiki_lib/model/types/hk_text_choices.anubis transmit hayamiki_lib/model/types/hk_int_choices.anubis @@ -54,8 +55,11 @@ public type HK_Model_Field: HK_Text_Field_Attr hk_text_field_attr ), color_field, //String which representing RGBA color like HTML - phone_field, //phone field - mobile_field, //mobile phone field + //phone field + + phone_field( + HK_Phone_Field_Attr hk_ph_f_attr //phone line number type like (cellphone, landline, fax, etc) + ), url_field, //url field for website and so forth email_field //email field . @@ -145,13 +149,12 @@ public define Message color_field then forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "color_field")), - //Alternative phone_field (NO TYPE) - phone_field then - forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "phone_field")), - - //Alternative mobile_field (NO TYPE) - mobile_field then - forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "mobile_field")), + //Alternative phone_field + //phone field + phone_field(_hk_ph_f_attr) then + forget(add_string(_hk_model_field_message, "__TYPE_ALT__", "phone_field")); + // [type = HK_Phone_Field_Attr] phone_field.hk_ph_f_attr + forget(add_message(_hk_model_field_message, "hk_ph_f_attr", to_Message(_hk_ph_f_attr))), //Alternative url_field (NO TYPE) url_field then @@ -258,12 +261,15 @@ public define Maybe(HK_Model_Field) else //Alternative color_field (NO TYPE) if __type_alt__ = "color_field" then success(color_field) - else //Alternative phone_field (NO TYPE) - if __type_alt__ = "phone_field" then - success(phone_field) - else //Alternative mobile_field (NO TYPE) - if __type_alt__ = "mobile_field" then - success(mobile_field) + else //Alternative phone_field + //phone field + if __type_alt__ = "phone_field" then //Alternative phone_field + // [type = HK_Phone_Field_Attr] phone_field.hk_ph_f_attr + if find_message(_hk_model_field_message, "hk_ph_f_attr") is {failure then failure, success(_hk_ph_f_attr__msg) then + if (Maybe(HK_Phone_Field_Attr))from_Message(_hk_ph_f_attr__msg) is {failure then failure, success(_hk_ph_f_attr_) then + + success(phone_field(_hk_ph_f_attr_)) + }} else //Alternative url_field (NO TYPE) if __type_alt__ = "url_field" then success(url_field) diff --git a/model/types/hk_phone_field_attr.anubis b/model/types/hk_phone_field_attr.anubis new file mode 100644 index 0000000..1cf4ea8 --- /dev/null +++ b/model/types/hk_phone_field_attr.anubis @@ -0,0 +1,82 @@ +/* + * Created by 伝作 (Densaku). + * Types & Messages generator written by フランスのトトロ aka (David RENÉ) + * Date: 2017-09-16 + * Time: 09:48:18 + * + */ + +transmit system/muscle.anubis +transmit system/convert.anubis +transmit tools/basis.anubis + + + + +public type HK_Phone_Field_Attr: + generic, //Nothing special, normal phone number like home, mobile, etc.. + landline, //wired phone line number + cellphone, //mobile or cell phone line number + fax //fax line number +. + + HK_Phone_Field_Attr message format + ================================== + + +public define Message + to_Message + ( + HK_Phone_Field_Attr _hk_phone_field_attr + )= + with _hk_phone_field_attr_message = message((Word32)0), // + forget(add_string(_hk_phone_field_attr_message, "__TYPE__", "HK_Phone_Field_Attr")); + if _hk_phone_field_attr is + { + //Alternative generic (NO TYPE) + generic then + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "generic")), + + //Alternative landline (NO TYPE) + landline then + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "landline")), + + //Alternative cellphone (NO TYPE) + cellphone then + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "cellphone")), + + //Alternative fax (NO TYPE) + fax then + forget(add_string(_hk_phone_field_attr_message, "__TYPE_ALT__", "fax")), + + }; + _hk_phone_field_attr_message +. + +public define Maybe(HK_Phone_Field_Attr) + from_Message + ( + Message _hk_phone_field_attr_message + )= + if find_string(_hk_phone_field_attr_message, "__TYPE__") is {failure then failure, success(__type__) then + if find_string(_hk_phone_field_attr_message, "__TYPE_ALT__") is {failure then failure, success(__type_alt__) then + if __type__ = "HK_Phone_Field_Attr" then + //Alternative generic (NO TYPE) + if __type_alt__ = "generic" then + success(generic) + else //Alternative landline (NO TYPE) + if __type_alt__ = "landline" then + success(landline) + else //Alternative cellphone (NO TYPE) + if __type_alt__ = "cellphone" then + success(cellphone) + else //Alternative fax (NO TYPE) + if __type_alt__ = "fax" then + success(fax) + else + failure //No valid Alternative found ! + else + failure //Type not found in message ! + }} +. + diff --git a/view/types/hk_view.anubis b/view/types/hk_view.anubis index 1e010d7..b2d9b30 100644 --- a/view/types/hk_view.anubis +++ b/view/types/hk_view.anubis @@ -72,7 +72,8 @@ public type VT_view_model_entry: datetime (String label, String column_name, HK_Help_Text help), color (String label, String column_name, HK_Help_Text help), phone (String label, String column_name, HK_Help_Text help), - email (String label, String column_name, HK_Help_Text help) + email (String label, String column_name, HK_Help_Text help), + url (String label, String column_name, HK_Help_Text help) . -- libgit2 0.21.4